Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

call corresponding endpoint in cross_validation #300

Merged
merged 11 commits into from
May 1, 2024
Merged

Conversation

jmoralez
Copy link
Member

@jmoralez jmoralez commented Apr 23, 2024

Calls the cross_validation endpoint in the API when using the cross_validation method.

This required a couple of refactors:

  • The logic to determine the date features inside the preprocess_dataframes was moved to add_date_features to be able to call that method directly, because the logic in that method isn't compatible with the structure needed for cross_validation. This also prevented some attributes from being overriden to reduce the complexity and prevent unwanted interactions.
  • The restrict_input logic was extracted to a separate method.

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copy link
Contributor

Experiment Results

Experiment 1: air-passengers

Description:

variable experiment
h 12
season_length 12
freq MS
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 12.6793 11.0623 47.8333 76
mape 0.027 0.0232 0.0999 0.1425
mse 213.936 199.132 2571.33 10604.2
total_time 3.3595 5.1812 0.0089 0.0047

Plot:

Experiment 2: air-passengers

Description:

variable experiment
h 24
season_length 12
freq MS
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 58.1031 58.4587 71.25 115.25
mape 0.1257 0.1267 0.1552 0.2358
mse 4040.22 4110.79 5928.17 18859.2
total_time 4.861 6.4176 0.0056 0.0047

Plot:

Experiment 3: electricity-multiple-series

Description:

variable experiment
h 24
season_length 24
freq H
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 142.394 196.363 269.23 1331.02
mape 0.0203 0.0234 0.0304 0.1692
mse 63464.7 123119 213677 4.68961e+06
total_time 6.1023 6.5302 0.0079 0.0069

Plot:

Experiment 4: electricity-multiple-series

Description:

variable experiment
h 168
season_length 24
freq H
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 522.427 353.528 398.956 1119.26
mape 0.069 0.0454 0.0512 0.1583
mse 966294 422332 656723 3.17316e+06
total_time 5.4906 7.1572 0.0074 0.0069

Plot:

Experiment 5: electricity-multiple-series

Description:

variable experiment
h 336
season_length 24
freq H
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 478.362 361.033 602.926 1340.95
mape 0.0622 0.046 0.0787 0.17
mse 805039 441118 1.61572e+06 6.04619e+06
total_time 7.0408 5.4176 0.0074 0.007

Plot:

Copy link
Contributor

Experiment Results

Experiment 1: air-passengers

Description:

variable experiment
h 12
season_length 12
freq MS
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 12.6793 11.0623 47.8333 76
mape 0.027 0.0232 0.0999 0.1425
mse 213.936 199.132 2571.33 10604.2
total_time 3.0683 5.4451 0.0087 0.0047

Plot:

Experiment 2: air-passengers

Description:

variable experiment
h 24
season_length 12
freq MS
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 58.1031 58.4587 71.25 115.25
mape 0.1257 0.1267 0.1552 0.2358
mse 4040.22 4110.79 5928.17 18859.2
total_time 10.027 10.7113 0.0054 0.0046

Plot:

Experiment 3: electricity-multiple-series

Description:

variable experiment
h 24
season_length 24
freq H
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 142.394 196.363 269.23 1331.02
mape 0.0203 0.0234 0.0304 0.1692
mse 63464.7 123119 213677 4.68961e+06
total_time 5.9582 7.1798 0.0074 0.0066

Plot:

Experiment 4: electricity-multiple-series

Description:

variable experiment
h 168
season_length 24
freq H
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 522.427 353.528 398.956 1119.26
mape 0.069 0.0454 0.0512 0.1583
mse 966294 422332 656723 3.17316e+06
total_time 4.9416 5.9843 0.0073 0.0067

Plot:

Experiment 5: electricity-multiple-series

Description:

variable experiment
h 336
season_length 24
freq H
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 478.362 361.033 602.926 1340.95
mape 0.0622 0.046 0.0787 0.17
mse 805038 441118 1.61572e+06 6.04619e+06
total_time 8.0863 5.813 0.0073 0.0068

Plot:

Copy link
Contributor

Experiment Results

Experiment 1: air-passengers

Description:

variable experiment
h 12
season_length 12
freq MS
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 12.6793 11.0623 47.8333 76
mape 0.027 0.0232 0.0999 0.1425
mse 213.936 199.132 2571.33 10604.2
total_time 6.7511 10.5437 0.0091 0.0049

