10.63 Feature Selection

20180726 The FSelector (Romanski, Kotthoff, and Schratz 2023) 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::%s+% operator is a convenience 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.

% Do we need options(scipen=10) here - Tony does?

# 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_today"
# Use information gain to identify variable importance.

information.gain(form, ds[vars])
##                 attr_importance
## min_temp            0.005842268
## max_temp            0.014035403
## rainfall            0.057195021
## evaporation         0.004072236
## sunshine            0.042379579
## wind_gust_dir       0.005179419
## wind_gust_speed     0.025955989
## wind_dir_9am        0.008778442
## wind_dir_3pm        0.004432471
## wind_speed_9am      0.004207069
## wind_speed_3pm      0.005244380
## humidity_9am        0.037801417
## humidity_3pm        0.113361768
## pressure_9am        0.026408028
## cloud_9am           0.030038069
## cloud_3pm           0.044644071
## rain_today          0.045789061

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().

References

Romanski, Piotr, Lars Kotthoff, and Patrick Schratz. 2023. FSelector: Selecting Attributes. https://github.com/larskotthoff/fselector.


If you find this curated material useful then you can consider a donation to support it's ongoing availability and give you access to the PDF version of this book. The material has been scoped up by Generative AI without permission or any kind of recompense so do consider a donation if you can afford it. Unlike Generative AI your access to this materials is freely given. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Togaware has a 30 year tradition of making popular open source software which includes sold privacy preserving productivity apps, rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0