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
HORIZON = 62 | |
pipeline = Pipeline( | |
model=CatBoostModelPerSegment(), | |
transforms=[ | |
BinsegTrendTransform(in_column="target", n_bkps=2, min_size=150), | |
DateFlagsTransform(day_number_in_week=True, day_number_in_month=False, is_weekend=False), | |
], | |
horizon=HORIZON, | |
) |
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
HORIZON = 62 | |
pipeline = Pipeline( | |
model=CatBoostModelPerSegment(), | |
transforms=[ | |
LinearTrendTransform(in_column="target"), | |
DateFlagsTransform(day_number_in_week=True, day_number_in_month=False, is_weekend=False), | |
], | |
horizon=HORIZON, | |
) |
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
pipeline = Pipeline( | |
model=CatBoostModelPerSegment(), | |
transforms=[ | |
DateFlagsTransform(day_number_in_week=True, day_number_in_month=False, is_weekend=False), | |
], | |
horizon=HORIZON, | |
) | |
metrics, forecast, _ = pipeline.backtest(ts, metrics=[SMAPE()], n_folds=3) | |
plot_backtest(forecast, ts, history_len="all") |
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
from etna.datasets import TSDataset | |
from itertools import filterfalse | |
import pandas as pd | |
import re | |
def get_segments(tags: list): | |
segments = [] | |
for tag in tags: | |
segments.extend(list(filterfalse(lambda x: tag not in x, data["Page"]))) |
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
from etna.analysis import plot_feature_relevance, ModelRelevanceTable | |
from catboost import CatBoostRegressor | |
ts = get_ts(segments) | |
ts.fit_transform(transforms) | |
plot_feature_relevance( | |
ts=ts, | |
relevance_table=ModelRelevanceTable(), | |
relevance_aggregation_mode="mean", | |
relevance_params={ |
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
plot_metric_per_segment(metrics, metric_name="SMAPE", top_k=10, ascending=False) |
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
from etna.analysis import plot_metric_per_segment | |
plot_metric_per_segment(metrics, metric_name="SMAPE", top_k=10, ascending=True) |
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
from etna.models import CatBoostModelMultiSegment | |
from etna.transforms import SegmentEncoderTransform | |
from etna.transforms import LagTransform | |
from etna.analysis import metric_per_segment_distribution_plot | |
HORIZON = 62 | |
np.random.seed(42) | |
segments = np.random.choice(data["Page"].values, size=100) | |
ts = get_ts(segments) | |
ts.fit_transform( |
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
from etna.analysis import plot_trend | |
from etna.transforms import LinearTrendTransform, BinsegTrendTransform | |
ts = get_ts(["List_of_country"]) | |
ts.fit_transform([TimeSeriesImputerTransform(in_column="target", strategy="running_mean", window=3)]) | |
plot_trend( | |
ts=ts, | |
trend_transform=[ | |
LinearTrendTransform(in_column="target"), | |
BinsegTrendTransform(in_column="target", n_bkps=2, min_size=150), |
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
from etna.models import CatBoostModelPerSegment | |
from etna.transforms import DateFlagsTransform, FourierTransform | |
HORIZON = 62 | |
pipeline = Pipeline( | |
model=CatBoostModelPerSegment(), | |
transforms=[ | |
DensityOutliersTransform(in_column="target", window_size=30, n_neighbors=9, distance_coef=1), | |
TimeSeriesImputerTransform(in_column="target", strategy="running_mean", window=3), | |
FourierTransform(period=365.25, order=4), |
NewerOlder