/
ff_train: training a model

ff_train: training a model

The ff_train function is designed to train an XGBoost model for deforestation prediction using the ForestForesight algorithm. It takes prepared data (usually from ff_prep), sets up the XGBoost parameters, trains the model, and optionally saves it. The function allows for customization of various XGBoost parameters and supports both training and validation data.

Exercises

  1. Basic Usage:
    Train a simple model using prepared data from ff_prep.

library(ForestForesight) # Assume we have already prepared data using ff_prep prepared_data <- ff_prep(...) model <- ff_train( train_matrix = prepared_data$data_matrix, nrounds = 100, verbose = TRUE ) print(model)
  1. Using Validation Data:
    Train a model with separate validation data for early stopping.

prepared_data <- ff_prep(..., validation_sample = 0.2) model <- ff_train( train_matrix = prepared_data$data_matrix, validation_matrix = prepared_data$validation_matrix, nrounds = 300, early_stopping_rounds = 20, verbose = TRUE ) print(model$best_iteration) print(model$best_score)
  1. Customizing XGBoost Parameters:
    Experiment with different XGBoost parameters to optimize the model.

model <- ff_train( train_matrix = prepared_data$data_matrix, eta = 0.05, max_depth = 7, subsample = 0.8, min_child_weight = 2, eval_metric = "auc", verbose = TRUE ) print(model$params)
  1. Saving the Model:
    Train a model and save it to a file for later use.

  1. Continue Training from a Saved Model:
    Load a previously saved model and continue training it with new data.

These exercises will help you understand how to use the ff_train function to train XGBoost models for deforestation prediction, experiment with different parameters, and manage model saving and updating. Remember to replace the ff_prep(...) calls with actual data preparation steps using your ForestForesight data.

Related content

ff_predict: Predicting deforestation
ff_predict: Predicting deforestation
More like this
ff_run: using the Forest Foresight package for training and predicting
ff_run: using the Forest Foresight package for training and predicting
More like this
ff_prep: data preparation
ff_prep: data preparation
More like this
ff_analyze: Analyzing the results
ff_analyze: Analyzing the results
More like this
Downloading Forest Foresight data
Downloading Forest Foresight data
More like this
Installing the Forest Foresight package
Installing the Forest Foresight package
More like this