ageron / ageron/handson-ml2

[Chapter 3] - p102 - Scaling and using SGD Classifier

Ouverte
#167 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Jupyter Notebook
Étoiles
30k
Forks
13.1k
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

Hi,

I am currently on p.102 Chapter 3 and I have just scaled the training data of the MNIST dataset using the StandardScalar(). After scaling the training data, it doesn't seem that the SGD model is refitted using this newly scaled data. Instead, the data is scaled and then y_train_pred (y train predictions) are made calling the SGD classifier (fitted to the X_train unscaled data) onto the X_train_scaled data. Is this the correct way to scale and use data in models? I ask as my 1st thought is that you would need to refit the model on the scaled data as it is very different to the original data. That way when you feed the scaled data to the model it will have been fitted on the scaled data and not the original data.

I have run a cross validation on both:

1. an SGD model using the scaled trained X data as input but fitted to the original data
2. an SGD model using the scaled trained X data as input AND fitted to the scaled data

1. 5 fold cross valid results = array([0.89733333, 0.88725 , 0.89583333, 0.89233333, 0.90516667])
2. 5 fold cross valid results = array([0.89733333, 0.88725 , 0.89583333, 0.89233333, 0.90516667])

As you can see when you fit the model to the scaled data and then use the scaled data it performs exactly the same as the case when you don't re fit the model / re train the model. Is this always the case / do you not need to re fit the model once you have rescaled?

Any help would be much appreciated.

Thanks,
Dan

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.