yusuf
yusuf

Reputation: 3781

TypeError: MLPClassifier() got an unexpected keyword argument 'algorithm'

I have just installed scikit-learn v0.18 dev package.

when I call the following on iPython;

>>> from sklearn.neural_network import MLPClassifier
>>> clf = MLPClassifier(algorithm='l-bfgs', alpha=1e-5, hidden_layer_sizes=(5, 2), random_state=1)

there is no error. But when I write a python script file and run the code on it, I get the following error:

clf = MLPClassifier(algorithm='l-bfgs', alpha=1e-5, hidden_layer_sizes=(5, 2), random_state=1, warm_start=True)
TypeError: MLPClassifier() got an unexpected keyword argument 'algorithm'

I don't know where is the problem. How can I fix this bug?

Upvotes: 5

Views: 3541

Answers (2)

Sadekujjaman
Sadekujjaman

Reputation: 687

from sklearn.neural_network import MLPClassifier

clf = MLPClassifier(solver='l-bfgs', alpha=1e-5, hidden_layer_sizes=(5, 2), random_state=1, warm_start=True)

Just replace algorithm by solver

But when you fit data in one line:

X,y = make_moons(n_samples=100, noise=0.25, random_state=3)
X_trian, X_test, y_train, y_test = train_test_split(X,y, stratify=y, random_state=42)
mlpc = MLPClassifier(solver='lbfgs', random_state=0).fit(X_train, y_train)

replace l-bfgs by lbfgs

Upvotes: 2

leon yin
leon yin

Reputation: 849

You're gonna want to change the algorithm param to solver. See the documentation for that estimator and the repo for dev.

Upvotes: 4

Related Questions