Plot:

Experiment 2: air-passengers

Description:

variable experiment
h 24
season_length 12
freq MS
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 58.1031 58.4587 71.25 115.25
mape 0.1257 0.1267 0.1552 0.2358
mse 4040.22 4110.79 5928.17 18859.2
total_time 11.4124 11.1059 0.0062 0.0051

Plot:

Experiment 3: electricity-multiple-series

Description:

variable experiment
h 24
season_length 24
freq H
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 142.394 196.363 269.23 1331.02
mape 0.0203 0.0234 0.0304 0.1692
mse 63464.8 123119 213677 4.68961e+06
total_time 12.5897 11.2768 0.0084 0.0074

Plot:

Experiment 4: electricity-multiple-series

Description:

variable experiment
h 168
season_length 24
freq H
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 522.427 353.528 398.956 1119.26
mape 0.069 0.0454 0.0512 0.1583
mse 966294 422332 656723 3.17316e+06
total_time 12.4718 11.2887 0.0079 0.0074

Plot:

Experiment 5: electricity-multiple-series

Description:

variable experiment
h 336
season_length 24
freq H
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 478.362 361.033 602.926 1340.95
mape 0.0622 0.046 0.0787 0.17
mse 805038 441118 1.61572e+06 6.04619e+06
total_time 15.4437 9.967 0.0087 0.0085

Plot:

Copy link
Contributor

Experiment Results

Experiment 1: air-passengers

Description:

variable experiment
h 12
season_length 12
freq MS
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 12.6793 11.0623 47.8333 76
mape 0.027 0.0232 0.0999 0.1425
mse 213.936 199.132 2571.33 10604.2
total_time 9.5399 10.6874 0.0085 0.0046

Plot:

Experiment 2: air-passengers

Description:

variable experiment
h 24
season_length 12
freq MS
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 58.1031 58.4587 71.25 115.25
mape 0.1257 0.1267 0.1552 0.2358
mse 4040.21 4110.79 5928.17 18859.2
total_time 10.1251 9.6249 0.0056 0.0047

Plot:

Experiment 3: electricity-multiple-series

Description:

variable experiment
h 24
season_length 24
freq H
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 142.394 196.363 269.23 1331.02
mape 0.0203 0.0234 0.0304 0.1692
mse 63464.7 123119 213677 4.68961e+06
total_time 9.4487 9.5113 0.0078 0.0069

Plot:

Experiment 4: electricity-multiple-series

Description:

variable experiment
h 168
season_length 24
freq H
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 522.427 353.528 398.956 1119.26
mape 0.069 0.0454 0.0512 0.1583
mse 966294 422332 656723 3.17316e+06
total_time 11.8248 14.933 0.0073 0.007

Plot:

Experiment 5: electricity-multiple-series

Description:

variable experiment
h 336
season_length 24
freq H
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 478.362 361.033 602.926 1340.95
mape 0.0622 0.046 0.0787 0.17
mse 805039 441118 1.61572e+06 6.04619e+06
total_time 14.4779 11.7709 0.0075 0.007

Plot:

Copy link
Contributor

Experiment Results

Experiment 1: air-passengers

Description:

variable experiment
h 12
season_length 12
freq MS
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 12.6793 11.0623 47.8333 76
mape 0.027 0.0232 0.0999 0.1425
mse 213.936 199.132 2571.33 10604.2
total_time 10.8811 5.2323 0.0088 0.0048

Plot:

Experiment 2: air-passengers

Description:

variable experiment
h 24
season_length 12
freq MS
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 58.1031 58.4587 71.25 115.25
mape 0.1257 0.1267 0.1552 0.2358
mse 4040.21 4110.79 5928.17 18859.2
total_time 8.2443 9.281 0.0058 0.0048

Plot:

Experiment 3: electricity-multiple-series

Description:

variable experiment
h 24
season_length 24
freq H
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 142.394 196.363 269.23 1331.02
mape 0.0203 0.0234 0.0304 0.1692
mse 63464.7 123119 213677 4.68961e+06
total_time 8.1626 12.3383 0.0078 0.0069

Plot:

Experiment 4: electricity-multiple-series

Description:

variable experiment
h 168
season_length 24
freq H
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 522.427 353.528 398.956 1119.26
mape 0.069 0.0454 0.0512 0.1583
mse 966294 422332 656723 3.17316e+06
total_time 5.1948 6.0768 0.0076 0.0069

