knnreg

0th

Percentile

k-Nearest Neighbour Regression

$k$-nearest neighbour clasregressionsification that can return the average value for the neighbours.

Keywords
multivariate
Usage
## S3 method for class 'default':
knnreg(x, ...)

## S3 method for class 'formula': knnreg(formula, data, subset, na.action, k = 5, ...)

## S3 method for class 'matrix': knnreg(x, y, k = 5, ...)

## S3 method for class 'data.frame': knnreg(x, y, k = 5, ...)

knnregTrain(train, test, y, k = 5, use.all=TRUE)

Details

knnreg is similar to ipredknn and knnregTrain is a modification of knn. The underlying C code from the class pacakge has been modifed to return average outcome.

Value

Aliases
Examples
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))
Documentation reproduced from package caret, version 5.07-001, License: GPL-2

Community examples

Looks like there are no examples yet.