Created
June 8, 2011 19:04
-
-
Save actsasgeek/1015104 to your computer and use it in GitHub Desktop.
"Walking skeleton" of the nearest neighbor algorithm.
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 Instance( featureValues: List[Double], var classLabel: String) { | |
} | |
class NearestNeighbor( library: List[Instance]) { | |
def classify( query: Instance) { | |
query.classLabel = "unknown" | |
} | |
} | |
object NearestNeighbor { | |
def create( libraryFileName: String): NearestNeighbor = { | |
val library = new List[ Instance]( 10) | |
new NearestNeighbor( library) | |
} | |
} | |
val examples = NearestNeighbor.create( "library.data") | |
val query = new Instance( List( 0.0, 0.0, 0.0, 0.0), null) | |
examples.classify( query) | |
println( query.classLabel) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment