Learn R Programming

sits (version 1.4.0)

sits_combine_predictions: Estimate ensemble prediction based on list of probs cubes

Description

Calculate an ensemble predictor based a list of probability cubes. The function combines the output of two or more classifier to derive a value which is based on weights assigned to each model. The supported types of ensemble predictors are 'average' and 'uncertainty'.

Usage

sits_combine_predictions(
  cubes,
  type = "average",
  ...,
  memsize = 8,
  multicores = 2,
  output_dir,
  version = "v1"
)

# S3 method for average sits_combine_predictions( cubes, type = "average", ..., weights = NULL, memsize = 8, multicores = 2, output_dir, version = "v1" )

# S3 method for uncertainty sits_combine_predictions( cubes, type = "uncertainty", ..., uncert_cubes, memsize = 8, multicores = 2, output_dir, version = "v1" )

Value

A combined probability cube

Arguments

cubes

List of probability data cubes.

type

Method to measure uncertainty. See details.

...

Parameters for specific functions.

memsize

Maximum overall memory (in GB) to run the function.

multicores

Number of cores to run the function.

output_dir

Output directory for image files.

version

Version of resulting image. (in the case of multiple tests)

weights

Weights for averaging

uncert_cubes

Uncertainty cubes to be used as local weights.

Author

Gilberto Camara, gilberto.camara@inpe.br

Rolf Simoes, rolf.simoes@inpe.br

Examples

Run this code
if (sits_run_examples()) {
    # create a data cube from local files
    data_dir <- system.file("extdata/raster/mod13q1", package = "sits")
    cube <- sits_cube(
        source = "BDC",
        collection = "MOD13Q1-6",
        data_dir = data_dir
    )
    # create a random forest model
    rfor_model <- sits_train(samples_modis_ndvi, sits_rfor())
    # classify a data cube using rfor model
    probs_rfor_cube <- sits_classify(
        data = cube, ml_model = rfor_model, output_dir = tempdir(),
        version = "rfor"
    )
    # create an XGBoost model
    tcnn_model <- sits_train(samples_modis_ndvi, sits_tempcnn())
    # classify a data cube using tempcnn model
    probs_tcnn_cube <- sits_classify(
        data = cube, ml_model = tcnn_model, output_dir = tempdir(),
        version = "tcnn"
    )
    # create a list of predictions to be combined
    pred_cubes <- list(probs_rfor_cube, probs_tcnn_cube)
    # combine predictions
    comb_probs_cube <- sits_combine_predictions(
        pred_cubes, output_dir = tempdir()
    )
    # plot the resulting combined prediction cube
    plot(comb_probs_cube)
}

Run the code above in your browser using DataLab