doenut.models.model_set

Module Contents

Classes

ModelSet

Class to train and hold a group of related models.

class doenut.models.model_set.ModelSet(default_inputs=None, default_responses=None, default_scale_data=True, default_fit_intercept=True)[source]

Class to train and hold a group of related models. When constructing the ModelSet, you can define default values. Then when adding a new model to the set you only have to specify the parameters which differ from the default.

Note

This class mostly exists as a base - you probably want AveragedModelSet

Parameters:
  • default_inputs (pd.DataFrame, optional) – The default inputs to the model

  • default_responses (pd.DataFrame, optional) – The default responses for the model

  • default_scale_data (bool, optional) – Whether to scale the data before adding to the model by default

  • default_fit_intercept (bool, optional) – Whether to fit the model’s intercept to the axis by default

_validate_value(name: str, value: Any = None) Any[source]
add_model(inputs: pandas.DataFrame = None, responses: pandas.DataFrame = None, scale_data: bool = None, fit_intercept: bool = None)[source]

Builds and adds a model to the set For each parameter not specified, the defaults will be used instead.

Parameters:
  • inputs (pd.DataFrame, optional) – The inputs to the model

  • responses (pd.DataFrame, optional) – The responses for the model

  • scale_data (bool, optional) – Whether to scale the data before adding to the model

  • fit_intercept (bool, optional) – Whether to fit the model’s intercept to the axis

Returns:

The generated model

Return type:

doenut.models.Model

get_r2s()[source]

Get the Pearson R2 values for the models in the set

Returns:

The R2 value for each model in the set.

Return type:

List[float]

get_attributes(attribute: str) List[Any][source]

Get a specified attribute from each model. Frustratingly, some are in the model, others in the sklearn model.

Parameters:

attribute (str) – The attribute you want from the model

Returns:

A list of the value of that attribute for each model in the set.

Return type:

List[Any]

Raises:

ValueError – If the attribute is not present in either the model or the inner sklearn model.

Note

If the attribute exists in both the model and the sklearn model, the model attribute will be the one returned.