【问题标题】:Error while hyperparameter tuning using BayesSearchCV for CatBoostClassifier (Multiclass classification)使用 BayesSearchCV 对 CatBoostClassifier(多类分类)进行超参数调整时出错
【发布时间】:2022-01-15 09:38:17
【问题描述】:

我正在尝试使用 CatBoostClassifier 调整多类分类的超参数,但出现以下错误。

ValueError: multiclass format is not supported

我的目标变量包含 (0,1,2,3)

请检查我已实现的以下代码。

  accuracy = make_scorer(accuracy_score, greater_is_better=True, needs_threshold=True)
skf = StratifiedKFold(n_splits=5, shuffle=True, random_state=42)

clf = CatBoostClassifier(thread_count=2, loss_function='MultiClass', eval_metric='Accuracy', leaf_estimation_method='Newton',  od_type = 'Iter', verbose= False)

# Defining your search space
search_spaces = {'iterations': Integer(10, 2000),
                 'depth': Integer(1, 12),
                 'learning_rate': Real(0.01, 1.0, 'log-uniform'),
                 'random_strength': Real(1e-9, 10, 'log-uniform'),
                 'bagging_temperature': Real(0.0, 1.0),
                 'border_count': Integer(1, 255),
                 'l2_leaf_reg': Integer(2, 30)}

# Setting up BayesSearchCV
opt = BayesSearchCV(clf,
                    search_spaces,
                    scoring=accuracy,
                    cv=skf,
                    n_iter=100,
                    n_jobs=1, 
                    return_train_score=False,
                    refit=True,
                    optimizer_kwargs={'base_estimator': 'GP'},
                    random_state=42)
opt.fit(X_train, y_train)

如果需要有关我的问题的更多详细信息,请告诉我。 请帮我解决这个问题。谢谢!

【问题讨论】:

    标签: machine-learning hyperparameters multiclass-classification catboost bayessearchcv


    【解决方案1】:

    尝试将objective = 'multi:softmax' 添加到分类器并设置classes_count

    【讨论】:

    • 我试过了,但它不起作用谢谢。
    猜你喜欢
    • 2021-04-11
    • 2022-08-16
    • 2021-02-15
    • 2020-11-28
    • 2018-03-07
    • 2021-05-30
    • 2012-05-14
    • 1970-01-01
    • 2018-08-05
    相关资源
    最近更新 更多