ageron / ageron/handson-ml2

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

未關閉
#167 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Jupyter Notebook
星號
30k
分支
13.1k
PR 合併指標
30 天內沒有已合併 PR

描述

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

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。