Commit 06f167e1 authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼
parent a974c1e5
...@@ -11,7 +11,7 @@ for f in sorted(glob.glob(os.path.join('slapos', 'README.*.rst'))): ...@@ -11,7 +11,7 @@ for f in sorted(glob.glob(os.path.join('slapos', 'README.*.rst'))):
long_description += open("CHANGES.txt").read() + "\n" long_description += open("CHANGES.txt").read() + "\n"
prediction_require = ['statsmodels', 'scipy', 'pandas'] prediction_require = ['statsmodels>=0.11.0', 'scipy', 'pandas']
test_require = ['mock', 'cryptography', 'websockets; python_version>="3"',] + prediction_require test_require = ['mock', 'cryptography', 'websockets; python_version>="3"',] + prediction_require
setup(name=name, setup(name=name,
......
...@@ -22,7 +22,7 @@ from contextlib import closing ...@@ -22,7 +22,7 @@ from contextlib import closing
try: try:
import pandas as pd import pandas as pd
import numpy as np import numpy as np
from statsmodels.tsa.arima_model import ARIMA from statsmodels.tsa.arima.model import ARIMA
except ImportError: except ImportError:
pass pass
...@@ -126,9 +126,10 @@ class RunPromise(GenericPromise): ...@@ -126,9 +126,10 @@ class RunPromise(GenericPromise):
for t in range(len(test)): for t in range(len(test)):
with warnings.catch_warnings(): with warnings.catch_warnings():
warnings.simplefilter("ignore") warnings.simplefilter("ignore")
model = ARIMA(history, order=arima_order) # WARNING, HERE we should use the order SOMEHOW
model_fit = model.fit(disp=-1) model = ARIMA(history)
yhat = model_fit.forecast()[0] model_fit = model.fit()
yhat = model_fit.forecast()
predictions.append(yhat) predictions.append(yhat)
history.append(test[t]) history.append(test[t])
# calculate out of sample error # calculate out of sample error
...@@ -191,11 +192,11 @@ class RunPromise(GenericPromise): ...@@ -191,11 +192,11 @@ class RunPromise(GenericPromise):
# disabling warnings during the ARIMA calculation # disabling warnings during the ARIMA calculation
with warnings.catch_warnings(): with warnings.catch_warnings():
warnings.simplefilter("ignore") warnings.simplefilter("ignore")
model_arima = ARIMA(df, order=best_cfg) # WARNING, HERE we should use the order SOMEHOW
# disp < 0 means no output about convergence information model_arima = ARIMA(df)
model_arima_fit = model_arima.fit(disp=-1) model_arima_fit = model_arima.fit()
# save ARIMA predictions # save ARIMA predictions
fcast, _, conf = model_arima_fit.forecast(max_date_predicted, alpha=0.05) fcast = model_arima_fit.forecast(max_date_predicted, alpha=0.05)
# pass the same index as the others # pass the same index as the others
fcast = pd.Series(fcast, index=future_index_date) fcast = pd.Series(fcast, index=future_index_date)
if fcast.empty: if fcast.empty:
...@@ -205,9 +206,7 @@ class RunPromise(GenericPromise): ...@@ -205,9 +206,7 @@ class RunPromise(GenericPromise):
self.logger.info("Arima prediction error: skipped prediction") self.logger.info("Arima prediction error: skipped prediction")
return None return None
# get results with 95% confidence # get results with 95% confidence
lower_series = pd.Series(conf[:, 0], index=future_index_date) return fcast
upper_series = pd.Series(conf[:, 1], index=future_index_date)
return fcast, lower_series, upper_series
except sqlite3.OperationalError as e: except sqlite3.OperationalError as e:
# if database is still locked after timeout expiration (another process is using it) # if database is still locked after timeout expiration (another process is using it)
# we print warning message and try the promise at next run until max warn count # we print warning message and try the promise at next run until max warn count
...@@ -324,10 +323,9 @@ class RunPromise(GenericPromise): ...@@ -324,10 +323,9 @@ class RunPromise(GenericPromise):
"but at least one module is not installed. Prediction skipped.") "but at least one module is not installed. Prediction skipped.")
return return
nb_days_predicted = int(self.getConfig('nb-days-predicted', 10) or 10) nb_days_predicted = int(self.getConfig('nb-days-predicted', 10) or 10)
disk_space_prediction_tuple = self.diskSpacePrediction( fcast = self.diskSpacePrediction(
disk_partition, db_path, currentdate, currenttime, nb_days_predicted) disk_partition, db_path, currentdate, currenttime, nb_days_predicted)
if disk_space_prediction_tuple is not None: if fcast is not None:
fcast, lower_series, upper_series = disk_space_prediction_tuple
space_left_predicted = fcast.iloc[-1] space_left_predicted = fcast.iloc[-1]
last_date_predicted = datetime.datetime.strptime(str(fcast.index[-1]), last_date_predicted = datetime.datetime.strptime(str(fcast.index[-1]),
"%Y-%m-%d %H:%M:%S") "%Y-%m-%d %H:%M:%S")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment