Skip to content

Instantly share code, notes, and snippets.

@tomonori-masui
Created February 2, 2022 06:32
Show Gist options
  • Save tomonori-masui/c93338f51da153f71bf5d1a1ad1843ba to your computer and use it in GitHub Desktop.
Save tomonori-masui/c93338f51da153f71bf5d1a1ad1843ba to your computer and use it in GitHub Desktop.
Comparing custom GBM's log-loss to sklearn's
from sklearn.ensemble import GradientBoostingClassifier
from sklearn.metrics import log_loss
custom_gbm = CustomGradientBoostingClassifier(
n_estimators=20,
learning_rate=0.1,
max_depth=1
)
custom_gbm.fit(x, y)
custom_gbm_log_loss = log_loss(y, custom_gbm.predict_proba(x))
print(f"Custom GBM Log-Loss:{custom_gbm_log_loss:.15f}")
sklearn_gbm = GradientBoostingClassifier(
n_estimators=20,
learning_rate=0.1,
max_depth=1
)
sklearn_gbm.fit(x, y)
sklearn_gbm_log_loss = log_loss(y, sklearn_gbm.predict_proba(x))
print(f"Scikit-learn GBM Log-Loss:{sklearn_gbm_log_loss:.15f}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment