Data-Analysis-and-Machine-Learning-Projects icon indicating copy to clipboard operation
Data-Analysis-and-Machine-Learning-Projects copied to clipboard

ML notebook: Add preprocessing and a sklearn pipeline

Open rhiever opened this issue 10 years ago • 3 comments
trafficstars

From a Reddit comment:

Advice: I think you are missing a few big things like preprocessing/scaling and pipelines.

Before using the learners, inputs should be scaled so that each feature has equal weight. Something like StandardScaler or MinMaxScaler are both appropriate (from sklearn.preprocessing). If you think some features are more important, you can scale them later to increase their relative importance in prediction. These are more parameters you would tune using CV, but these can be really numerous, so GridSearch is out the window and you would have to consider some alternatives like Nelder Mead search, genetic search, or multivariate gradient descent if you suspect convexity.

You have to fit these scalers on the training data and then use the trained fit to transform the testing data. Using Pipelines simplifies this whole process (fits the scaler and learner at once, transforms and predicts at once).

rhiever avatar Aug 21 '15 17:08 rhiever

From a Reddit comment:

Advice: I think you are missing a few big things like preprocessing/scaling and pipelines. Before using the learners, inputs should be scaled so that each feature has equal weight. Something like StandardScaler or MinMaxScaler are both appropriate (from sklearn.preprocessing). If you think some features are more important, you can scale them later to increase their relative importance in prediction. These are more parameters you would tune using CV, but these can be really numerous, so GridSearch is out the window and you would have to consider some alternatives like Nelder Mead search, genetic search, or multivariate gradient descent if you suspect convexity. You have to fit these scalers on the training data and then use the trained fit to transform the testing data. Using Pipelines simplifies this whole process (fits the scaler and learner at once, transforms and predicts at once).

Can you please tell which file you are referring to? To add the scaling.

Ritish-Madan avatar May 11 '20 06:05 Ritish-Madan

The example data science notebook: https://github.com/rhiever/Data-Analysis-and-Machine-Learning-Projects/blob/master/example-data-science-notebook/Example%20Machine%20Learning%20Notebook.ipynb

rhiever avatar May 11 '20 14:05 rhiever

Hi!I believe that Scaling the features won't really be beneficial in our features. The classification is based on the size of petals and various other continuous data features are available. Scaling them might ruin their actual existence and might ruin the classification.

Ritish-Madan avatar Jun 02 '20 14:06 Ritish-Madan