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

Get Practical Predictive Analytics now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.