# Font /mnt/font/InputMonoNarrow-Regular/20a/font
# rm(list=ls())
# bookdown::render_book()
# :/^\#
# save.image(file="~/tmp/202301231942.Rdata")
# load(file = "~/tmp/202301231942.Rdata")

# bash make_chapter 19_nystroem_approximation.Rmd

# knitr::purl("05_c_svd_ca.Rmd")

# Extrait de 05_c_svd_ca.Rmd
#
# Affichons encore une carte avec les coordonnées principales sur les dimensions n°1 et n°2, mais uniquement pour les profils lignes et les profils colonnes considérés importants.
#
# ```{r}
# selI <- CTRI > (1/I)
# selI12 <- selI[,1] | selI[,2]
# selJ <- CTRJ > (1/J)
# selJ12 <- selJ[,1] | selJ[,2]
# par(pty="s") # square plotting region
# plot(c(F[selI12,1], G[selJ12,1]), c(F[selI12,2], G[selJ12,2]),
#      main = "x: d1, y: d2", type = "n",
#      xlab="", ylab="", asp = 1, xaxt = "n", yaxt = "n")
# text(c(F[selI12,1], G[selJ12,1]), c(F[selI12,2], G[selJ12,2]),
#      c(rownames(P)[selI12], colnames(P)[selJ12]),
#      adj = 0, cex = 0.6)
# points(0, 0, pch = 3)
# ```

#  source("19_b_nystroem_approximation_housing_experiment_code.R")
#  rdat <- hous.dat.nakr$dat[sample(nrow(hous.dat.nakr$dat), size=2000, replace=FALSE),]
#  X <- rdat[,!(colnames(rdat) %in% c('median_house_value'))]
#  Y <- rdat[,c('median_house_value')]
#  names(Y) <- rownames(X)
#  rsplt <- splitdata(list(X = X, Y = Y), 0.8)
#  X.entr <- rsplt$entr$X
#  Y.entr <- rsplt$entr$Y
#  X.test <- rsplt$test$X
#  Y.test <- rsplt$test$Y
#  source("18_kernel_ridge_regression_code.R")
#  krm <- krr(X.entr, Y.entr)
#  krm.yh <- predict(krm, X.test)
#  krm.mae <- mean(abs(krm.yh - Y.test)) # 35445.1
#  source("15_loocv_code.R")
#  rm <- ridge(X.entr, Y.entr)
#  rm.yh <- predict(rm, X.test)
#  rm.mae <- mean(abs(rm.yh - Y.test)) # 45786.62
#  library(randomForest)
#  rfm <- randomForest(X.entr, Y.entr)
#  rfm.yh <- predict(rfm, X.test)
#  rfm.mae <- mean(abs(rfm.yh - Y.test)) # 34229.02
#  nakrm <- kfold.nakr(X.entr, Y.entr, nb.landmarks=500)
#  nakrm.yh <- predict(nakrm, X.test)
#  nakrm.mae <- mean(abs(nakrm.yh - Y.test)) # 65454.18