Created
June 14, 2020 17:24
-
-
Save rocreguant/cccaabc1be933e0885675e34555f5272 to your computer and use it in GitHub Desktop.
Deep learning model calibration using Platt scaling approach via sklearn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.linear_model import LogisticRegression as LR | |
y_train = train_results[class_labels].values | |
pred_train = train_results[pred_labels].values | |
pred_calibrated = np.zeros_like(pred) | |
for i in range(len(class_labels)): | |
lr = LR(solver='liblinear', max_iter=10000) | |
lr.fit(pred_train[:, i].reshape(-1, 1), y_train[:, i]) | |
pred_calibrated[:, i] = lr.predict_proba(pred[:, i].reshape(-1, 1))[:,1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment