Table of Contents

Class CrossValidationResult<T, TInput, TOutput>

Namespace
AiDotNet.Models.Results
Assembly
AiDotNet.dll

Aggregates results from all folds in a cross-validation procedure.

public class CrossValidationResult<T, TInput, TOutput>

Type Parameters

T

The numeric type used for calculations (e.g., float, double).

TInput

The type of input data (e.g., Matrix<T> for tabular data, Tensor<T> for images).

TOutput

The type of output data (e.g., Vector<T> for predictions, custom types for other formats).

Inheritance
CrossValidationResult<T, TInput, TOutput>
Inherited Members

Remarks

For Beginners: Cross-validation helps you understand how well your model will perform on new data by testing it on several different train/test splits. This class combines the results from all those tests to give you an overall picture of your model's performance.

Constructors

CrossValidationResult(List<FoldResult<T, TInput, TOutput>>, TimeSpan)

Creates a new instance of the CrossValidationResult class.

public CrossValidationResult(List<FoldResult<T, TInput, TOutput>> foldResults, TimeSpan totalTime)

Parameters

foldResults List<FoldResult<T, TInput, TOutput>>

The results from each individual fold.

totalTime TimeSpan

The total time taken for the entire cross-validation process.

Remarks

For Beginners: This constructor takes the results from each fold of cross-validation and calculates summary statistics to give you an overall view of how well your model performs. It helps you understand both the average performance and how consistent that performance is across different subsets of your data.

Properties

AdjustedRandIndexStats

Gets basic statistics for Adjusted Rand Index values across folds, or null if not applicable.

public BasicStats<T>? AdjustedRandIndexStats { get; }

Property Value

BasicStats<T>

Remarks

For Beginners: This property contains statistics about how well the clustering matches known ground truth labels across all folds. Values closer to 1 indicate better agreement with the ground truth. This will be null if ground truth labels aren't available or if the model doesn't perform clustering.

AverageTrainingTime

Gets the average time taken to train the model across all folds.

public TimeSpan AverageTrainingTime { get; }

Property Value

TimeSpan

CalinskiHarabaszIndexStats

Gets basic statistics for Calinski-Harabasz Index values across folds, or null if not applicable.

public BasicStats<T>? CalinskiHarabaszIndexStats { get; }

Property Value

BasicStats<T>

Remarks

For Beginners: This property contains statistics about how well-separated and compact clusters are across all folds. Higher values indicate better clustering. This will be null if the model doesn't perform clustering or if the metric couldn't be calculated.

DaviesBouldinIndexStats

Gets basic statistics for Davies-Bouldin Index values across folds, or null if not applicable.

public BasicStats<T>? DaviesBouldinIndexStats { get; }

Property Value

BasicStats<T>

Remarks

For Beginners: This property contains statistics about the average similarity between each cluster and its most similar neighbor across all folds. Lower values indicate better clustering (more distinct clusters). This will be null if the model doesn't perform clustering or if the metric couldn't be calculated.

FeatureImportanceStats

Gets a dictionary of feature importance scores aggregated across all folds.

public Dictionary<string, BasicStats<T>> FeatureImportanceStats { get; }

Property Value

Dictionary<string, BasicStats<T>>

FoldCount

Gets the number of folds used in cross-validation.

public int FoldCount { get; }

Property Value

int

FoldResults

Gets the individual results for each fold.

public List<FoldResult<T, TInput, TOutput>> FoldResults { get; }

Property Value

List<FoldResult<T, TInput, TOutput>>

MAEStats

Gets basic statistics for MAE values across folds.

public BasicStats<T> MAEStats { get; }

Property Value

BasicStats<T>

R2Stats

Gets basic statistics (mean, standard deviation, etc.) for R² values across folds.

public BasicStats<T> R2Stats { get; }

Property Value

BasicStats<T>

RMSEStats

Gets basic statistics for RMSE values across folds.

public BasicStats<T> RMSEStats { get; }

Property Value

BasicStats<T>

SilhouetteScoreStats

Gets basic statistics for Silhouette Score values across folds, or null if not applicable.

public BasicStats<T>? SilhouetteScoreStats { get; }

Property Value

BasicStats<T>

Remarks

For Beginners: When cross-validating clustering algorithms, this property contains statistics about how well items fit into their assigned clusters across all folds. Higher values (closer to 1) indicate better clustering quality. This will be null if the model doesn't perform clustering or if clustering metrics couldn't be calculated.

TotalTime

Gets the total time taken for the entire cross-validation process.

public TimeSpan TotalTime { get; }

Property Value

TimeSpan

Methods

GenerateReport()

Generates a comprehensive summary report of the cross-validation results.

public string GenerateReport()

Returns

string

A string containing the summary report.

Remarks

For Beginners: This method creates a human-readable report that summarizes how well your model performed across all folds of cross-validation. It includes key metrics, their variability, and feature importance information.

GetMetricStats(MetricType)

Gets summary statistics for a specific metric across all folds.

public BasicStats<T> GetMetricStats(MetricType metricType)

Parameters

metricType MetricType

The type of the metric to analyze.

Returns

BasicStats<T>

Basic statistics for the specified metric.

Remarks

For Beginners: This method lets you get statistics (mean, standard deviation, etc.) for any metric across all folds. It helps you understand not just the average performance, but also how consistent that performance is across different data splits.

Exceptions

ArgumentException

Thrown when an invalid metric type is provided.