flexcv.models
This module implements wrapper classes for the Linear Model and the Linear Mixed Effects Model from statsmodels.
flexcv.models.BaseLinearModel
Bases: BaseEstimator
, RegressorMixin
Base class for the Linear Model and the Linear Mixed Effects Model.
Source code in flexcv/models.py
flexcv.models.BaseLinearModel.get_params(deep=True)
Return the parameters of the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deep |
This argument is not used. (Default value = True) |
True
|
Returns:
Type | Description |
---|---|
dict
|
Parameter names mapped to their values. |
flexcv.models.BaseLinearModel.get_summary()
Creates a html summary table of the model.
Returns:
Type | Description |
---|---|
str
|
HTML table of the model summary. |
Source code in flexcv/models.py
flexcv.models.LinearMixedEffectsModel
Bases: BaseLinearModel
Wrapper class for the Linear Mixed Effects Model from statsmodels.
Source code in flexcv/models.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
|
flexcv.models.LinearMixedEffectsModel.fit(X, y, clusters, formula, re_formula, **kwargs)
Fit the LMER model to the given training data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
The training input samples. |
required |
y |
Series
|
The target values. |
required |
clusters |
Series
|
The clustering data. |
required |
re_formula |
str
|
The random effects formula for the random slopes and intercepts. |
required |
**kwargs |
dict
|
Additional parameters to pass to the underlying model's |
{}
|
Returns:
Type | Description |
---|---|
object
|
Returns self. |
Notes
This method fits a LMER class on the X data.
Source code in flexcv/models.py
flexcv.models.LinearMixedEffectsModel.predict(X, clusters, **kwargs)
Make predictions using the fitted model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
Features |
required |
clusters |
Series
|
The clustering data. |
required |
**kwargs |
Any other keyword arguments to pass to the underlying model's |
{}
|
Returns:
Type | Description |
---|---|
array - like
|
An array of fitted values. |
Source code in flexcv/models.py
flexcv.models.LinearModel
Bases: BaseLinearModel
Wrapper class for the Linear Model from statsmodels.
Source code in flexcv/models.py
flexcv.models.LinearModel.fit(X, y, formula, **kwargs)
Fit the LM to the given training data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
array-like of shape (n_samples, n_features
|
The training input samples. |
required |
y |
array-like of shape (n_samples,
|
The target values. |
required |
**kwargs(dict) |
Additional parameters to pass to the underlying model's |
required |
Returns:
Type | Description |
---|---|
object
|
Returns the model after fit. |
Notes
This method fits a OLS class on the X data.
Source code in flexcv/models.py
flexcv.models.LinearModel.predict(X, **kwargs)
Make predictions using the fitted model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
array - like
|
Features |
required |
**kwargs |
Used to prevent raising an error when passing the |
{}
|
Returns:
Type | Description |
---|---|
array - like
|
An array of fitted values. |