0

今天,我尝试测试 Yandex 最近发布的一个惊人的 Catboost 库,但即使在玩具数据集上,它也显示出非常糟糕的结果。我试图找到问题的根源,但由于缺乏有关图书馆的适当文档和主题,我无法弄清楚发生了什么。请帮助我 =) 我正在使用 Anaconda 3 x64 和 Python 3.6。

from sklearn.datasets import make_classification
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.metrics import roc_auc_score, roc_curve, f1_score, make_scorer
from catboost import CatBoostClassifier

X,y = make_classification( n_classes=2
                              ,n_clusters_per_class=2
                              ,n_features=10
                              ,n_informative=4
                              ,n_repeated=2
                              ,shuffle=True
                              ,random_state=564
                              ,n_samples=10000
                                 )

X_train,X_test,y_train,y_test = train_test_split(X,y,train_size = 0.8)

cb = CatBoostClassifier(depth=3,custom_loss=
                            ['Accuracy','AUC'],
                            logging_level='Silent',
                            iterations=500,
                            od_type='Iter',
                            od_wait=20)
cb.fit(X_train,y_train,eval_set=(X_test,y_test),plot=True,use_best_model=True)
pred = cb.predict_proba(X_test)[:,1]
tpr,fpr,_=roc_curve(y_score=pred,y_true=y_test)
    #just to show the difference
from sklearn.ensemble import GradientBoostingClassifier
gbc = GradientBoostingClassifier().fit(X_train,y_train)
pred_gbc = gbc.predict_proba(X_test)[:,1]
tpr_xgb,fpr_xgb,_=roc_curve(y_score=pred_gbc,y_true=y_test)
plt.plot(tpr,fpr,color='orange')
plt.plot(tpr_xgb,fpr_xgb,color='red')
plt.show()
4

1 回答 1

0

这是一个错误。请小心并确保您使用的是最新版本。该错误已在 0.6.1 版本中修复。

于 2018-02-05T16:03:52.913 回答