Skip to contents

Folds 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
)

Arguments

X, y

Data.

K

Folds, 2 <= K <= m.

fit, predict, score

Optional callables.

shuffle

Must be FALSE.

random_state

Ignored.

Value

List with cv_score, fold_scores, fold_sizes, se, worst_fold, spread.

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"
#>