Class ValidationHelper<T>
Provides validation methods for AI model inputs and parameters.
public static class ValidationHelper<T>
Type Parameters
TThe 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
skipFramesintNumber of frames to skip in the stack trace.
Returns
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
componentstringThe component name, or empty to use caller info.
operationstringThe operation name, or empty to use caller info.
skipFramesintNumber of frames to skip in the stack trace.
Returns
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
inputDataOptimizationInputData<T, TInput, TOutput>The optimization input data containing training, validation, and test datasets.
Type Parameters
TInputThe type of the input data (e.g., Matrix<T> or Tensor<T>).
TOutputThe 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:
- Training data - used to teach the model patterns (like studying for a test)
- Validation data - used to tune the model (like practice tests)
- 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
xTInputThe input data.
yTOutputThe target data.
Type Parameters
TInputThe type of the input data (e.g., Matrix<T> or Tensor<T>).
TOutputThe 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
yVector<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).