This file contains hidden or 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
| # Example script running rolling evaluation of Chronos models. | |
| # See: https://github.com/amazon-science/chronos-forecasting | |
| # | |
| # Requirements: | |
| # uv pip install -U chronos-forecasting matplotlib numpy pandas torch | |
| # | |
| import pandas as pd | |
| import numpy as np | |
| import torch |
This file contains hidden or 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
| # Just journal for today: journal | |
| # yesterday: journal -1 | |
| # in a directory: (cd PATH && journal) | |
| function journal { | |
| case "$(uname -s)" in | |
| Linux*) machine=linux;; | |
| Darwin*) machine=mac;; | |
| esac | |
| if [[ $machine == "mac" ]] then |
This file contains hidden or 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
| # Works on gluonts dev branch as of May 30th, 2023 | |
| # Assumes "m5-forecasting-accuracy" folder with data next to the script | |
| # Data is obtained from https://www.kaggle.com/c/m5-forecasting-accuracy | |
| import pandas as pd | |
| from pathlib import Path | |
| from gluonts.dataset.pandas import PandasDataset | |
| # Load data from csv files |
This file contains hidden or 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
| syntax on | |
| filetype plugin indent on | |
| set tabstop=4 softtabstop=4 shiftwidth=4 expandtab smarttab autoindent | |
| set incsearch ignorecase smartcase hlsearch | |
| set wildmode=longest,list,full wildmenu | |
| set ruler laststatus=2 showcmd showmode | |
| set list listchars=trail:»,tab:»- | |
| set fillchars+=vert:\ | |
| set wrap breakindent | |
| set encoding=utf-8 |
This file contains hidden or 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 gluonts.dataset.repository.datasets import get_dataset, dataset_names | |
| def check_train_test_split(dataset): | |
| prediction_length = dataset.metadata.prediction_length | |
| train_end = {} | |
| for entry in dataset.train: | |
| assert entry["item_id"] not in train_end, f"item {k} is duplicate" | |
| train_end[entry["item_id"]] = entry["start"] + len(entry["target"]) * entry["start"].freq |
This file contains hidden or 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
| import time | |
| import mxnet as mx | |
| from gluonts.dataset.repository.datasets import get_dataset | |
| from gluonts.dataset.loader import TrainDataLoader | |
| from gluonts.model.deepar import DeepAREstimator | |
| from gluonts.mx.batchify import batchify as mx_batchify | |
| dataset = get_dataset("electricity") |
This file contains hidden or 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
| import time | |
| from functools import partial | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| import seaborn as sns | |
| import mxnet as mx | |
| import torch |
This file contains hidden or 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 pathlib import Path | |
| from typing import List | |
| class IndexedFile: | |
| def __init__(self, path: Path) -> None: | |
| self.path = path | |
| self.offset: List[int] = [] | |
| self._build_index() | |
This file contains hidden or 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
| import mxnet as mx | |
| class MyBlock(mx.gluon.HybridBlock): | |
| def __init__(self): | |
| super().__init__() | |
| with self.name_scope(): | |
| self.lstmcell = mx.gluon.rnn.LSTMCell(hidden_size=20) | |
| def hybrid_forward(self, F, seq): | |
| outputs, state = self.lstmcell.unroll(inputs=seq, length=10, layout="NTC", merge_outputs=True) |
This file contains hidden or 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
| import mxnet as mx | |
| class MyBlock(mx.gluon.HybridBlock): | |
| def __init__(self): | |
| super().__init__() | |
| with self.name_scope(): | |
| self.lstm = mx.gluon.rnn.HybridSequentialRNNCell() | |
| for layer in range(3): | |
| self.lstm.add(mx.gluon.rnn.LSTMCell(hidden_size=20)) |
NewerOlder