Data Science Desktop Survival Guide by Graham Williams Desktop Survival Project Home Preface Data Science Introducing R R Constructs R Tasks R Strings R Read, Write, and Create Data Template Data Exploration Data Wrangling Data Visualisation Statistics ML Template ML Scenarios ML Activities ML Applications ML Algorithms Cluster Analysis Decision Trees Computer Vision Graph Data Privacy Literate Data Science Coding with Style Resources Bibliography Index

## Feature Selection

20180726 The FSelector package provides functions to identify subsets of variables that might be more effective for modelling. We can use this (and other packages) to assist us in reducing the variables that will be useful in our modelling. As we find useful functionality we will add them to our standard template so that for our next dataset we have the functionality readily available.

We first use FSelector::cfs() to identify a good subset of variables using correlation and entropy. We then list the variable importance using FSelector::information.gain() to advise a useful subset of variables. Note that the stringi::https://www.rdocumentation.org/packages/stringi/topics/to concatenate strings together to produce a formula that indicates we will model the target variable using all of the other variables of the dataset.

# Construct the formulation of the modelling we plan to do.

form <- formula(target %s+% " ~ .") %T>% print()
 ```## rain_tomorrow ~ . ```

# Use correlation search to identify key variables.

cfs(form, ds[vars])
 ```## [1] "rainfall" "sunshine" "humidity_3pm" "cloud_3pm" "rain_to... ```

# Use information gain to identify variable importance.

information.gain(form, ds[vars])
 ```## attr_importance ## min_temp 0.005574465 ## max_temp 0.014306291 ## rainfall 0.058146788 ## evaporation 0.004816268 ## sunshine 0.050838588 ## wind_gust_dir 0.005941322 ## wind_gust_speed 0.026772843 ## wind_dir_9am 0.008740164 ## wind_dir_3pm 0.004717540 ## wind_speed_9am 0.004189375 ## wind_speed_3pm 0.005426695 ## humidity_9am 0.038093685 ## humidity_3pm 0.108910707 ## pressure_9am 0.027130527 ## cloud_9am 0.032297858 ## cloud_3pm 0.047524832 ## rain_today 0.046474217 ```

The two measures are consistent in this case in that the variables identified by FSelector::cfs() are the more important variables identified by FSelector::information.gain().