Plot:

Experiment 5: electricity-multiple-series

Description:

variable experiment
h 336
season_length 24
freq H
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 478.362 361.033 602.926 1340.95
mape 0.0622 0.046 0.0787 0.17
mse 805039 441118 1.61572e+06 6.04619e+06
total_time 11.4559 10.1713 0.0078 0.007

Plot:

Copy link
Contributor

Experiment Results

Experiment 1: air-passengers

Description:

variable experiment
h 12
season_length 12
freq MS
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 12.6793 11.0623 47.8333 76
mape 0.027 0.0232 0.0999 0.1425
mse 213.936 199.132 2571.33 10604.2
total_time 5.9552 10.9815 0.0087 0.0047

Plot:

Experiment 2: air-passengers

Description:

variable experiment
h 24
season_length 12
freq MS
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 58.1031 58.4587 71.25 115.25
mape 0.1257 0.1267 0.1552 0.2358
mse 4040.22 4110.79 5928.17 18859.2
total_time 8.7135 7.1011 0.0054 0.0046

Plot:

Experiment 3: electricity-multiple-series

Description:

variable experiment
h 24
season_length 24
freq H
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 142.394 196.363 269.23 1331.02
mape 0.0203 0.0234 0.0304 0.1692
mse 63464.8 123119 213677 4.68961e+06
total_time 12.3537 11.0562 0.0079 0.0067

Plot:

Experiment 4: electricity-multiple-series

Description:

variable experiment
h 168
season_length 24
freq H
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 522.427 353.528 398.956 1119.26
mape 0.069 0.0454 0.0512 0.1583
mse 966295 422332 656723 3.17316e+06
total_time 9.7135 8.1769 0.0074 0.0069

Plot:

Experiment 5: electricity-multiple-series

Description:

variable experiment
h 336
season_length 24
freq H
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 478.362 361.033 602.926 1340.95
mape 0.0622 0.046 0.0787 0.17
mse 805038 441118 1.61572e+06 6.04619e+06
total_time 13.2476 8.5143 0.0073 0.0068

Plot:

Copy link
Contributor

Experiment Results

Experiment 1: air-passengers

Description:

variable experiment
h 12
season_length 12
freq MS
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 12.6793 11.0623 47.8333 76
mape 0.027 0.0232 0.0999 0.1425
mse 213.936 199.132 2571.33 10604.2
total_time 4.2158 2.6322 0.0086 0.0047

Plot:

Experiment 2: air-passengers

Description:

variable experiment
h 24
season_length 12
freq MS
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 58.1031 58.4587 71.25 115.25
mape 0.1257 0.1267 0.1552 0.2358
mse 4040.21 4110.79 5928.17 18859.2
total_time 10.6872 3.604 0.0058 0.0049

Plot:

Experiment 3: electricity-multiple-series

Description:

variable experiment
h 24
season_length 24
freq H
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 142.394 196.363 269.23 1331.02
mape 0.0203 0.0234 0.0304 0.1692
mse 63464.7 123119 213677 4.68961e+06
total_time 6.0107 10.8721 0.0077 0.0066

Plot:

Experiment 4: electricity-multiple-series

Description:

variable experiment
h 168
season_length 24
freq H
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 522.427 353.528 398.956 1119.26
mape 0.069 0.0454 0.0512 0.1583
mse 966294 422332 656723 3.17316e+06
total_time 10.3246 10.4512 0.0076 0.007

Plot:

Experiment 5: electricity-multiple-series

Description:

variable experiment
h 336
season_length 24
freq H
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 478.362 361.033 602.926 1340.95
mape 0.0622 0.046 0.0787 0.17
mse 805039 441118 1.61572e+06 6.04619e+06
total_time 12.6547 8.5403 0.0076 0.0071

Plot:

Copy link
Contributor

Experiment Results

Experiment 1: air-passengers

Description:

variable experiment
h 12
season_length 12
freq MS
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 12.6793 11.0623 47.8333 76
mape 0.027 0.0232 0.0999 0.1425
mse 213.936 199.132 2571.33 10604.2
total_time 3.8503 3.0823 0.0094 0.0053

Plot:

Experiment 2: air-passengers

Description:

