Random forest model
In this exercise, you will use the randomForest() function in the randomForest package to build a random forest model for predicting churn of the customers in the training data set, training_set. The target variable is called Future.
You will also inspect and visualize the importance of the variables in the model.
本练习是课程的一部分
Predictive Analytics using Networked Data in R
练习说明
- Load the
randomForestpackage. - Use the
set.seed()function with the seed 863. - Build a random forest using the function
randomForest()and all the variables intraining_set. The response variableFutureneeds to be a factor, so utilize theas.factor()function. - Plot the variable importance of the random forest model using
varImpPlot().
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Load package
___(randomForest)
# Set seed
set.seed(___)
# Build model
rfModel <- ___(as.factor(___)~. ,data=training_set)
# Plot variable importance
varImpPlot(___)