intro_to_ml/pad.R

52 lines
1.5 KiB
R

# Font /mnt/font/InputMonoNarrow-Regular/20a/font
# rm(list=ls())
# bookdown::render_book()
# :/^\#
# 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("01_intro_code.R")
source("04_validation_croisee_code.R")
set.seed(1123)
n <- 100
data = gendat(n,0.2)
splitres <- splitdata(data,0.8)
entr <- splitres$entr
test <- splitres$test
# K11 <- gausskernel(as.matrix(X[splidx,]), sigma2)
#
# K21 <- matrix(nrow = n-nspl, ncol = nspl)
# for(i in 1:(n-nspl))
# for(j in 1:nspl)
# K21[i,j] <- sum(X[notsplidx[i],] - X[splidx[j],])^2
# K21 <- exp(-1*K21/sigma2)
source("19_nystroem_approximation_code.R")
krm <- nakrr(entr$X, entr$Y, nspl=15)
yh <- predict(krm,test$X)
plt(test,f)
points(test$X, yh, pch=4)
# coef2 <- coef[order(strtoi(rownames(coef)))]