0

I used Perceptron from sklearn.linear_model for the first time and I got this message

"DeprecationWarning: n_iter parameter is deprecated in 0.19 and will be removed in 0.21. Use max_iter and tol instead.

DeprecationWarning"

while using the following code.

from sklearn.linear_model import Perceptron
ppn=Perceptron(n_iter=40, eta0= 0.1, random_state=1)
ppn.fit(X_train_std, y_train)
y_pred = ppn.predict(X_test_std)

Could somebody tell me what is the issue here ? Thank you

  • 1
    What exactly do you not understand about the message? It warns you that you should not use a certain feature because when you update the library it will be removed. – mkrieger1 Feb 06 '18 at 12:36
  • i dont know who downvoted you but ill upvote you because by the moment i got the error it didnt have the warning, and thanks to this i know i have to use max iter and tol instead which now ill have to... ugh... research – Mr-Programs Dec 08 '19 at 20:52

2 Answers2

1

It's only a notification that in future versions this parameter (n_iter) will be removed by max_iter.

It's a good practice so replace it, so in future version your script will work fine.

1

Read up on the specification for sklearn.linear_model.Perceptron:

max_iter : int, optional

The maximum number of passes over the training data (aka epochs). It only impacts the behavior in the fit method, and not the partial_fit. Defaults to 5. Defaults to 1000 from 0.21, or if tol is not None.

New in version 0.19.

tol : float or None, optional

The stopping criterion. If it is not None, the iterations will stop when (loss > previous_loss - tol). Defaults to None. Defaults to 1e-3 from 0.21.

New in version 0.19.

n_iter : int, optional

The number of passes over the training data (aka epochs). Defaults to None. Deprecated, will be removed in 0.21.

Changed in version 0.19: Deprecated

jpp
  • 159,742
  • 34
  • 281
  • 339