2017-06-20 12 views
2

バイナリ分類問題でxgboostクラシファイアをトレーニングします。 70%正確な予測が得られます。しかし、ログロスは9.13で非常に大きいです。なぜなら、いくつかの予測が目標をはるかに超えているからだと思うが、なぜそれが起こるのか分からない。他の人は、xgboostを使って同じデータに対してもっと良いlogloss(0.55-0.6)を報告する。xgboost:妥当な精度にもかかわらず、巨大なログロス

from readCsv import x_train, y_train 
from sklearn.model_selection import train_test_split 
from sklearn.metrics import accuracy_score, log_loss 
from xgboost import XGBClassifier 

seed=7 
test_size=0.09 

X_train, X_test, y_train, y_test = train_test_split(
    x_train, y_train, test_size=test_size, random_state=seed) 

# fit model no training data 
model = XGBClassifier(max_depth=5, 
         learning_rate=0.02, 
         objective= 'binary:logistic', 
         n_estimators = 5000) 
model.fit(X_train, y_train) 

# make predictions for test data 
y_pred = model.predict(X_test) 
predictions = [round(value) for value in y_pred] 

accuracy = accuracy_score(y_test, predictions) 
print("Accuracy: %.2f%%" % (accuracy * 100.0)) 

ll = log_loss(y_test, y_pred) 
print("Log_loss: %f" % ll) 
print(model) 

は、次の出力を生成します。

Accuracy: 73.54% 
Log_loss: 9.139162 
XGBClassifier(base_score=0.5, colsample_bylevel=1, colsample_bytree=1, 
     gamma=0, learning_rate=0.02, max_delta_step=0, max_depth=5, 
     min_child_weight=1, missing=None, n_estimators=5000, nthread=-1, 
     objective='binary:logistic', reg_alpha=0, reg_lambda=1, 
     scale_pos_weight=1, seed=0, silent=True, subsample=1) 

誰もが私の高いloglossの理由を知っていますか?ありがとう!

+0

丸め予測で精度を計算しますが、丸め予測なしでログ損失を計算することに注意してください。値を丸めずに精度をチェックしようとしましたか? – rafaelvalle

+0

@rafaelvalleちょうど丸めなしでテスト:正確に同じ数字を生成しました - 73.54% – ikamen

答えて

2

溶液:使用model.predict_proba()は、model.predictない()

予想範囲内である7+から0.52までこの減少logloss、。 model.predict()は1e18のような巨大な値を出力していましたが、有効な確率スコア(0と1の間)になるような関数を実行する必要があるようです。

関連する問題