-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
5,547 additions
and
57 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
"""Multi-variable linear regression (MVLR) module.""" | ||
|
||
from .mvlr import MultiVariableLinearRegression, find_best_mvlr, ValidationParameters | ||
from .models import IndependentVariable, MultiVariableRegressionResult | ||
from .main import find_best_mvlr | ||
from .models import ( | ||
IndependentVariableInput, | ||
MultiVariableRegressionInput, | ||
MultiVariableRegressionResult, | ||
ValidationParameters, | ||
IndependentVariableResult, | ||
) | ||
|
||
__all__ = [ | ||
"MultiVariableLinearRegression", | ||
"MultiVariableRegressionResult", | ||
"IndependentVariable", | ||
"find_best_mvlr", | ||
"IndependentVariableInput", | ||
"MultiVariableRegressionInput", | ||
"MultiVariableRegressionResult", | ||
"ValidationParameters", | ||
"IndependentVariableResult", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""Main module for the MultiVariableLinearRegression class.""" | ||
|
||
from .models import MultiVariableRegressionInput, MultiVariableRegressionResult | ||
from .helpers import resample_input_data | ||
from .mvlr import MultiVariableLinearRegression | ||
|
||
|
||
def find_best_mvlr( | ||
data: MultiVariableRegressionInput, | ||
) -> MultiVariableRegressionResult: | ||
"""Cycle through multiple granularities and return the best model.""" | ||
for granularity in data.granularities: | ||
frame = data.data_frame() | ||
frame = resample_input_data(data=frame, granularity=granularity) | ||
mvlr = MultiVariableLinearRegression( | ||
data=frame, | ||
y=data.dependent_variable, | ||
granularity=granularity, | ||
allow_negative_predictions=data.allow_negative_predictions, | ||
) | ||
mvlr.do_analysis() | ||
if mvlr.validate( | ||
min_rsquared=data.validation_parameters.rsquared, | ||
max_f_pvalue=data.validation_parameters.f_pvalue, | ||
max_pvalues=data.validation_parameters.pvalues, | ||
): | ||
return MultiVariableRegressionResult.from_mvlr(mvlr) | ||
raise ValueError("No valid model found.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters