cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
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

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.