
Batch (offline) learning by closed-form least squares (Geron Ch 1, hmbat)
Source:R/geron_ml_native.R
morie_geron_batch_learning.RdRidge leaves the intercept unpenalised. The returned predict closure
is frozen: new data needs a full retrain, which is what "offline" means.
Examples
V <- c(1, 2, 3, 4, 5, 6, 7, 8)
morie_geron_batch_learning(V, V)
#> $theta
#> [1] 1
#>
#> $predict
#> function (Xnew)
#> {
#> A <- if (is.matrix(Xnew))
#> Xnew
#> else matrix(as.numeric(Xnew), nrow = 1)
#> storage.mode(A) <- "double"
#> .morie_gr_need(ncol(A) == nfeat, "predict: feature count mismatch")
#> if (fit_intercept)
#> A <- cbind(1, A)
#> as.numeric(A %*% theta)
#> }
#> <environment: 0x56217ab6ba98>
#>
#> $fitted
#> [1] 1 2 3 4 5 6 7 8
#>
#> $residuals
#> [1] 0 0 0 0 0 0 0 0
#>
#> $train_mse
#> [1] 0
#>
#> $r2
#> [1] 1
#>
#> $estimate
#> [1] 0
#>
#> $n
#> [1] 8
#>
#> $method
#> [1] "Batch learning: closed-form minimisation of the full-dataset squared-error loss"
#>