TabularPredictor.predict_from_proba¶
- TabularPredictor.predict_from_proba(y_pred_proba: pd.DataFrame | np.ndarray, decision_threshold: float | None = None) pd.Series | np.array [source]¶
Given prediction probabilities, convert to predictions.
- Parameters:
y_pred_proba (
pd.DataFrame
ornp.ndarray
) – The prediction probabilities to convert to predictions. Obtainable via the output of predictor.predict_proba.decision_threshold (float, default = None) – The decision threshold used to convert prediction probabilities to predictions. Only relevant for binary classification, otherwise ignored. If None, defaults to predictor.decision_threshold. Valid values are in the range [0.0, 1.0] You can obtain an optimized decision_threshold by first calling predictor.calibrate_decision_threshold(). Useful to set for metrics such as balanced_accuracy and f1 as 0.5 is often not an optimal threshold. Predictions are calculated via the following logic on the positive class: 1 if pred > decision_threshold else 0
- Return type:
Array of predictions, one corresponding to each row in given dataset. Either
np.ndarray
orpd.Series
depending on y_pred_proba dtype.
Examples
>>> from autogluon.tabular import TabularPredictor >>> predictor = TabularPredictor(label='class').fit('train.csv', label='class') >>> y_pred_proba = predictor.predict_proba('test.csv') >>> >>> # y_pred and y_pred_from_proba are identical >>> y_pred = predictor.predict('test.csv') >>> y_pred_from_proba = predictor.predict_from_proba(y_pred_proba=y_pred_proba)