• Create
    • Ask a question
    • Create an article
    • Topics
    • Questions
    • Articles
    • Users
    • Badges
  • Sign in
  • Home /
avatar image
0

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

spark sqlpythonazure databrickslinear regressionbayesian regression in sklearn
Question by mudassar45@gmail.com · Jul 30 at 01:07 AM ·

# 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?

Add comment · Show 1
Comment
10 |600 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image mudassar45@gmail.com · Jul 30 at 01:08 AM 0
Share

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?

2 Answers

Sort

  • Votes
  • Created
  • Oldest
avatar image
1

Answer by Daniel Holth · Aug 08 at 12:29 PM

Try replacing the failing line with the following:

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

Comment
Add comment · Share
10 |600 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Fantomas_nl · Aug 13 at 10:55 AM

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..

Comment
Add comment · Share
10 |600 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

45 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Spark.implicits in Python API 1 Answer

DROP TABLE IF EXISTS does not work 4 Answers

Write data Frame into Azure Data Lake Storage 2 Answers

How to work with spark-jobserver in azure databricks? 0 Answers

Why are Python custom UDFs (registerFunction) showing Arrays with java.lang.Object references? 1 Answer

  • Product
    • Databricks Cloud
    • FAQ
  • Spark
    • About Spark
    • Developer Resources
    • Community + Events
  • Services
    • Certification
    • Spark Support
    • Spark Training
  • Company
    • About Us
    • Team
    • News
    • Contact
  • Careers
  • Blog

Databricks Inc.
160 Spear Street, 13th Floor
San Francisco, CA 94105

info@databricks.com
1-866-330-0121

  • Twitter
  • LinkedIn
  • Facebook
  • Facebook

© Databricks 2015. All rights reserved. Apache Spark and the Apache Spark Logo are trademarks of the Apache Software Foundation.

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Explore
  • Topics
  • Questions
  • Articles
  • Users
  • Badges