/
ff_predict: Predicting deforestation

ff_predict: Predicting deforestation

The ff_predict function is designed to make predictions using a trained XGBoost model from the ForestForesight algorithm. It can handle both loaded models and model file paths, applies the model to test data, and can optionally create a predicted raster. The function also calculates performance metrics if ground truth data is provided.

Exercises

  1. Basic Usage:
    Make predictions using a trained model and test data.

library(ForestForesight) # Assume we have a trained model and prepared test data model <- ... # Trained model from ff_train test_data <- ff_prep(...) # Prepare test data predictions <- ff_predict( model = model, test_matrix = test_data$data_matrix, verbose = TRUE ) print(head(predictions$predictions))
  1. Using a Saved Model File:
    Load a model from a file and make predictions.

predictions <- ff_predict( model = "path/to/my_deforestation_model.model", test_matrix = test_data$data_matrix, verbose = TRUE ) print(summary(predictions$predictions))
  1. Adjusting the Threshold:
    Experiment with different probability thresholds for binary classification.

predictions <- ff_predict( model = model, test_matrix = test_data$data_matrix, threshold = 0.7, verbose = TRUE ) print(table(predictions$predicted_raster[] > 0.7))
  1. Performance Evaluation:
    Use ground truth data to evaluate model performance.

  1. Creating a Predicted Raster:
    Generate a spatial raster of predictions.

  1. Generating Probability Maps:
    Create a raster of deforestation probabilities instead of binary classification.

These exercises will help you understand how to use the ff_predict function to make predictions with trained ForestForesight models, evaluate model performance, and create spatial predictions. Remember to replace the placeholder data (like model and test_data) with actual trained models and prepared data from your ForestForesight workflow.

Related content

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_train: training a model
ff_train: training a model
More like this
Building your own predictions (Open Source)
Building your own predictions (Open Source)
More like this
ff_analyze: Analyzing the results
ff_analyze: Analyzing the results
More like this
Technical Deep Dive
Technical Deep Dive
More like this
ff_prep: data preparation
ff_prep: data preparation
More like this