variable experiment
h 24
season_length 12
freq MS
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 58.1031 58.4587 71.25 115.25
mape 0.1257 0.1267 0.1552 0.2358
mse 4040.21 4110.79 5928.17 18859.2
total_time 5.2331 3.8088 0.0062 0.0053

Plot:

Experiment 3: electricity-multiple-series

Description:

variable experiment
h 24
season_length 24
freq H
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 142.394 196.363 269.23 1331.02
mape 0.0203 0.0234 0.0304 0.1692
mse 63464.7 123119 213677 4.68961e+06
total_time 3.3612 6.1869 0.008 0.0073

Plot:

Experiment 4: electricity-multiple-series

Description:

variable experiment
h 168
season_length 24
freq H
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 522.427 353.528 398.956 1119.26
mape 0.069 0.0454 0.0512 0.1583
mse 966294 422332 656723 3.17316e+06
total_time 3.8503 4.3445 0.0078 0.0077

Plot:

Experiment 5: electricity-multiple-series

Description:

variable experiment
h 336
season_length 24
freq H
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 478.362 361.033 602.926 1340.95
mape 0.0622 0.046 0.0787 0.17
mse 805039 441118 1.61572e+06 6.04619e+06
total_time 7.0397 3.4937 0.0081 0.0077

Plot:

This reverts commit f99d4e0.
Copy link
Contributor

github-actions bot commented May 1, 2024

Experiment Results

Experiment 1: air-passengers

Description:

variable experiment
h 12
season_length 12
freq MS
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 12.6793 11.0623 47.8333 76
mape 0.027 0.0232 0.0999 0.1425
mse 213.936 199.132 2571.33 10604.2
total_time 5.0212 5.997 0.0087 0.0046

Plot:

Experiment 2: air-passengers

Description:

variable experiment
h 24
season_length 12
freq MS
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 58.1031 58.4587 71.25 115.25
mape 0.1257 0.1267 0.1552 0.2358
mse 4040.21 4110.79 5928.17 18859.2
total_time 7.1112 7.4455 0.0059 0.0048

Plot:

Experiment 3: electricity-multiple-series

Description:

variable experiment
h 24
season_length 24
freq H
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 142.394 196.363 269.23 1331.02
mape 0.0203 0.0234 0.0304 0.1692
mse 63464.7 123119 213677 4.68961e+06
total_time 5.758 9.3779 0.0082 0.0069

Plot:

Experiment 4: electricity-multiple-series

Description:

variable experiment
h 168
season_length 24
freq H
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 522.427 353.528 398.956 1119.26
mape 0.069 0.0454 0.0512 0.1583
mse 966294 422332 656723 3.17316e+06
total_time 7.4884 6.2507 0.0074 0.0068

Plot:

Experiment 5: electricity-multiple-series

Description:

variable experiment
h 336
season_length 24
freq H
level None
n_windows 1

Results:

metric timegpt-1 timegpt-1-long-horizon SeasonalNaive Naive
mae 478.362 361.033 602.926 1340.95
mape 0.0622 0.046 0.0787 0.17
mse 805039 441118 1.61572e+06 6.04619e+06
total_time 9.0639 6.3045 0.0076 0.0069

Plot:

@jmoralez jmoralez marked this pull request as ready for review May 1, 2024 01:14
@jmoralez jmoralez requested a review from AzulGarza May 1, 2024 01:29
Copy link
Member

@AzulGarza AzulGarza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome @jmoralez! lvgtm🥳


from .client import Nixtla
from .core import ApiError
from .types.multi_series_anomaly import MultiSeriesAnomaly
from .types.multi_series_cross_validation import MultiSeriesCrossValidation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pfff beautiful change

Comment on lines +532 to +549
def _restrict_input_samples(self) -> int:
main_logger.info("Restricting input...")
if self.level is not None:
# add sufficient info to compute
# conformal interval
# @AzulGarza
# this is an old opinionated decision
# about reducing the data sent to the api
# to reduce latency when
# a user passes level. since currently the model
# uses conformal prediction, we can change a minimum
# amount of data if the series are too large
new_input_size = 3 * self.input_size + max(self.model_horizon, self.h)
else:
# we only want to forecast
new_input_size = self.input_size
return new_input_size

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@AzulGarza AzulGarza merged commit cd63921 into main May 1, 2024
14 checks passed
@AzulGarza AzulGarza deleted the cv-from-api branch May 1, 2024 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants