lucid  0.0.1
Lifting-based Uncertain Control Invariant Dynamics
Loading...
Searching...
No Matches
lucid::LeaveOneOut Class Referencefinal

Leave-One-Out cross-validation (LOOCV) is a specific type of cross-validation where the number of folds equals the number of data points in the dataset. More...

#include <LeaveOneOut.h>

Inheritance diagram for lucid::LeaveOneOut:
lucid::CrossValidator

Public Member Functions

Dimension num_folds (ConstMatrixRef training_inputs) const override
 In the Leave-One-Out cross-validation (LOOCV) strategy, the number of folds is equal to the number of samples in the dataset, i.e., \( n \).
 
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, SliceSelectorcompute_folds (ConstMatrixRef training_inputs) const override
 Compute the training and validation folds for cross-validation.
 

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.
 

Detailed Description

Leave-One-Out cross-validation (LOOCV) is a specific type of cross-validation where the number of folds equals the number of data points in the dataset.

In LOOCV, each data point is used once as a validation set while the remaining data points form the training set. This means that for a dataset with n samples, the model is trained n times, each time leaving out one sample for validation. LOOCV is particularly useful for small datasets, as it maximizes the amount of training data used in each iteration. However, it can be computationally expensive for large datasets due to the high number of training iterations required. Moreover, LOOCV can lead to high variance in the model's performance estimate, as each training set is very similar to the others, differing by only one sample.

---
title: "Leave one out"
config:
    packet:
        bitWidth: 64
        bitsPerRow: 10
        showBits: false
---
packet
+9: "Training"
+1: "Validation"
+8: "Training"
+1: "Validation"
+1: "Training"
+10: "..."
+1: "Training"
+1: "Validation"
+8: "Training"
+1: "Validation"
+9: "Training"

Member Function Documentation

◆ compute_folds()

std::pair< LeaveOneOut::SliceSelector, LeaveOneOut::SliceSelector > lucid::LeaveOneOut::compute_folds ( ConstMatrixRef training_inputs) const
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.

Parameters
training_inputs\( \texttip{n}{Number of samples} \times \texttip{d_x}{Dimension of the input vector space} \) training input data
Returns
pair of slice selectors for training and validation folds

Implements lucid::CrossValidator.

◆ num_folds()

Dimension lucid::LeaveOneOut::num_folds ( ConstMatrixRef training_inputs) const
inlinenodiscardoverridevirtual

In the Leave-One-Out cross-validation (LOOCV) strategy, the number of folds is equal to the number of samples in the dataset, i.e., \( n \).

Parameters
training_inputs\( \texttip{n}{Number of samples} \times \texttip{d_x}{Dimension of the input vector space} \) training input data
Returns
number of folds (equal to the number of samples in the dataset)

Implements lucid::CrossValidator.

◆ to_string()

std::string lucid::LeaveOneOut::to_string ( ) const
nodiscardoverridevirtual

Obtain the string representation of this object.

Returns
string representation of this object

Reimplemented from lucid::CrossValidator.


The documentation for this class was generated from the following files: