Cell In[12], line 4
2 naive_model = NaiveSeasonal(K=1)
3 with LogTime() as timer:
----> 4 y_pred, metrics = eval_model(naive_model, ts_train, ts_val, name=name)
5 metrics['Time Elapsed'] = timer.elapsed
6 metric_record.append(metrics)
Cell In[10], line 11
4 model.fit(ts_train)
5 y_pred = model.predict(len(ts_test))
6 return y_pred, {
7 "Algorithm": name,
8 "MAE": mae(actual_series = ts_test, pred_series = y_pred),
9 "MSE": mse(actual_series = ts_test, pred_series = y_pred),
10 "MASE": mase(actual_series = ts_test, pred_series = y_pred, insample=ts_train),
---> 11 "Forecast Bias": forecast_bias(actual_series = ts_test, pred_series = y_pred)
12 }
File ~/Modern-Time-Series-Forecasting-with-Python/src/utils/ts_utils.py:102, in forecast_bias(actual_series, pred_series, intersect, reduction, inter_reduction, n_jobs, verbose)
100 else:
101 y_true, y_pred = _get_values_or_raise(actual_series, pred_series, intersect)
--> 102 y_true, y_pred = _remove_nan_union(y_true, y_pred)
103 y_true_sum, y_pred_sum = np.sum(y_true), np.sum(y_pred)
...
5348 'length of {}'.format(N))
5350 # optimization, the other branch is slower
5351 keep = ~obj
ValueError: boolean array argument obj to delete must be one dimensional and match the axis length of 1488
def _remove_nan_union(array_a: np.ndarray,
array_b: np.ndarray) -> Tuple[np.ndarray, np.ndarray]:
"""
Returns the two inputs arrays where all elements are deleted that have an index that corresponds to
a NaN value in either of the two input arrays.
"""
isnan_mask = np.logical_or(np.isnan(array_a), np.isnan(array_b))
# I added the line below
isnan_mask = isnan_mask.reshape(-1,)
return np.delete(array_a, isnan_mask), np.delete(array_b, isnan_mask)
This resolved the ValueError but I do not know if there are any side-effects of my modification.
When running the
eval_modelfunction within Chapter 4: 02-Baseline Forecasts using darts.ipynb at cell 12, I get the following error:I went into
ts_utils.pyand made the following changes:This resolved the ValueError but I do not know if there are any side-effects of my modification.