TypeError: Ridge.__init__() got an unexpected keyword argument 'normalize'

In “C1_W3_Lab08_Overfitting_Soln”

I have downloaded the workspace in the latest version. All the code in this lab runs normally except the one below. Can anyone help me? Do I need to revise the related code? I don’t know how to fix it.

When I run code locally

In the scikit implementation of the Ridge regression

class sklearn.linear_model.Ridge(alpha=1.0, ***, fit_intercept=True, copy_X=True, max_iter=None, tol=0.0001, solver=‘auto’, positive=False, random_state=None )[source]

there is no normalize parameter, perhaps this is the issue!

2 Likes

I have fixed it, thank you!

1 Like

Hello @nathanael,

Please follow these steps to resolve the issues:

  1. Update scikit-learn: Ensure you have the latest version by running the following command in the terminal:

conda update scikit-learn

  1. Modify plt_overfit.py:
  • At line 359, change:

lr = LogisticRegression(penalty=‘none’, max_iter=10000)

to:

lr = LogisticRegression(penalty=None, max_iter=10000) #Set penalty to None

  • At line 336, remove the normalize parameter:

linear_model = Ridge(alpha=self.lambda_, max_iter=10000) # Remove normalize=True

These changes should resolve the issues.

2 Likes

Thanks for your information.

Just to clarify for other students:

  • This should only be done if you’re going to run the lab notebook on your own platform.
  • No changes should be made to the notebook you use for grading within the course.
1 Like