Predict using randomForest package in R

前端 未结 2 1622
灰色年华
灰色年华 2021-01-24 07:19

How can I use result of randomForrest call in R to predict labels on some unlabled data (e.g. real world input to be classified)?
Code:

train_data = read.csv         


        
2条回答
  •  灰色年华
    2021-01-24 07:58

    You can use the predict function

    for example:

    data(iris)
    set.seed(111)
    ind <- sample(2, nrow(iris), replace = TRUE, prob=c(0.8, 0.2))
    iris.rf <- randomForest(Species ~ ., data=iris[ind == 1,])
    iris.pred <- predict(iris.rf, iris[ind == 2,])
    

    This is from http://ugrad.stat.ubc.ca/R/library/randomForest/html/predict.randomForest.html

提交回复
热议问题