Repository navigation
Align KumoForecast input preparation with the Kumo-TS SDK #1338
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
base: main
Are you sure you want to change the base?
Changes from all commits
1400085
c90cc4a
0839952
c863c61
2d9b177
bfa850c
4f44a5d
6221b9e
e091f42
7be8bca
0d4e68a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -96,7 +96,7 @@ class KumoForecast(ICLModel): | |
| ) | ||
| metadata: ClassVar[Mapping[str, str]] = { | ||
| "Output": "Point predictions per target and time step", | ||
| "Missing Values": "Handled natively", | ||
| "Missing Values": "Zero-imputed before standardization", | ||
| "Pretraining Scope": "Up to 512 rows", | ||
| } | ||
|
|
||
|
|
@@ -156,6 +156,8 @@ def forward( | |
| r""":meta private:""" # noqa: D415 | ||
| if not isinstance(x_context, TableTensor): | ||
| x_context = TableTensor.from_tensor(x_context) | ||
| if not isinstance(y_context, TableTensor): | ||
| y_context = TableTensor.from_tensor(y_context) | ||
| if not isinstance(x_query, TableTensor): | ||
| x_query = TableTensor.from_tensor(x_query) | ||
| if x_query.size(-1) > 0: | ||
|
|
@@ -168,6 +170,29 @@ def forward( | |
| ) | ||
| x_query = x_query[..., :0] | ||
|
|
||
| context_tables = [x_context, y_context] | ||
| for i, table in enumerate(context_tables): | ||
| numerical = table.numerical | ||
| numerical = numerical.masked_fill(numerical.isnan(), 0) | ||
| if table.size(-2) < self.model.context_size: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Retain padding after context callbacks. A context callback can shorten both processed histories after this padding step. The base validation accepts matching shortened histories, but
|
||
| padded = numerical.new_zeros( | ||
| ( | ||
| *numerical.size()[:-2], | ||
| self.model.context_size, | ||
| numerical.size(-1), | ||
| ), | ||
| ) | ||
| padded[..., self.model.context_size - table.size(-2) :, :] = ( | ||
| numerical | ||
| ) | ||
| numerical = padded | ||
| context_tables[i] = TableTensor( | ||
| columns={ | ||
| str(stype): names for stype, names in table.columns.items() | ||
| }, | ||
| numerical=numerical, | ||
| ) | ||
| x_context, y_context = context_tables | ||
| kwargs.update(alpha=alpha, k=k, temperature=temperature) | ||
| return super().forward(x_context, y_context, x_query, *args, **kwargs) | ||
|
|
||
|
|
@@ -226,12 +251,6 @@ def _forward( | |
|
|
||
| # Forecast: | ||
| last_x = x[..., -self.model.context_size :] | ||
| if last_x.size(-1) < context_size: | ||
| last_x = torch.nn.functional.pad( | ||
| last_x, | ||
| pad=(context_size - last_x.size(-1), 0), | ||
| value=float("nan"), | ||
| ) | ||
| encoded, mean, scale = self.model.encode(last_x) # [..., C, P, D] | ||
| out = self.model.decode(encoded, mean, scale) | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.