Skip to main content

ml_dl.tune_threshold

ml_dl.tune_threshold(model, X, y)

Sweep predict_proba thresholds; return the F1-optimal one.

Works with any sklearn-compatible classifier (LR / RF / XGBClassifier) that exposes predict_proba. Returns 0.5 when the input has only a single class so the caller can fall back without branching.