Reputation: 138
I want to initialize weights in a MLPclassifier, but when i use sample_weight in .fit()
method,
it says that TypeError: fit() got an unexpected keyword argument 'sample_weight'
import sklearn.neural_network as SKNN
mlp_classifier = SKNN.MLPClassifier((10,), learning_rate="invscaling",solver="lbfgs")
fit_model = mlp_classifier.fit(train_data,train_target, sample_weight = weight)
i also read What does `sample_weight` do to the way a `DecisionTreeClassifier` works in sklearn?, it said that you should use sample_weight in the .fit()
method.
is there any way to use sample_weight
for MLPclassifier
like the one used in Decisiontreeclassifier
?
Upvotes: 3
Views: 3586
Reputation: 1009
There are no sample weights in sklearn NN yet. But you can as the start:
Upvotes: 0
Reputation: 531
That is because MLPClassifier
unlike DecisionTreeClassifier
doesn't have a fit()
method with a sample_weight
parameter.
See the documentation.
Maybe some of the answers to this similar question can help: How to set initial weights in MLPClassifier?
Upvotes: 1
Reputation: 176
according to sklearn.neural_network.MLPClassifier.fit the fit
method does not have an argument named sample_weight
Upvotes: 0