【问题标题】:Very strange accuracy change?很奇怪的精度变化?
【发布时间】:2022-01-02 10:19:32
【问题描述】:

下面是我的 catboost 模型:

from sklearn.metrics import r2_score
cb_model = CatBoostRegressor(iterations=500,
                             learning_rate=0.05,
                             depth=10,
                             random_seed = 42,
                             bagging_temperature = 0.2,
                             od_type='Iter',
                             metric_period = 50,
                             od_wait=20)
cb_model.fit(X, y)
r2_score(cb_model.predict(X), y)

输出为:0.9999993582437351

当我尝试打印混淆矩阵时:

classificationSummary(y, clf.predict(X))

输出始终如下:



Confusion Matrix (Accuracy 0.9700)

       Prediction
Actual  0  1
     0 50  1
     1  2 47

为什么准确率会下降?

【问题讨论】:

  • 我不确定,但它可能是两个不同的accuracy,你无法比较它们。
  • 我投票结束这个问题,因为它不是问题,它来自对潜在问题和方法的根本误解。

标签: python scikit-learn confusion-matrix catboost


【解决方案1】:

您使用了错误的指标。 r2_score 计算 r 平方或coefficient of determination,这用于回归而不是计算准确度。

你应该使用accuracy score

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-03-26
    • 2020-07-02
    • 2018-07-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多