Ali Amma
Ali Amma

Reputation: 43

multi time step forecasting for next 24 H ahead using XGBoost

My project is multi time step forecasting for next 24 H ahead using XGBoost.

The below two figures are the results:

enter image description here enter image description here

Why the test data as in first fig, is different than the second fig (orange one), it should be the same?

from sklearn.metrics import mean_squared_error, mean_absolute_error
import numpy as np

# Inverse transform the predictions and the test data (if scaled)
y_pred_actual = scaler_y.inverse_transform(y_pred.reshape(-1, 1)) # Ensure shape is 
(-1, 
   1)
  y_test_inv = scaler_y.inverse_transform(y_test)

# Calculate metrics
mse = mean_squared_error(y_test_inv, y_pred_actual)
mae = mean_absolute_error(y_test_inv, y_pred_actual)
rmse = np.sqrt(mse)
mpe = np.mean((y_test_inv - y_pred_actual) / y_test_inv) * 100

# Calculate MAPE
mape = np.mean(np.abs((y_test_inv - y_pred_actual) / y_test_inv)) * 100

# Print the evaluation metrics
print('')
 print('---------------------------------------------------')
print(f'TL_model_loaded MAE for test set : {round(mae, 3)}')
print(f'TL_model_loaded MSE for test set : {round(mse, 3)}')
print(f'TL_model_loaded RMSE for test set : {round(rmse, 3)}')
print(f'TL_model_loaded MPE for test set : {round(mpe, 3)} %')
print(f'TL_model_loaded MAPE for test set : {round(mape, 3)} %')
print('---------------------------------------------------')
print('')

# Call the plot_results_xgboost function
plot_results_xgboost(y_pred_actual, y_test_inv, evals_result, 'XG')

Upvotes: 0

Views: 34

Answers (0)

Related Questions