I am doing the following:
from sklearn.model_selection import GridSearchCV, RandomizedSearchCV, cross_val_score, train_test_split
import lightgbm as lgb
param_test ={
'learning_rate' : [0.01, 0.02, 0.03, 0.04, 0.05, 0.08, 0.1, 0.2, 0.3, 0.4]
}
clf = lgb.LGBMClassifier(boosting_type='gbdt',\
num_leaves=31, \
max_depth=-1, \
n_estimators=100, \
subsample_for_bin=200000, \
objective='multiclass', \
class_weight=balanced, \
min_split_gain=0.0, \
min_child_weight=0.001, \
min_child_samples=20, \
subsample=1.0, \
subsample_freq=0, \
colsample_bytree=1.0, \
reg_alpha=0.0, \
reg_lambda=0.0, \
random_state=None,\
n_jobs=-1,\
silent=True, \
importance_type='split'
)
gs = GridSearchCV(
estimator=clf,
param_grid = param_test,
scoring='roc_auc',
cv=3
)
gs.fit(X_train, y_train_lbl["target_encoded"].values)
and I am getting the below error:
/home/cdsw/.local/lib/python3.6/site-packages/sklearn/model_selection/_validation.py in _score(estimator, X_test, y_test, scorer, is_multimetric)
597 """
598 if is_multimetric:
--> 599 return _multimetric_score(estimator, X_test, y_test, scorer)
600 else:
601 if y_test is None:
/home/cdsw/.local/lib/python3.6/site-packages/sklearn/model_selection/_validation.py in _multimetric_score(estimator, X_test, y_test, scorers)
627 score = scorer(estimator, X_test)
628 else:
--> 629 score = scorer(estimator, X_test, y_test)
630
631 if hasattr(score, 'item'):
/home/cdsw/.local/lib/python3.6/site-packages/sklearn/metrics/scorer.py in __call__(self, clf, X, y, sample_weight)
173 y_type = type_of_target(y)
174 if y_type not in ("binary", "multilabel-indicator"):
--> 175 raise ValueError("{0} format is not supported".format(y_type))
176
177 if is_regressor(clf):
**ValueError: multiclass format is not supported**
So, the value error for the multiclass not being supported is what has stumped me. Am I missing some fundamentals here? I used auc as a metric. Should this be multi_logloss
? I tried that as well no result.
**ValueError: multiclass format is not supported**
suggests that the target variable is in a format which can't be fed to the model. $\endgroup$ – 89f3a1c Nov 6 '19 at 15:40