Skip to content

Missing reverse standardization in predict function #13

@Witchcraft-Jasper

Description

@Witchcraft-Jasper

Hello author, I encountered an issue while using your model for time series prediction. In the predict function of exp_main.py, the original code does not reverse the standardization on the data (the default value for scale in dataloader.py is True) when generating the prediction results. This leads to some issues in the final generated results.

To fix this, I added a scale parameter in the execution script to control whether the data should be standardized or not. Additionally, I added the following code at line 366, which resulted in correct prediction results:

      pred = outputs.detach().cpu().numpy()  # .squeeze()

      ## if using scale
      if self.args.scale:
          pred_reshaped = pred.reshape(-1, pred.shape[-1])
          
          # Apply inverse_transform using the saved scaler from Dataset_Pred
          pred_reshaped = pred_loader.dataset.scaler.inverse_transform(pred_reshaped)
          
          # Reshape back to original shape
          pred = pred_reshaped.reshape(pred.shape)  # (batch_size, pred_len, num_features)

      preds.append(pred)

Hopefully, it would be helpful. Thank you for your work on this model!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions