gpt4 book ai didi

python - 猫升压 : Cannot calc metric which requires logits for absolute values

转载 作者:行者123 更新时间:2023-12-01 07:26:17 26 4
gpt4 key购买 nike

我在我的模型中使用 catboost,并且在以下代码中收到如下错误:

from catboost import Pool, CatBoostClassifier, cv

#Split data
train = data[:split]
test = data[split:]

# Get variables for a model
x = train.drop(["Survived"], axis=1)
y = train["Survived"]

#Do train data splitting
X_train, X_test, y_train, y_test = train_test_split(x,y, test_size=0.2, random_state=42)

cat_features = np.where(x.dtypes != float)[0]

cat = CatBoostClassifier(one_hot_max_size=7, iterations=21, random_seed=42, use_best_model=True, eval_metric='Accuracy')

cat.fit(X_train, y_train, cat_features = cat_features, eval_set=(X_test, y_test))
pred = cat.predict(X_test)

pool = Pool(X_train, y_train, cat_features=cat_features)
cv_scores = cv(pool, cat.get_params(), fold_count=10, plot=True)
print('CV score: {:.5f}'.format(cv_scores['test-Accuracy-mean'].values[-1]))
print('The test accuracy is :{:.6f}'.format(accuracy_score(y_test, cat.predict(X_test))))

...这会引发:

---> 23 cv_scores = cv(pool, cat.get_params(), fold_count=10)

CatBoostError: catboost/libs/metrics/metric.cpp:5069: Cannot calc metric which requires logits for absolute values.

如果有帮助,我们将不胜感激。谢谢。

最佳答案

您需要在CatBoostClassifier()内添加参数loss_function='Logloss'。此问题描述here据说已经修复了,但现在又出现了。我将重新讨论这个问题,因为这显然是一个错误。

关于python - 猫升压 : Cannot calc metric which requires logits for absolute values,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57433605/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com