Selecting features using the caret package

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.

Getting ready

In this recipe, we will continue to use the telecom churn dataset as the input data source for feature selection.

How to do it...

Perform the following steps to select features:

  1. Transform the feature named as international_plan of the training dataset, trainset, to

Get R: Recipes for Analysis, Visualization and Machine Learning now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.