Skip to content

index and key are not present when using predict #35

@vidarsumo

Description

@vidarsumo

I have future known values so I need to pass the data set to new_data in predict() but it only gives me .pred_lower, .pred and .pred_upper. No index (date) or key (id) present in the output which is important as the data set contains multiple time series.

> forecasts_default <- predict(fitted_default, new_data = test, past_data = train)
> forecasts_default
# A tibble: 520 × 3
   .pred_lower .pred .pred_upper
         <dbl> <dbl>       <dbl>
 1       1498. 2242.       2874.
 2       1373. 1791.       2134.
 3       1259. 1671.       2016.
 4       1142. 1463.       1730.
 5       1619. 2090.       2485.
 6        467. 3079.       5370.
 7       1361. 1743.       2070.
 8       2375. 3815.       5073.
 9       2591. 3305.       3896.
10       5128. 7600.       9728.
# … with 510 more rows

Using generics::forecast() instead and skipping the known future data gives the desired output (i.e. containing date and id):

# A tibble: 520 × 5
   date       id        .pred_lower .pred .pred_upper
 * <date>     <chr>           <dbl> <dbl>       <dbl>
 1 2021-08-09 oes_13078       1498. 2242.       2874.
 2 2021-08-16 oes_13078       1598. 2323.       2971.
 3 2021-08-23 oes_13078       1510. 2379.       3257.
 4 2021-08-30 oes_13078       1572. 2410.       3216.
 5 2021-09-06 oes_13078       1356. 2280.       3259.
 6 2021-09-13 oes_13078       1359. 2090.       2809.
 7 2021-09-20 oes_13078       1383. 2130.       2771.
 8 2021-09-27 oes_13078       1324. 2074.       2847.
 9 2021-10-04 oes_13078       1355. 2254.       2973.
10 2021-10-11 oes_13078       1371. 2068.       2524.
# … with 510 more rows

Do I need to do anything for the predict() function to return the index and the key?

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions