Created
October 29, 2012 21:56
-
-
Save bdewilde/3976802 to your computer and use it in GitHub Desktop.
optimal implementation of a weighted knn model
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
# load test datasets | |
test <- read.csv("test.csv", header=TRUE) | |
# train the optimal kknn model | |
model <- kknn(as.factor(label) ~ ., train, test, k=9, kernel="triangular") | |
results <- model$fitted.values | |
# save the class predictions in a column vector | |
write(as.numeric(levels(results))[results], file="kknn_submission.csv", ncolumns=1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment