mds_2025_helper_functions.scores
Functions
|
Creates a table comparing mean cross-validation scores of multiple models. |
Module Contents
- mds_2025_helper_functions.scores.compare_model_scores(*args, X, y=None, scoring=None, return_train_scores=False, **kwargs)[source]
Creates a table comparing mean cross-validation scores of multiple models.
- Parameters:
*args (sklearn.base.BaseEstimator) – Model objects implementing the fit method. At least two models are required.
X (array-like of shape (n_samples, n_features)) – Training data.
y (array-like of shape (n_samples,) or (n_samples, n_outputs), optional) – Target values for supervised learning tasks.
scoring (str, callable, list, tuple, or dict, optional) – Metrics to evaluate models. Refer to scikit-learn scoring documentation: https://scikit-learn.org/stable/modules/model_evaluation.html#scoring-parameter.
return_train_scores (bool, default=False) – Whether to include training scores in addition to test scores.
**kwargs (dict) – Additional arguments passed to sklearn.model_selection.cross_validate.
- Returns:
A DataFrame comparing model performance: - Rows represent different models. - Columns include metrics from cross-validation. - Index contains model names.
- Return type:
pd.DataFrame
Examples
>>> from sklearn.linear_model import LogisticRegression >>> from sklearn.ensemble import RandomForestClassifier >>> compare_model_scores(LogisticRegression(), RandomForestClassifier(), X=X_train, y=y_train, scoring="accuracy")