Learn R Programming

sits (version 1.5.3)

sits_accuracy: Assess classification accuracy

Description

This function calculates the accuracy of the classification result. The input is either a set of classified time series or a classified data cube. Classified time series are produced by sits_classify. Classified images are generated using sits_classify followed by sits_label_classification.

For a set of time series, sits_accuracy creates a confusion matrix and calculates the resulting statistics using package caret. For a classified image, the function uses an area-weighted technique proposed by Olofsson et al. according to references [1-3] to produce reliable accuracy estimates at 95% confidence level. In both cases, it provides an accuracy assessment of the classified, including Overall Accuracy, Kappa, User's Accuracy, Producer's Accuracy and error matrix (confusion matrix).

Usage

sits_accuracy(data, ...)

# S3 method for sits sits_accuracy(data, ...)

# S3 method for class_vector_cube sits_accuracy(data, ..., prediction_attr, reference_attr)

# S3 method for class_cube sits_accuracy(data, ..., validation, method = "olofsson")

# S3 method for raster_cube sits_accuracy(data, ...)

# S3 method for derived_cube sits_accuracy(data, ...)

# S3 method for tbl_df sits_accuracy(data, ...)

# S3 method for default sits_accuracy(data, ...)

Value

A list of lists: The error_matrix, the class_areas, the unbiased estimated areas, the standard error areas, confidence interval 95

and the accuracy (user, producer, and overall), or NULL if the data is empty. The result is assigned to class "sits_accuracy" and can be visualized directly on the screen.

Arguments

data

Either a data cube with classified images or a set of time series

...

Specific parameters

prediction_attr

Name of the column of the segments object that contains the predicted values (only for vector class cubes)

reference_attr

Name of the column of the segments object that contains the reference values (only for vector class cubes)

validation

Samples for validation (see below) Only required when data is a raster class cube.

method

A character with 'olofsson' or 'pixel' to compute accuracy (only for raster class cubes)

Author

Rolf Simoes, rolfsimoes@gmail.com

Alber Sanchez, alber.ipia@inpe.br

References

[1] Olofsson, P., Foody, G.M., Stehman, S.V., Woodcock, C.E. (2013). Making better use of accuracy data in land change studies: Estimating accuracy and area and quantifying uncertainty using stratified estimation. Remote Sensing of Environment, 129, pp.122-131.

[2] Olofsson, P., Foody G.M., Herold M., Stehman, S.V., Woodcock, C.E., Wulder, M.A. (2014) Good practices for estimating area and assessing accuracy of land change. Remote Sensing of Environment, 148, pp. 42-57.

[3] FAO, Map Accuracy Assessment and Area Estimation: A Practical Guide. National forest monitoring assessment working paper No.46/E, 2016.

Examples

Run this code
if (sits_run_examples()) {
    # show accuracy for a set of samples
    train_data <- sits_sample(samples_modis_ndvi, frac = 0.5)
    test_data <- sits_sample(samples_modis_ndvi, frac = 0.5)
    rfor_model <- sits_train(train_data, sits_rfor())
    points_class <- sits_classify(
        data = test_data, ml_model = rfor_model
    )
    acc <- sits_accuracy(points_class)

    # show accuracy for a data cube classification
    # create a random forest model
    rfor_model <- sits_train(samples_modis_ndvi, sits_rfor())
    # create a data cube from local files
    data_dir <- system.file("extdata/raster/mod13q1", package = "sits")
    cube <- sits_cube(
        source = "BDC",
        collection = "MOD13Q1-6.1",
        data_dir = data_dir
    )
    # classify a data cube
    probs_cube <- sits_classify(
        data = cube, ml_model = rfor_model, output_dir = tempdir()
    )
    # label the probability cube
    label_cube <- sits_label_classification(
        probs_cube,
        output_dir = tempdir()
    )
    # obtain the ground truth for accuracy assessment
    ground_truth <- system.file("extdata/samples/samples_sinop_crop.csv",
        package = "sits"
    )
    # make accuracy assessment
    as <- sits_accuracy(label_cube, validation = ground_truth)
}

Run the code above in your browser using DataLab