Reputation: 1207
I am using a OneVsRestClassifier
on MLPClassifier
. I am using this for classifying text data where X
is set of questions in pd.DataFrame
and Y
is multi-label and multi-class strings. Please see below the code snippets
text_clf = Pipeline([('scale',StandardScaler(with_mean=False)),('clf',OneVsRestClassifier(MLPClassifier(learning_rate = 'adaptive', solver = 'lbfgs',random_state=9000)))])
parameters = {'clf__alpha':[10.0 ** ~ np.arange(1, 7).any()],'clf__hidden_layer_sizes': [(100,),(50,)],'clf__max_iter': [1000,500],'clf__activation':('relu','tanh')}
grid = GridSearchCV(text_clf, parameters, cv=3, n_jobs=-1, scoring= 'accuracy')
with parallel_backend('threading'):
grid.fit(X,Y)
I am getting the following error
ValueError: Invalid parameter activation for estimator OneVsRestClassifier(estimator=MLPClassifier(activation='relu', alpha=0.0001, batch_size='auto', beta_1=0.9,
beta_2=0.999, early_stopping=False, epsilon=1e-08,
hidden_layer_sizes=(100,), learning_rate='adaptive',
learning_rate_init=0.001, max_iter=200, momentum=0.9,
n_iter_no_change=10, nesterovs_momentum=True, power_t=0.5,
random_state=9000, shuffle=True, solver='lbfgs', tol=0.0001,
validation_fraction=0.1, verbose=False, warm_start=False),
n_jobs=None). Check the list of available parameters with `estimator.get_params().keys()`.
As per my understanding MLPClassifier
supports Multi Label classification. Is it indicating that parameters
need to be re-examined? If so, then can any body please give any clue on where to make changes in parameters
?
Any help would really be appreciated.
Upvotes: 4
Views: 1297
Reputation: 29742
Your MLPClassifier
is nested into OneVsRestClassifier
as its estimator.
In other words, parameters
should specify that all of alpha
, hidden_layer_sizes
, ... are meant for nested estimator not OneVsRestClassifier
.
Changing your parameters
like following should do the job:
parameters = {'clf__estimator__alpha':[10.0 ** ~ np.arange(1,7).any()],
'clf__estimator__hidden_layer_sizes': [(100,),(50,)],
'clf__estimator__max_iter': [1000,500],
'clf__estimator__activation':('relu','tanh')}
Upvotes: 3