Skip to content

Commit

Permalink
adding forecasting time series case
Browse files Browse the repository at this point in the history
  • Loading branch information
KozitsinSlava committed Sep 17, 2023
1 parent 85a8f0c commit 50f97a5
Show file tree
Hide file tree
Showing 6 changed files with 282 additions and 503 deletions.
375 changes: 126 additions & 249 deletions Tutorials/forecasting-time-series.ipynb

Large diffs are not rendered by default.

375 changes: 126 additions & 249 deletions docs/waico_jups/forecasting-time-series.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tsad/base/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def _sklearn_predict(self,df):
return new_df


def fit(self,df:pd.DataFrame,sklearn_kwargs):
def fit(self,df:pd.DataFrame,sklearn_kwargs={}):
self.sklearnClass.fit(df,**sklearn_kwargs)
new_df = self._sklearn_predict(df)
return new_df
Expand Down
26 changes: 26 additions & 0 deletions tsad/pipelines.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from tsad.tasks.eda import HighLevelDatasetAnalysisTask, TimeDiscretizationTask
from tsad.tasks.eda import FindNaNTask, EquipmentDowntimeTask
from tsad.tasks.preprocess import ScalingTask, ValueRangeProcessingTask, ResampleProcessingTask
from tsad.tasks.preprocess import FeatureProcessingTask, SplitByNaNTask, PrepareSeqSamplesTask
from tsad.tasks.deep_learning_anomaly_detection import ResidualAnomalyDetectionTask
from tsad.tasks.deep_learning_forecasting import DeepLeaningTimeSeriesForecastingTask

from tsad.base.pipeline import Pipeline
from tsad.base.wrappers import SklearnWrapper

from sklearn.preprocessing import StandardScaler

StandardScalerTask = SklearnWrapper(StandardScaler)

multivatiateTimeSeriesDeepLearningForecastingTaskSet = [
HighLevelDatasetAnalysisTask(),
TimeDiscretizationTask(freq_tobe_approach='most_frequent'),
FindNaNTask(),
EquipmentDowntimeTask(),
ResampleProcessingTask(),
StandardScalerTask(),
FeatureProcessingTask(),
SplitByNaNTask(),
PrepareSeqSamplesTask(len_seq=10),
DeepLeaningTimeSeriesForecastingTask(),
]
5 changes: 2 additions & 3 deletions tsad/tasks/deep_learning_forecasting.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,8 @@ def predict(self,
# -----------------------------------------------------------------------------------------
# Генерация остатков
# -----------------------------------------------------------------------------------------
X_train, X_test, y_train, y_test = dfs
all_data_iterator = self.Loader(X_test, y_test, self.batch_size, shuffle=False) ######
##### !!!!!!!!!!!!!!! c X_test, y_test точно ошибка
X_train, X_test, y_train, y_test = dfs # тут нужен только X_train
all_data_iterator = self.Loader(X_train, X_train, self.batch_size, shuffle=False)

y_pred = self.model.run_epoch( all_data_iterator,
None, None, phase='forecast', points_ahead=self.points_ahead,
Expand Down
2 changes: 1 addition & 1 deletion tsad/tasks/eda.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def __init__(self, name: str | None = None, FREQ_TOBE=None, freq_tobe_approach:
* Если 'custom' для оптимальной частоты берется частота из параметра FREQ_TOBE
* Если 'min_period' для оптимальной частоты берется частота,
соответствующая минимальному периоду между сэмплами
* Если 'min_period' для оптимальной частоты берется частота,
* Если 'most_frequent' для оптимальной частоты берется частота,
соответствующая наиболее часто встречающемуся периоду между сэмплами
* Если 'auto' для оптимальной частоты берется частота,
которая находится сложным образом на основе округления большего числа периодов.
Expand Down

0 comments on commit 50f97a5

Please sign in to comment.