Uses machine learning algorithms to forecast climate variables from simulated climate data.

forecasting_ml(
  climate_data,
  target = "Rainfall",
  predictors = c("Tmin", "Tmax", "Avg.Temp", "RH", "WindSpeed", "Solar_Radiation", "ET0"),
  forecast_horizon = 12,
  start_forecast = NULL,
  end_forecast = NULL,
  method = c("rf", "lm", "gbm", "arima", "xgboost", "nnet", "all"),
  frequency = c("month", "day", "year"),
  train_fraction = 0.8,
  include_lag = TRUE,
  lag_period = 1,
  ntree = 500,
  hidden_nodes = 5,
  digits = 2,
  seed = 123
)

Arguments

climate_data

Climate dataframe.

target

Variable to forecast.

predictors

Predictor variables.

forecast_horizon

Number of future periods.

start_forecast

Optional forecast start date. Must be coercible to Date.

end_forecast

Optional forecast end date. Must be coercible to Date.

If supplied, forecast_horizon is automatically calculated.

method

Forecasting method.

frequency

Forecast interval. Options are: "day", "month", "year".

train_fraction

Fraction of data for training.

include_lag

Logical. Include lag predictor.

lag_period

Lag size.

ntree

Number of trees for RF and GBM.

hidden_nodes

Number of hidden nodes for neural network.

digits

Decimal places.

seed

Random seed for reproducibility.

Value

A list containing:

forecast_data

Forecasted future values.

model_performance

RMSE, MAE, and correlation.

importance

Variable importance table.

model

Trained ML model.

all_results

Returned only when method = "all".

Details

Supported methods:

  • Random Forest ("rf")

  • Linear Regression ("lm")

  • Gradient Boosting ("gbm")

  • ARIMA Time-Series ("arima")

  • Extreme Gradient Boosting ("xgboost")

  • Neural Network ("nnet")

  • Run All Models ("all")