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 摘要。