Skip to content

get_probs

Gets the predicted probabilities from the model.

Parameters:

Name Type Description Default
model Any

The trained model.

required
classification str

The type of classification.

required
X DataFrame

Predict features.

required

Returns:

Type Description
ndarray

array-like: Predicted probabilities.

Source code in periomod/training/_metrics.py
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
def get_probs(model: Any, classification: str, X: pd.DataFrame) -> np.ndarray:
    """Gets the predicted probabilities from the model.

    Args:
        model (Any): The trained model.
        classification (str): The type of classification.
        X (pd.DataFrame): Predict features.

    Returns:
        array-like: Predicted probabilities.
    """
    if classification == "binary":
        return model.predict_proba(X)[:, 1]
    else:
        return model.predict_proba(X)