ourtils.modeling#
All things modeling
- class ourtils.modeling.RegResultCollection(reg_results: list[RegressionResult])#
Bases:
objectRepresents a collection of regression models.
- batch_plot_regs(x_var: str, n=10)#
- classmethod build_from_mapper(input_data: DataFrame, model_mapper: list[tuple])#
Creates a RegResultCollection from a dictionary
model_mapper: A dictionary of: ```python import pandas as pd {
(key, formula): model description
}#
input_data: The input dataframe to fit the model on
- coef_dataframe(*args, **kwargs) DataFrame#
Returns model summaries as a dataframe
- property model_summary#
- plot_coefs(show_nums=True, scale_by=None, *args, **kwargs)#
Plots the coefficients of each model as a bar chart with error bars.
- property rowlevel_data: DataFrame#
- class ourtils.modeling.RegressionResult(key: str, formula: str, description: str, data: DataFrame)#
Bases:
objectRepresents a single model
- property diagnostic_df: DataFrame#
- property fitted_model: RegressionResultsWrapper#
- get_n_most_influential_points(n=5)#
- get_param_df(standardize=True) DataFrame#
- idx_most_influential(n)#
- property info_df: DataFrame#
- property model_descr#
- plot_coefs(*args, **kwargs)#
- plot_leverage_vs_resids()#
- plot_n_influential(x_val: str, n: int, title=None, ax=None) None#
Plots the n most influential points.
- plot_partial_regression()#
- plot_qq()#
- plot_scatter(x_val: str, y_val=None, highlight_influence=False, **kwargs)#
- property regression_influences#
- property standardized_fitted_model#
Standardizes data before fitting.
- property summary#
- tag_dataframe(_df) DataFrame#
- property y_variable: str#
- class ourtils.modeling.Sklearner(X, y, preprocessing_pipeline, models: list)#
Bases:
object- create_cv_results(*args, **kwargs) DataFrame#
- ourtils.modeling.standardize(numbers: Series) Series#
Safely standardizes a series.