O'Reilly logo

Practical Predictive Analytics by Ralph Winters

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Constructing new variables

Even though OneR works by finding the single best predictor, we can also try to improve the predictions by constructing some new variables and tricking OneR into thinking it is one variable.

In the code below we are creating new variables by combining attributes of single variables such ass of build, eyecolor, and hair color. After running the OneR model again, you can see that it helps a bit in terms of prediction accuracy and one of the new variables (eye_hair_build) is now ranked second.

This is a simple example of how you can perform "feature engineering".

tmp <- train_data tmp$eye_hair_build <- paste(train_data$eyecolor,train_data$haircolr,train_data$build) tmp$weapon <- paste(train_data$knifcuti,train_data$riflshot,train_data$pistol,train_data$machgun,train_data$othrweap) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required