Created
June 9, 2011 02:29
-
-
Save actsasgeek/1015926 to your computer and use it in GitHub Desktop.
The spec for NearestNeighbor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NearestNeighborSpec extends Spec with ShouldMatchers { | |
describe( "A Nearest Neighbor classifier") { | |
val library = List( | |
new Instance( List( 3.0, 3.0), Some( "A")), | |
new Instance( List( 4.0, 2.0), Some( "A")), | |
new Instance( List( 2.0, 2.0), Some( "B")) | |
) | |
val nearestNeighbor = new NearestNeighbor( library) | |
it( "can find the 1st closest example in the library to a query") { | |
val query = new Instance( List( 0.0, 0.0)) | |
val queryResult = nearestNeighbor.classify( query) | |
queryResult.classLabel should be === Some( "B") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment