Repository: ourownstory/neural_prophet

Issue:
Float32 target values encounter TypeError: can't convert np.ndarray of type numpy.datetime64.
**Prerequisites**

* [X] Put an X between the brackets on this line if you have done all of the following:
    * Reproduced the problem in a new virtualenv with only neuralprophet installed, directly from github:
      ```shell
      git clone <copied link from github>
      cd neural_prophet
      pip install .
      ```
    * Checked the Answered Questions on the Github Disscussion board: https://github.com/ourownstory/neural_prophet/discussions
      If you have the same question but the Answer does not solve your issue, please continue the conversation there.
    * Checked that your issue isn't already filed: https://github.com/ourownstory/neural_prophet/issues
      If you have the same issue but there is a twist to your situation, please add an explanation there.
    * Considered whether your bug might actually be solvable by getting a question answered: 
      * Please [post a package use question](https://github.com/ourownstory/neural_prophet/discussions/categories/q-a-get-help-using-neuralprophet)
      * Please [post a forecasting best practice question](https://github.com/ourownstory/neural_prophet/discussions/categories/q-a-forecasting-best-practices)
      * Please [post an idea or feedback](https://github.com/ourownstory/neural_prophet/discussions/categories/ideas-feedback)

**Describe the bug**

Type error encountered predicting a np.float32 column, appears to be in time_dataset.py.

**To Reproduce**

```import pandas as pd
from neuralprophet import NeuralProphet
df = pd.read_csv("https://github.com/ourownstory/neuralprophet-data/raw/main/kaggle-energy/datasets/tutorial01.csv")
df.y = df.y.astype('float32')
m = NeuralProphet()
metrics = m.fit(df)
```

**Expected behavior**

The model should have no problem fitting.


**What actually happens**

```
  File "/home/gordon/src/neural_prophet/neuralprophet/time_dataset.py", line 145, in init_after_tabularized
    self.targets = torch.from_numpy(targets).type(targets_dtype).unsqueeze(dim=2)
TypeError: can't convert np.ndarray of type numpy.datetime64. The only supported types are: float64, float32, float16, complex64, complex128, int64, int32, int16, int8, uint8, and bool.
```

**Environment (please complete the following information):**

Reproduced on python 3.10.11.
The bug is present in neuralprophet 0.6.0, but not in 0.5.4, I tried both PyPI and installed from cloned github repo.




Discussion:
I looked into this and I think it's an issue with the `_stride_future_time_features_for_forecasts` function within `tabularize_univariate_datetime`. It looks like the target values will get transformed to `np.datetime64` unless the input is `np.float64`.

```
def _stride_future_time_features_for_forecasts(x):
    # only for case where n_lags > 0
    if x.dtype != np.float64:
        dtype = np.datetime64
    else:
        dtype = np.float64
    return np.array([x[max_lags + i : max_lags + i + n_forecasts] for i in range(n_samples)], dtype=dtype)
```

@LeonieFreisinger I think you made this [change](https://github.com/ourownstory/neural_prophet/commit/ba949c76903f4c20ac58049cae5bcd844043b757)?

Resolving patch:
diff --git a/neuralprophet/time_dataset.py b/neuralprophet/time_dataset.py
--- a/neuralprophet/time_dataset.py
+++ b/neuralprophet/time_dataset.py
@@ -314,20 +314,12 @@ def tabularize_univariate_datetime(
     inputs = OrderedDict({})
 
     def _stride_time_features_for_forecasts(x):
-        # only for case where n_lags > 0
-        if x.dtype != np.float64:
-            dtype = np.datetime64
-        else:
-            dtype = np.float64
-        return np.array([x[i + max_lags - n_lags : i + max_lags + n_forecasts] for i in range(n_samples)], dtype=dtype)
+        return np.array(
+            [x[i + max_lags - n_lags : i + max_lags + n_forecasts] for i in range(n_samples)], dtype=x.dtype
+        )
 
     def _stride_future_time_features_for_forecasts(x):
-        # only for case where n_lags > 0
-        if x.dtype != np.float64:
-            dtype = np.datetime64
-        else:
-            dtype = np.float64
-        return np.array([x[max_lags + i : max_lags + i + n_forecasts] for i in range(n_samples)], dtype=dtype)
+        return np.array([x[max_lags + i : max_lags + i + n_forecasts] for i in range(n_samples)], dtype=x.dtype)
 
     def _stride_lagged_features(df_col_name, feature_dims):
         # only for case where max_lags > 0


Test patch: