autopredictor.select_model

Module Contents

Functions

select_model(df_output, model_name)

Selects and returns the scores of a specified model from a DataFrame of model scores.

autopredictor.select_model.select_model(df_output, model_name)[source]

Selects and returns the scores of a specified model from a DataFrame of model scores.

This function searches the index of a DataFrame, typically generated by the show_all() function, for a model matching the name being provided. If found, it returns the corresponding row of scores. Otherwise, it issues a “Model Not Found” message and a list of available models.

Parameters:
  • df_output (DataFrame) – A DataFrame containing scores of various models, usually outputted by show_all().

  • model_name (str) – The name of the model to search for in the DataFrame.

Returns:

The row from the DataFrame corresponding to the specified model. Otherwise, returns a “Model Not Found” message.

Return type:

Series or str

Raises:
  • TypeError – If df_output is not a pandas DataFrame or model_name is not a string.

  • ValueError – If df_output DataFrame is empty.

Examples

>>> from autopredictor.select_model import select_model
>>> df_scores = pd.DataFrame({'MAE': [2.5, 3.6],
                              'MSE': [10.1, 20.3]},
                             index=['Linear Regression', 'Random Forest'])
>>> select_model(df_scores, 'Linear Regression')
                   MAE   MSE
Linear Regression  2.5  10.1
>>> select_model(df_scores, 'Support Vector Machine')
"Model 'Support Vector Machine' not found. Here is the list of the models available: Linear Regression, Random Forest."