
K-fold cross-validation score (Geron Ch 1/2, morie.fn grcvs)
Source:R/geron_ml_native.R
morie_geron_cross_validation_score.RdFolds follow numpy's array_split: the first m %% K folds get one extra
row. Default model is OLS via minimum-norm least squares, scored by
R^2. shuffle is not supported, because numpy's default_rng stream
cannot be reproduced in R – passing TRUE is an error rather than a
silently different split.
Usage
morie_geron_cross_validation_score(
X,
y,
K,
fit = NULL,
predict = NULL,
score = NULL,
shuffle = FALSE,
random_state = NULL
)Examples
morie_geron_cross_validation_score(X = c(1, 2, 3, 4, 5, 6, 7, 8),
y = c(1, 2, 3, 4, 5, 6, 7, 8), K = 3L)
#> $cv_score
#> [1] 1
#>
#> $fold_scores
#> [1] 1 1 1
#>
#> $fold_sizes
#> [1] 3 3 2
#>
#> $se
#> [1] 0
#>
#> $worst_fold
#> [1] 0
#>
#> $spread
#> [1] 0
#>
#> $K
#> [1] 3
#>
#> $estimate
#> [1] 1
#>
#> $n
#> [1] 8
#>
#> $method
#> [1] "K-fold cross-validation"
#>