cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to fix TypeError: __init__() got an unexpected keyword argument 'max_iter'?

MudassarA
New Contributor II

# Create the model using sklearn (don't worry about the parameters for now): model = SGDRegressor(loss='squared_loss', verbose=0, eta0=0.0003, max_iter=3000)

Train/fit the model to the train-part of the dataset:

odel.fit(X_train, y_train)

ERROR:

TypeError: init() got an unexpected keyword argument 'max_iter'

TypeError Traceback (most recent call last) <command-894361499296960> in <module>() 1 # Create the model using sklearn (don't worry about the parameters for now): ----> 2 model = SGDRegressor(loss='squared_loss', verbose=0, eta0=0.0003, max_iter=3000) 3 4 # Train/fit the model to the train-part of the dataset: 5 model.fit(X_train, y_train)

TypeError: init() got an unexpected keyword argument 'max_iter'

I m running the linear regression code in Community edition.

Google says reinstall --

pip install scikit-learn==0.18 --force-reinstall

How to re-install in notebook?

1 ACCEPTED SOLUTION

Accepted Solutions

DanielHolth
New Contributor III

Try replacing the failing line with the following:

model = SGDRegressor(loss='squared_loss', verbose=0, eta0=0.0003, n_iter=3000)

View solution in original post

4 REPLIES 4

MudassarA
New Contributor II

I m running the linear regression code in Community edition.

Google says reinstall --

pip install scikit-learn==0.18 --force-reinstall

How to re-install in notebook?

DanielHolth
New Contributor III

Try replacing the failing line with the following:

model = SGDRegressor(loss='squared_loss', verbose=0, eta0=0.0003, n_iter=3000)

Fantomas_nl
New Contributor II

Replacing max_iter with n_iter resolves the error. Thnx!

It is a bit unusual to expect errors like this with this type of solution from Microsoft. As if it could not be prevented..

kiradgs
New Contributor II

Thank you for your share.It is nice. Ancestormoneyshop

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group