knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)

library(dplyr)
library(ggplot2)
library(kableExtra)
library(knitr)
library(purrr)
library(tidyr)
library(sits.prodes)
library(xtable)

Training

Experiment summary

data("training_logs", package = "sits.prodes")
na_remover <- function(x){return(trimws(gsub("NA", "", x[!is.na(x)])))}
training_logs %>% tidyr::unnest(setup) %>%
    dplyr::mutate(bands = na_remover(paste(Bands_experiment, Bands__experiment))) %>%
    dplyr::mutate(labels = na_remover(paste(Labels, Labels_experiment))) %>%
    dplyr::select(experiment, Clasification_type, labels, bands, Scenes_experiment) %>%
    knitr::kable() %>%
    kableExtra::kable_styling(full_width = F)

Training results

plot_tb <- training_logs %>% tidyr::unnest(trains) %>% 
    dplyr::select(experiment, model_name, acc, loss, val_acc, val_loss) %>%
    dplyr::mutate(acc  = purrr::map(acc,  function(x) eval(parse(text = x))),
                  loss = purrr::map(loss, function(x) eval(parse(text = x))),
                  val_acc  = purrr::map(val_acc, function(x) eval(parse(text = x))),
                  val_loss = purrr::map(val_loss, function(x) eval(parse(text = x))), 
                  val_acc_mean = purrr::map_dbl(val_acc, mean)) 

#plot_tb %>% dplyr::select(experiment, model_name, val_acc_mean) %>%
#    knitr::kable() %>% kableExtra::kable_styling(full_width = F)


# plot_ls <- lapply(unique(plot_tb$experiment), function(exp){
#   plot_tb %>% dplyr::filter(experiment %in% exp) %>% tidyr::unnest() %>%
#     dplyr::group_by(model_name) %>% dplyr::mutate(epoch = row_number()) %>% 
#     ggplot2::ggplot() +
#     ggplot2::geom_path(aes(y = acc, x = epoch), colour = "blue") +
#     ggplot2::geom_path(ggplot2::aes(y = val_acc, x = epoch)) +
#     ggplot2::ggtitle(exp) +
#     ggplot2::ylim(0.95, 1.0) +
#     #ggplot2::theme(plot.title = element_text(size = 8)) +
#     ggplot2::labs(x = "Epochs", y = "Accuracy") + 
#     ggplot2::facet_wrap(~ model_name, nrow = 5) %>%
#     return()
# })


plot_ls <- lapply(unique(plot_tb$experiment), function(exp){
    plot_tb %>% 
        dplyr::filter(experiment %in% exp) %>% 
        tidyr::unnest() %>%
        dplyr::group_by(model_name) %>% 
        dplyr::mutate(epoch = row_number()) %>%
        ggplot2::ggplot() +
        ggplot2::geom_path(aes(y = loss, x = epoch), colour = "blue") +
        ggplot2::geom_path(ggplot2::aes(y = val_loss, x = epoch)) +
        ggplot2::ggtitle(exp) +
        ggplot2::ylim(0.0, 0.25) +
        #ggplot2::theme(plot.title = element_text(size = 8)) +
        ggplot2::labs(x = "Epochs", y = "Loss") +
        ggplot2::facet_wrap(~ model_name, nrow = 5) %>%
        return()
})



for(p in plot_ls)
    suppressWarnings(print(p))

selected trainings

Bias and variance

Bias and variance

One way to understand overfitting is by decomposing generalization error into bias and variance. Bias is a learner’s tendency to consistently learn the same wrong thing. Variance is the tendency to learn random things irrespective of irrespective of the real signal - [@Domingos:2012]

Source: Machine Learning — Andrew Ng, Stanford University [FULL COURSE]

The loss function takes the predictions of the network and the true target (what you wanted the network to output) and computes a distance score, capturing how well the network has done on this specific example. - [@Chollet:2018]

Two quantities are displayed during training: the loss of the network over the training data, and the accuracy of the network over the training data. - [@Chollet:2018]

[The] gap between training accuracy and test accuracy is an example of overfitting - [@Chollet:2018]

References



albhasan/sits.prodes documentation built on Sept. 3, 2020, 2:03 p.m.