Description Usage Arguments Value Examples
This function predicts classes of new objects with given rFerns
object.
1 2 |
object |
Object of a class |
x |
Data frame containing attributes; must have corresponding names to training set (although order is not important) and do not introduce new factor levels. If this argument is not given, OOB predictions on the training set will be returned. |
scores |
If |
... |
Additional parameters. |
Predictions.
If scores
is TRUE
, a factor vector (for many-class classification) or a logical data.frame (for multi-class classification) with predictions, else a data.frame with class' scores.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | set.seed(77)
#Fetch Iris data
data(iris)
#Split into tRain and tEst set
iris[c(TRUE,FALSE),]->irisR
iris[c(FALSE,TRUE),]->irisE
#Build model
rFerns(Species~.,data=irisR)->model
print(model)
#Test
predict(model,irisE)->p
print(table(
Predictions=p,
True=irisE[["Species"]]))
err<-mean(p!=irisE[["Species"]])
print(paste("Test error",err,sep=" "))
#Show first OOB scores
head(predict(model,scores=TRUE))
|
Forest of 1000 ferns of a depth 5.
OOB error 5.33%; OOB confusion matrix:
True
Predicted setosa versicolor virginica
setosa 25 0 0
versicolor 0 23 2
virginica 0 2 23
True
Predictions setosa versicolor virginica
setosa 25 0 0
versicolor 0 23 2
virginica 0 2 23
[1] "Test error 0.0533333333333333"
setosa versicolor virginica
1 365.5591 -611.7447 -689.0393
2 355.2148 -532.3447 -656.8028
3 356.9968 -611.9595 -655.4825
4 335.4048 -542.7392 -608.9734
5 207.1545 -309.8834 -452.9373
6 326.7404 -532.5410 -609.7109
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.