我在二进制分类问题上训练了一个 xgboost 分类器。它产生 70% 的准确预测。然而,logloss 在 9.13 时非常大。我怀疑这可能是因为一些预测非常偏离目标,但我不明白为什么会发生 - 其他人使用 xgboost 在相同数据上报告的 logloss (0.55 - 0.6) 要好得多。
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的原因吗?谢谢!