Table of Contents

Class ValidationHelper<T>

Namespace
AiDotNet.Helpers
Assembly
AiDotNet.dll

Provides validation methods for AI model inputs and parameters.

public static class ValidationHelper<T>

Type Parameters

T

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

Inheritance
ValidationHelper<T>
Inherited Members

Remarks

For Beginners: This helper class ensures that the data you provide to AI models is valid and properly formatted. It can handle both traditional matrix/vector inputs (for regression-like models) and tensor inputs (for neural networks). Think of it as a quality control checkpoint that prevents errors before they happen by checking that your data meets all the requirements needed for successful model training and prediction.

Methods

GetCallerInfo(int)

Gets information about the calling method.

public static (string component, string operation) GetCallerInfo(int skipFrames = 2)

Parameters

skipFrames int

Number of frames to skip in the stack trace.

Returns

(string component, string operation)

A tuple containing the component name and operation name.

Remarks

For Beginners: This method identifies which part of the code called a validation function. It's like caller ID for functions, helping to provide more specific error messages. You typically won't need to call this directly in your code.

ResolveCallerInfo(string, string, int)

Resolves component and operation names, using caller info if either is empty.

public static (string component, string operation) ResolveCallerInfo(string component = "", string operation = "", int skipFrames = 3)

Parameters

component string

The component name, or empty to use caller info.

operation string

The operation name, or empty to use caller info.

skipFrames int

Number of frames to skip in the stack trace.

Returns

(string component, string operation)

A tuple containing the resolved component and operation names.

Remarks

For Beginners: This method helps create more informative error messages by identifying which part of the library is performing an operation. You typically won't need to call this directly in your code.

ValidateInputData<TInput, TOutput>(OptimizationInputData<T, TInput, TOutput>)

Validates that optimization input data is properly formatted for model training and evaluation.

public static void ValidateInputData<TInput, TOutput>(OptimizationInputData<T, TInput, TOutput> inputData)

Parameters

inputData OptimizationInputData<T, TInput, TOutput>

The optimization input data containing training, validation, and test datasets.

Type Parameters

TInput

The type of the input data (e.g., Matrix<T> or Tensor<T>).

TOutput

The type of the output data (e.g., Vector<T> or Tensor<T>).

Remarks

For Beginners: When training AI models, we typically split our data into three sets:

  1. Training data - used to teach the model patterns (like studying for a test)
  2. Validation data - used to tune the model (like practice tests)
  3. Test data - used to evaluate the final model (like the final exam)

This method checks that all three datasets are properly formatted and compatible with each other. It can handle both matrix/vector pairs and tensor pairs.

ValidateInputData<TInput, TOutput>(TInput, TOutput)

Validates that input data is properly formatted for model training.

public static void ValidateInputData<TInput, TOutput>(TInput x, TOutput y)

Parameters

x TInput

The input data.

y TOutput

The target data.

Type Parameters

TInput

The type of the input data (e.g., Matrix<T> or Tensor<T>).

TOutput

The type of the output data (e.g., Vector<T> or Tensor<T>).

Remarks

For Beginners: This method checks that your input data (x) and output data (y) are compatible. It can handle both traditional matrix/vector pairs (for regression-like models) and tensor pairs (for neural networks). The method ensures they have matching dimensions and are not null or empty.

ValidatePoissonData(Vector<T>)

Validates that data is appropriate for Poisson regression.

public static void ValidatePoissonData(Vector<T> y)

Parameters

y Vector<T>

The target vector containing output values to predict.

Remarks

For Beginners: Poisson regression is a special type of model used when predicting counts (like number of customers, number of events, etc.). This method checks that your target values are non-negative integers (0, 1, 2, etc.), which is required for Poisson regression to work correctly.

For example, if you're predicting "number of website visitors per day", each value must be a whole number (you can't have 3.5 visitors) and can't be negative (you can't have -2 visitors).