Most of machine learning is cleaning the data
For a uni machine learning project, we predicted whether a driver would accept a coupon offer, using a dataset of 12,684 driving scenarios with 26 variables. I owned data preparation and the logistic regression model. Data prep took far longer than the modelling.
What the data threw at me:
- A column that was almost empty. One variable was missing in about 99% of rows. No imputation rescues that, so it went.
- Small gaps worth filling. Several “how often do you visit X” columns were missing 1 to 2% of values. Those were worth imputing rather than throwing rows away.
- Numbers that aren’t numbers. Age mixed values like
21and26with text likebelow21and50plus. Time was stored as strings like10AM. Both needed converting before a model could use them. - Variables that repeat each other. Some binary columns were very highly correlated. A correlation heatmap made those easy to find and drop.
Then the models. I built and tuned the logistic regression with GridSearchCV, and my teammate Luke built the decision tree and neural network. For my individual part, I compared all three saved models on a fresh test split using accuracy, ROC curves and AUC. The neural network came out on top.
What I’d tell myself at the start: read every column before touching a model. Classifying each variable as binary, ordinal, nominal or numeric up front saved me from encoding mistakes later.