Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified data/input/test_time_series.xlsx
Binary file not shown.
4 changes: 2 additions & 2 deletions logs/cov.out
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Name Stmts Miss Co
/media/ph33r/Data/Project/CodeLib/Git/mllib/lib/knn.py 70 0 100%
/media/ph33r/Data/Project/CodeLib/Git/mllib/lib/model.py 44 0 100%
/media/ph33r/Data/Project/CodeLib/Git/mllib/lib/opt.py 157 0 100%
/media/ph33r/Data/Project/CodeLib/Git/mllib/lib/timeseries.py 61 0 100%
/media/ph33r/Data/Project/CodeLib/Git/mllib/lib/timeseries.py 62 0 100%
/media/ph33r/Data/Project/CodeLib/Git/mllib/lib/tree.py 79 0 100%
---------------------------------------------------------------------------------------------
TOTAL 528 0 100%
TOTAL 529 0 100%
8 changes: 4 additions & 4 deletions logs/pylint/lib-timeseries-py.out
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
************* Module mllib.lib.timeseries
timeseries.py:208:41: I1101: Module 'metrics' has no 'rsq' member, but source is unavailable. Consider adding this module to extension-pkg-whitelist if you want to perform analysis based on run-time introspection of living objects. (c-extension-no-member)
timeseries.py:209:41: I1101: Module 'metrics' has no 'mae' member, but source is unavailable. Consider adding this module to extension-pkg-whitelist if you want to perform analysis based on run-time introspection of living objects. (c-extension-no-member)
timeseries.py:210:42: I1101: Module 'metrics' has no 'mape' member, but source is unavailable. Consider adding this module to extension-pkg-whitelist if you want to perform analysis based on run-time introspection of living objects. (c-extension-no-member)
timeseries.py:211:42: I1101: Module 'metrics' has no 'rmse' member, but source is unavailable. Consider adding this module to extension-pkg-whitelist if you want to perform analysis based on run-time introspection of living objects. (c-extension-no-member)
timeseries.py:209:41: I1101: Module 'metrics' has no 'rsq' member, but source is unavailable. Consider adding this module to extension-pkg-whitelist if you want to perform analysis based on run-time introspection of living objects. (c-extension-no-member)
timeseries.py:210:41: I1101: Module 'metrics' has no 'mae' member, but source is unavailable. Consider adding this module to extension-pkg-whitelist if you want to perform analysis based on run-time introspection of living objects. (c-extension-no-member)
timeseries.py:211:42: I1101: Module 'metrics' has no 'mape' member, but source is unavailable. Consider adding this module to extension-pkg-whitelist if you want to perform analysis based on run-time introspection of living objects. (c-extension-no-member)
timeseries.py:212:42: I1101: Module 'metrics' has no 'rmse' member, but source is unavailable. Consider adding this module to extension-pkg-whitelist if you want to perform analysis based on run-time introspection of living objects. (c-extension-no-member)

--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)
Expand Down
5 changes: 3 additions & 2 deletions mllib/lib/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ def _compute_metrics(self) -> Dict[str, float]:
y_hat = list(self.model.predict_in_sample(start=d,
end=len(self.df)))
else:
y_hat = list(self.predict(self.df[self.x_var])[self.y_var].values)
exog = self.df[self.x_var]
y_hat = list(self.model.predict(n_periods=len(exog), X=exog))
model_summary = {"rsq": np.round(metrics.rsq(y, y_hat), 3),
"mae": np.round(metrics.mae(y, y_hat), 3),
"mape": np.round(metrics.mape(y, y_hat), 3),
Expand Down Expand Up @@ -251,5 +252,5 @@ def predict(self,
df_pred = pd.concat([df_pred, x_predict.reset_index(drop=True)],
axis=1,
ignore_index=True)
df_pred.columns = list(self.y_var) + self.x_var
df_pred.columns = [self.y_var] + self.x_var
return df_pred
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pandas==1.0.1
statsmodels==0.11.0
xlrd==1.2.0
numpy==1.18.1
PuLP==1.6.8
pmdarima==1.8.0
xgboost==1.5.0
numpy==1.18.1
Cython==0.29.15
PuLP==1.6.8
statsmodels==0.11.0
xgboost==1.5.0
scikit_learn==1.0.2
14 changes: 10 additions & 4 deletions tests/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,17 @@ def test_multivariate(self):
df_ip = pd.read_excel(path + "test_time_series.xlsx",
sheet_name="exog")
df_ip = df_ip.set_index("ts")
mod = AutoArima(df=df_ip, y_var="y", x_var=["cost"])
op = mod.metrics
y_var = "y"
x_var = ["cost"]
mod = AutoArima(df=df_ip, y_var=y_var, x_var=x_var)
metrics = mod.metrics
X = pd.DataFrame(df_ip.iloc[-1]).T
op = mod.predict(x_predict=X[x_var])[y_var][0]
exp_op = X[y_var][0]
self.assertEqual(mod.opt_params["order"], (0, 1, 1))
self.assertAlmostEqual(1.0, op["rsq"], places=1)
self.assertLessEqual(op["mape"], 0.1)
self.assertAlmostEqual(1.0, metrics["rsq"], places=1)
self.assertLessEqual(metrics["mape"], 0.1)
self.assertAlmostEqual(op, exp_op, places=0)

def test_univariate(self):
"""TimeSeries: Test for univariate"""
Expand Down