C1_W3_Lab08_Overfitting_Soln overfit_example() not letting me change the degree and model

InvalidParameterError: The ‘penalty’ parameter of LogisticRegression must be a str among {‘l1’, ‘l2’, ‘elasticnet’} or None. Got ‘none’ instead.

im getting this error when im trying to see the overfitting solution by changing the degree and the model “C1_W3_Lab08_Overfitting_Soln”

Hello @nathanael,

The lab was designed to run on the Cousera environment that has the correct sklearn package version to run the code successfully. You were experiencing that error probably because you are running it in a different environment. 'none' was a valid option in older sklearn.

Please run the lab on Cousera, or you can change it yourself from 'none' to None to make it pass. The error message should have shown you where the problematic line was, and in which script file it is.

Cheers,
Raymond

2 Likes

okay thank you.

1 Like

No problem!

Cheers.

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.

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