The feature selection method searches the subset of features with minimized predictive errors. We can apply feature selection to identify which attributes are required to build an accurate model. The caret
package provides a recursive feature elimination function, rfe
, which can help automatically select the required features. In the following recipe, we will demonstrate how to use the caret
package to perform feature selection.
In this recipe, we will continue to use the telecom churn
dataset as the input data source for feature selection.
Perform the following steps to select features:
- Transform the feature named as
international_plan
from the training dataset,trainset
, tointl_yes
andintl_no
:
> intl_plan = model.matrix(~ trainset.international_plan - 1,
data=data.frame(trainset$international_plan))
> colnames(intl_plan) =
c("trainset.international_planno"="intl_no",
"trainset.international_planyes...