Issue
I'm using sklearn library. I have a question about the attribute: n_iter_
. When executing the code I get TypeError: __init__() got an unexpected keyword argument 'n_iter_'
. Also try using n_iter
but I get the same error, or maybe I am misspelling the attribute. It is not all the code, if you need more information, let me know
from sklearn.linear_model import Perceptron
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
ppn= Perceptron(n_iter_=40, eta0= 0.1, random_state=1)
ppn.fit(X_train_std, y_train)
Solution
Perceptron
Model in sklearn.linear_model
doesn't have n_iter_
as a parameter. It has following parameters with similar names.
max_iter: int, default=1000
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 method.
and
n_iter_no_change : int, default=5
Number of iterations with no improvement to wait before early stopping.
New in version 0.20.
By looking at your code it looks like you intended to use max_iter
.
So do
ppn=Perceptron(max_iter=40, eta0= 0.1, random_state=1)
ppn.fit(X_train_std, y_train)
Note:
You should first upgrade
your sklearn
using
pip install sklearn -upgrade
Answered By - user13486325
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.