get_scores#

mlquantify.utils.method.get_scores(X, y, learner, folds: int = 10, learner_fitted: bool = False) tuple[source]#

Generate true labels and predicted probabilities using a machine learning model.

This function evaluates a machine learning model using cross-validation or directly with a pre-fitted model, returning the true labels and predicted probabilities.

Parameters:
XUnion[np.ndarray, pd.DataFrame]

Input features for the model.

yUnion[np.ndarray, pd.Series]

Target labels corresponding to the input features.

learnerobject

A machine learning model that implements the fit and predict_proba methods.

foldsint, optional

Number of folds for stratified cross-validation. Defaults to 10.

learner_fittedbool, optional

If True, assumes the learner is already fitted and directly predicts probabilities without performing cross-validation. Defaults to False.

Returns:
tuple
  • An array of true labels.

  • An array of predicted probabilities.

Notes

  • When learner_fitted is True, the model is assumed to be pre-trained and no cross-validation is performed.

  • When learner_fitted is False, stratified k-fold cross-validation is used to generate predictions.

  • The input data X and y are converted to pandas objects for compatibility.