Assessment_via_cluster: Calculate error metrics for all algorithm per cluster

Description Usage Arguments Value Note See Also Examples

View source: R/Algorithms_assessment.R

Description

Calculate error metrics for all algorithm per cluster

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
Assessment_via_cluster(
  pred,
  meas,
  memb,
  metrics = c("MAE", "MAPE"),
  log10 = FALSE,
  total = TRUE,
  hard.mode = TRUE,
  cal.precision = FALSE,
  valid.definition = list(negative = FALSE, percent = 0.6),
  na.process = FALSE,
  plot.col = FALSE
)

Arguments

pred

prediction of Chla

meas

in-situ measurement of Chla

memb

membership value matrix

metrics

metrics need to be calculated

log10

Should pred and meas be log10-transformed? (default as FALSE)

total

Whether to calculate summarized metrics (default as TRUE)

hard.mode

If FALSE, the membership values are used to calculate validation metrics

cal.precision

Whether to calculate precision (only support for vectorized metrics), default as FALSE

valid.definition

The definition of valid prediction, default as list(negative=FALSE, percent = 0.6). The invalid prediction will not be removed to calculate error metrics.

negative=FALSE means the negative values are considered as invalid predictions while percent means the tolerance of error-percentage that only the predictions between (y-y*percent), y+y*percent) are valid.

na.process

na.process and choose to statistic NA value percent

plot.col

option to plot col result for selected metrics (default as FALSE)

Value

Results of Assessment_via_cluster are returned as a list including:

Metrcs

A list of the selected metric values for all algorithms. Valid_percent would be included if na.process are set as TRUE

res_plot

Bar plots by using ggplot function for metrics value at every cluster.

res_plot_dt

Dataframe for plotting res_plot. I just keep it in case of plotting other types

res_plot_facet

res_plot added on facet_wrap.

input

input parameters of Assessment_via_cluster

Note

If the cal.precision is TRUE, the hard.mode == TRUE is used. In that case, mean and sd calculation is conducted for hard mode based on result from cal.metrics.vector.

See Also

Other Algorithm assessment: Getting_Asses_results(), Sampling_via_cluster(), Score_algorithms_interval(), Score_algorithms_sort(), Scoring_system()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
library(FCMm) 
library(ggplot2) 
library(magrittr)
library(stringr)
data("Nechad2015")
x <- Nechad2015[,3:11]
wv <- gsub("X","",names(x)) %>% as.numeric
set.seed(1234)
w <- sample(1:nrow(x), 100) 
x <- x[w, ]
names(x) <- wv
nb = 4 # Obtained from the vignette "Cluster a new dataset by FCMm"
set.seed(1234)
FD <- FuzzifierDetermination(x, wv, stand=FALSE)
result <- FCM.new(FD, nb, fast.mode = TRUE)
p.spec <- plot_spec(result, show.stand=TRUE)
print(p.spec$p.cluster.spec)
Chla <- Nechad2015$X.Chl_a..ug.L.[w]
Chla[Chla >= 999] <- NA
dt_Chla <- run_all_Chla_algorithms(x) %>% as.data.frame
dt_Chla <- data.frame(Chla_true = Chla, 
BR_Gil10 = dt_Chla$BR_Gil10, 
OC4_OLCI = dt_Chla$OC4_OLCI, 
OCI_Hu12 = dt_Chla$OCI_Hu12, 
NDCI_Mi12= dt_Chla$NDCI_Mi12) %>% round(3)
w = which(!is.na(dt_Chla$Chla_true))
dt_Chla = dt_Chla[w,]
memb = result$res.FCM$u[w,] %>% round(4)
Asses_soft <- Assessment_via_cluster(pred = dt_Chla[,-1], 
meas = dt_Chla[,1], memb = memb, log10 = TRUE, hard.mode = FALSE, 
na.process = TRUE, plot.col = TRUE)
Asses_soft$res_plot_facet
knitr::kable(Asses_soft$MAE %>% round(3))
knitr::kable(Asses_soft$MAPE %>% round(2))

bishun945/FCMm documentation built on Oct. 15, 2021, 6:43 p.m.