Learn R Programming

sits (version 1.12.0)

sits_cluster_clean: Cluster cleaner

Description

Removes sits tibble samples of labels that are minority in each cluster. The function removes samples according to a percentage threshold "min_perc". If the method "intracluster" is chosen, the "min_perc" parameter controls the relative percentage of labels inside each cluster. If the number of samples of a given label inside a cluster are below this limit, then all those label samples are removed from that cluster. If the method "intercluster" is set, the "min_perc" parameter is a threshold that controls the minimum percentage of each label in all clusters. If the percentage of samples of a label in a cluster is less than this "min_perc", all thise label samples are removed from that cluster.

Usage

sits_cluster_clean(data.tb, min_perc = 0.05, method = "intracluster")

Arguments

data.tb

Tibble with `cluster` column.

min_perc

Minimum percentage of label inside a cluster for the label to remain in cluster.

method

String with "intracluster" or "intercluster" or both

Value

A tibble with all selected samples.

Examples

Run this code
# NOT RUN {
# Load the "dtwclust" package
library(dtwclust)
# load a simple data set with two classes
data(cerrado_2classes)
# calculate the dendrogram
dendro <- sits_dendrogram (cerrado_2classes, bands = c("ndvi"))
# create 6 clusters by cutting the dendrogram
clusters.tb <- sits_cluster(cerrado_2classes, dendro, k = 6)
# show clusters samples frequency
sits_cluster_frequency(clusters.tb)
# clear those clusters that are less that 25% of each cluster
cleaned.tb <- sits_cluster_clean(clusters.tb, min_perc = 0.25)
# show clusters samples frequency
sits_cluster_frequency(cleaned.tb)
# }

Run the code above in your browser using DataLab