data("iris")
iris$Species <- as.integer(as.factor(iris$Species))
xtrain <- iris[1:100,]
xtest <- iris[101:150,]
bst <- KNNTrainer$new(k=3, prob=TRUE, type="class")
bst$fit(xtrain, xtest, 'Species')
pred <- bst$predict(type="raw")
## ------------------------------------------------
## Method `KNNTrainer$new`
## ------------------------------------------------
data("iris")
iris$Species <- as.integer(as.factor(iris$Species))
xtrain <- iris[1:100,]
xtest <- iris[101:150,]
bst <- KNNTrainer$new(k=3, prob=TRUE, type="class")
bst$fit(xtrain, xtest, 'Species')
pred <- bst$predict(type="raw")
## ------------------------------------------------
## Method `KNNTrainer$fit`
## ------------------------------------------------
data("iris")
iris$Species <- as.integer(as.factor(iris$Species))
xtrain <- iris[1:100,]
xtest <- iris[101:150,]
bst <- KNNTrainer$new(k=3, prob=TRUE, type="class")
bst$fit(xtrain, xtest, 'Species')
## ------------------------------------------------
## Method `KNNTrainer$predict`
## ------------------------------------------------
data("iris")
iris$Species <- as.integer(as.factor(iris$Species))
xtrain <- iris[1:100,]
xtest <- iris[101:150,]
bst <- KNNTrainer$new(k=3, prob=TRUE, type="class")
bst$fit(xtrain, xtest, 'Species')
pred <- bst$predict(type="raw")
Run the code above in your browser using DataLab