SVMs and boosted trees output scores, not probabilities. Platt scaling fits a 1-D logistic regression on held-out scores: .
Implement:
fit_platt(scores, labels, iters=50): find a and b by Newton's method on the log loss, starting from a = 0 and b = log((pos + 1) / (neg + 1)). Return (a, b).platt_predict(a, b, scores)log_loss(probs, labels, eps=1e-12): the mean binary cross-entropy, clipping probabilities to [eps, 1 - eps]