# Scikit Regression comparison of train vs normalized X

**URL:** <https://community.deeplearning.ai/t/scikit-regression-comparison-of-train-vs-normalized-x/373960>\
**Category:** Supervised ML: Regression and Classification\
**Tags:** week-module-2\
**Created:** [July 4, 2023, 9:27pm UTC](https://community.deeplearning.ai/t/scikit-regression-comparison-of-train-vs-normalized-x/373960 "2023-07-04T21:27:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Venkat\_Subramani](https://avatars.discourse-cdn.com/v4/letter/v/5fc32e/32.png) [@Venkat\_Subramani](https://community.deeplearning.ai/u/Venkat_Subramani)\
**Post date:** [July 4, 2023, 9:27pm UTC](https://community.deeplearning.ai/t/scikit-regression-comparison-of-train-vs-normalized-x/373960/1 "2023-07-04T21:27:37Z")

</div>

Hi  
Why do we see difference in output of sgdr class and more iterations with X\_Norm as compared to X\_train?

Code from Lab:  
sgdr = SGDRegressor()  
sgdr.fit(X\_train, Y\_train )  
print ( sgdr)  
print(f"number of iterations completed: {sgdr.n\_iter\_}, number of weight updates: {sgdr.t\_}")

SGDRegressor(alpha=0.0001, average=False, early\_stopping=False, epsilon=0.1,  
eta0=0.01, fit\_intercept=True, l1\_ratio=0.15,  
learning\_rate=‘invscaling’, loss=‘squared\_loss’, max\_iter=1000,  
n\_iter\_no\_change=5, penalty=‘l2’, power\_t=0.25, random\_state=None,  
shuffle=True, tol=0.001, validation\_fraction=0.1, verbose=0,  
warm\_start=False)  
number of iterations completed: 146, number of weight updates: 14455.0

===========

Code modified to pass X\_train instead of X\_norm to sgdr:

sgdr = SGDRegressor()  
sgdr.fit(X\_train, Y\_train )  
print(f"number of iterations completed: {sgdr.n\_iter\_}, number of weight updates: {sgdr.t\_}")  
print ( sgdr)

number of iterations completed: 42, number of weight updates: 4159  
SGDRegressor()

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [July 4, 2023, 10:32pm UTC](https://community.deeplearning.ai/t/scikit-regression-comparison-of-train-vs-normalized-x/373960/2 "2023-07-04T22:32:40Z")

</div>

You can get a better fit by using normalized features. You can also use a larger learning rate, so direct comparisons can be difficult.

Do you have some metrics for the performance of both models?

---

<div class="post-metadata">

**Author:** ![Venkat\_Subramani](https://avatars.discourse-cdn.com/v4/letter/v/5fc32e/32.png) [@Venkat\_Subramani](https://community.deeplearning.ai/u/Venkat_Subramani)\
**Post date:** [July 5, 2023, 11:03pm UTC](https://community.deeplearning.ai/t/scikit-regression-comparison-of-train-vs-normalized-x/373960/3 "2023-07-05T23:03:54Z")

</div>

Yes, you could try passing X\_train to the sgdr.fir ( Line 7 ) of the pbook below…

sgdr = SGDRegressor()  
sgdr.fit(X\_Norm, Y\_train )  
print(f"number of iterations completed: {sgdr.n\_iter\_}, number of weight updates: {sgdr.t\_}")  
print ( sgdr)

[Optional lab: Linear regression with scikit-learn | Coursera](https://www.coursera.org/learn/machine-learning/ungradedLab/uaIsm/optional-lab-linear-regression-with-scikit-learn/lab?path=%2Fnotebooks%2FC1_W2_Lab05_Sklearn_GD_Soln.ipynb)
