# NOT RUN {
library(ksNN)
set.seed(1)
#make the nonlinear regression problem
X<-runif(100)
Y<-X^6-3*X^3+5*X^2+2
suffle<-order(rnorm(length(X)))
X<-X[suffle]
Y<-Y[suffle]
test_X<-X[1]
test_Y<-Y[1]
train_X<-X[-1]
train_Y<-Y[-1]
Label<-train_Y
Distance<-sqrt((test_X-train_X)^2)
pred_ksNN<-ksNN(Label,Distance,L_C=1)
#the predicted value with k*NN
pred_ksNN$pred
#the 'true' value
test_Y
# }
Run the code above in your browser using DataLab