वहाँ isotonic प्रतिगमन विधि के साथ मुद्दों (और में इसके कार्यान्वयन के एक जोड़े हैं sklearn) जो इसे अंशांकन के लिए एक उपमहाद्वीप पसंद बनाते हैं।
विशेष रूप से:
1) यह अंशांकन समारोह के लिए एक सुचारू रूप से अलग-अलग वक्र के बजाय एक piecewise निरंतर समारोह फिट बैठता है।
2) क्रॉस-वैलिडेशन मॉडल/कैलिब्रेशंस के परिणाम को प्रत्येक गुना से प्राप्त करता है। हालांकि, उनमें से प्रत्येक परिणाम अभी भी संबंधित फ़ोल्डरों पर फिट और कैलिब्रेटेड है।
अक्सर, बेहतर विकल्प SplineCalibratedClassifierCV
कक्षा ML-insights पैकेज में है (अस्वीकरण: मैं उस पैकेज का लेखक हूं)। पैकेज के लिए जिथब रेपो here है।
यह निम्न लाभ हैं:
1) यह बल्कि एक piecewise निरंतर समारोह की तुलना में एक घन चौरसाई पट्टी फिट बैठता है।
2) यह अंशांकन के लिए पूरे (क्रॉस-मान्य) उत्तर सेट का उपयोग करता है और पूर्ण डेटा सेट पर आधार मॉडल को रीफिट करता है। इस प्रकार, अंशांकन समारोह और आधार मॉडल दोनों को पूर्ण डेटा सेट पर प्रभावी ढंग से प्रशिक्षित किया जाता है।
आप here और here तुलना के उदाहरण देख सकते हैं।
पहले उदाहरण से, यहां एक ग्राफ है जो एक प्रशिक्षण सेट (लाल बिंदु), स्वतंत्र परीक्षण सेट (हरे + संकेत) की पिन की संभावनाओं को दिखाता है, और एमएल-अंतर्दृष्टि स्पलीन विधि (नीली रेखा) द्वारा गणना की गई अंशांकन) और आइसोटोनिक-स्लेलेन विधि (ग्रे डॉट्स/लाइन)।
मैं तरीकों की तुलना करने के लिए अपने कोड को संशोधित किया है (और उदाहरण की संख्या बढ़ी)। यह दर्शाता है कि स्पलीन दृष्टिकोण टाइपिकल बेहतर प्रदर्शन करता है (जैसा कि मैंने ऊपर से जुड़े उदाहरणों को किया है)।
import numpy as np from sklearn.datasets import make_classification from sklearn import ensemble from sklearn.calibration import CalibratedClassifierCV from sklearn.metrics import log_loss from sklearn import cross_validation import ml_insights as mli
X, y = make_classification(n_samples=10000, n_features=100, n_informative=30, n_redundant=0, n_repeated=0, n_classes=9, random_state=0, shuffle=False)
skf = cross_validation.StratifiedShuffleSplit(y, 5)
for train, test in skf:
:
संहिता (आप pip install ml_insights
पहले करना होगा):
यहाँ कोड और परिणाम है
X_train, X_test = X[train], X[test]
y_train, y_test = y[train], y[test]
clf = ensemble.GradientBoostingClassifier(n_estimators=100)
clf_cv_mli = mli.SplineCalibratedClassifierCV(clf, cv=3)
clf_cv_mli.fit(X_train, y_train)
probas_cv_mli = clf_cv_mli.predict_proba(X_test)
cv_score_mli = log_loss(y_test, probas_cv_mli)
clf = ensemble.GradientBoostingClassifier(n_estimators=100)
clf_cv = CalibratedClassifierCV(clf, cv=3, method='isotonic')
clf_cv.fit(X_train, y_train)
probas_cv = clf_cv.predict_proba(X_test)
cv_score = log_loss(y_test, probas_cv)
clf = ensemble.GradientBoostingClassifier(n_estimators=100)
clf.fit(X_train, y_train)
probas = clf.predict_proba(X_test)
clf_score = log_loss(y_test, probas)
clf = ensemble.GradientBoostingClassifier(n_estimators=100)
clf_cv_mli = mli.SplineCalibratedClassifierCV(clf, cv=10)
clf_cv_mli.fit(X_train, y_train)
probas_cv_mli = clf_cv_mli.predict_proba(X_test)
cv_score_mli_10 = log_loss(y_test, probas_cv_mli)
clf = ensemble.GradientBoostingClassifier(n_estimators=100)
clf_cv = CalibratedClassifierCV(clf, cv=10, method='isotonic')
clf_cv.fit(X_train, y_train)
probas_cv = clf_cv.predict_proba(X_test)
cv_score_10 = log_loss(y_test, probas_cv)
print('\nuncalibrated score: {}'.format(clf_score))
print('\ncalibrated score isotonic-sklearn (3-fold): {}'.format(cv_score))
print('calibrated score mli (3-fold): {}'.format(cv_score_mli))
print('\ncalibrated score isotonic-sklearn (10-fold): {}'.format(cv_score_10))
print('calibrated score mli (10-fold): {}\n'.format(cv_score_mli_10))`
परिणाम
uncalibrated score: 1.4475396740876696
calibrated score isotonic-sklearn (3-fold): 1.465140552847886 calibrated score mli (3-fold): 1.3651638065446683
calibrated score isotonic-sklearn (10-fold): 1.4158622673607426 calibrated score mli (10-fold): 1.3620771116522705
uncalibrated score: 1.5097320476479625
calibrated score isotonic-sklearn (3-fold): 1.5189534673089442 calibrated score mli (3-fold): 1.4386253950100405
calibrated score isotonic-sklearn (10-fold): 1.4976505139437257 calibrated score mli (10-fold): 1.4408912879989917
uncalibrated score: 1.4654527691892194
calibrated score isotonic-sklearn (3-fold): 1.493355643575107 calibrated score mli (3-fold): 1.388789694535648
calibrated score isotonic-sklearn (10-fold): 1.419760490609242 calibrated score mli (10-fold): 1.3830851694161692
uncalibrated score: 1.5163851866969407
calibrated score isotonic-sklearn (3-fold): 1.5532628847926322 calibrated score mli (3-fold): 1.459797287154743
calibrated score isotonic-sklearn (10-fold): 1.4748100659449732 calibrated score mli (10-fold): 1.4620173012979816
uncalibrated score: 1.4760935523959617
calibrated score isotonic-sklearn (3-fold): 1.469434735152088 calibrated score mli (3-fold): 1.402024502986732
calibrated score isotonic-sklearn (10-fold): 1.4702032019673137 calibrated score mli (10-fold): 1.3983943648572212
आप scikit सीखने मेलिंग सूची के साथ इस सवाल का साझा कर सकता है? ईमेल में, अपना पूरा प्रश्न दें लेकिन इस एसओ पोस्ट को एक लिंक प्रदान करें, ताकि प्रतिक्रिया प्रयास दोगुनी न हों। – eickenberg
मुझे नहीं पता कि आपका डेटा कैसा है, लेकिन यह डेटा सेट में भिन्नता के कारण हो सकता है। इसके अलावा, आपका logloss बहुत अधिक प्रतीत होता है। Sklearn logloss उपज का उपयोग कर यादृच्छिक डेटा पर परीक्षण 1. शायद आपके पास बहुत (वीरी) शोर डेटा है। –