|
|
lucid
0.0.1
Lifting-based Uncertain Control Invariant Dynamics
|
Generic K-Fold cross-validation, where the dataset is divided into k folds.
More...
#include <KFold.h>
Public Member Functions | |
| KFold (Dimension num_folds=5, bool shuffle=true) | |
| Construct a new KFold cross-validator with the specified number of folds. | |
| Dimension | num_folds (ConstMatrixRef training_inputs) const override |
| Get the number of folds used in cross-validation. | |
| Dimension | num_folds () const |
| Get read-only access to the num_folds of the the cross-validation. | |
| bool | shuffle () const |
| Check whether the to be shuffled before being split into folds is data. | |
| std::string | to_string () const override |
| Obtain the string representation of this object. | |
Public Member Functions inherited from lucid::CrossValidator | |
| double | fit (Estimator &estimator, ConstMatrixRef training_inputs, ConstMatrixRef training_outputs, const scorer::Scorer &scorer=nullptr) const |
Fit the estimator using cross-validation on the provided training_inputs and training_outputs. | |
| double | fit (Estimator &estimator, ConstMatrixRef training_inputs, ConstMatrixRef training_outputs, const Tuner &tuner, const scorer::Scorer &scorer=nullptr) const |
Fit the estimator using cross-validation on the provided training_inputs and training_outputs using the tuner tuner to optimize @hp. | |
| std::vector< double > | score (const Estimator &estimator, ConstMatrixRef inputs, ConstMatrixRef outputs, const scorer::Scorer &scorer=nullptr) const |
Evaluate the estimator using cross-validation on the provided inputs and outputs. | |
Private Member Functions | |
| std::pair< SliceSelector, SliceSelector > | compute_folds (ConstMatrixRef training_inputs) const override |
| Compute the training and validation folds for cross-validation. | |
Private Attributes | |
| Dimension | num_folds_ |
| Number of folds to use in cross-validation. | |
| bool | shuffle_ |
| Whether to shuffle the data before splitting into folds. | |
Additional Inherited Members | |
Public Types inherited from lucid::CrossValidator | |
| using | SliceSelector = std::vector<std::vector<Index>> |
| Type alias for slice selector. | |
Protected Member Functions inherited from lucid::CrossValidator | |
| double | fit (Estimator &estimator, ConstMatrixRef training_inputs, ConstMatrixRef training_outputs, const Tuner *tuner, const scorer::Scorer &scorer) const |
Fit the estimator using cross-validation on the provided training_inputs and training_outputs using the tuner tuner to optimize @hp, if provided. | |
Generic K-Fold cross-validation, where the dataset is divided into k folds.
The model is trained k times, each time using k-1 folds for training and the remaining fold for validation. The final model is the one that achieved the best validation score across all folds. This technique helps to mitigate overfitting and provides a more robust estimate of the model's performance.
---
title: "K fold [k = 4]"
config:
packet:
bitWidth: 64
bitsPerRow: 12
showBits: false
---
packet
+9: "Training"
+3: "Validation"
+6: "Training"
+3: "Validation"
+3: "Training"
+3: "Training"
+3: "Validation"
+6: "Training"
+3: "Validation"
+9: "Training"
|
explicit |
Construct a new KFold cross-validator with the specified number of folds.
num_folds must be at least 2 | num_folds | number of folds to use in cross-validation |
| shuffle | whether to shuffle the data before splitting into folds |
|
nodiscardoverrideprivatevirtual |
Compute the training and validation folds for cross-validation.
Each fold is represented as a pair of index vectors, where the first vector contains the indices for the training set and the second vector contains the indices for the validation set.
| training_inputs | \( \texttip{n}{Number of samples} \times \texttip{d_x}{Dimension of the input vector space} \) training input data |
Implements lucid::CrossValidator.
|
inlinenodiscard |
Get read-only access to the num_folds of the the cross-validation.
|
nodiscardoverridevirtual |
Get the number of folds used in cross-validation.
In KFold cross-validation, the dataset is divided into the number of folds specified during construction.
training_inputs must be at least equal to the number of folds | training_inputs | \( \texttip{n}{Number of samples} \times \texttip{d_x}{Dimension of the input vector space} \) training input data |
Implements lucid::CrossValidator.
|
inlinenodiscard |
Check whether the to be shuffled before being split into folds is data.
|
nodiscardoverridevirtual |
Obtain the string representation of this object.
Reimplemented from lucid::CrossValidator.