data(BloodBrain)
inTrain <- createDataPartition(logBBB, p = .8)[[1]]
trainX <- bbbDescr[inTrain,]
trainY <- logBBB[inTrain]
testX <- bbbDescr[-inTrain,]
testY <- logBBB[-inTrain]
fit <- knnreg(trainX, trainY, k = 3)
plot(testY, predict(fit, testX))
Run the code above in your browser using DataLab