Interface INormalizer<T, TInput, TOutput>
- Namespace
- AiDotNet.Interfaces
- Assembly
- AiDotNet.dll
public interface INormalizer<T, TInput, TOutput>
Type Parameters
TTInputTOutput
Methods
Denormalize(TInput, TOutput, TOutput, List<NormalizationParameters<T>>, NormalizationParameters<T>)
Calculates the denormalized Y-intercept (constant term) for a linear model.
T Denormalize(TInput xMatrix, TOutput y, TOutput coefficients, List<NormalizationParameters<T>> xParams, NormalizationParameters<T> yParams)
Parameters
xMatrixTInputThe original input feature matrix (before normalization).
yTOutputThe original target vector (before normalization).
coefficientsTOutputThe model coefficients (can be either normalized or denormalized).
xParamsList<NormalizationParameters<T>>The normalization parameters used for the input features (X).
yParamsNormalizationParameters<T>The normalization parameters used for the target variable (Y).
Returns
- T
The denormalized Y-intercept (constant term) for use with non-normalized data.
Remarks
This method computes the Y-intercept for a model trained on normalized data so it can be used with non-normalized input data.
For Beginners: This calculates the starting point (base value) for your model's predictions.
In a linear model like house price prediction:
- Coefficients tell you how much each feature contributes (e.g., $100 per square foot)
- The Y-intercept is the base value (e.g., $50,000 base price before adjustments)
When you train on normalized data:
- The Y-intercept learned by the model works for normalized values
- This method calculates the correct Y-intercept for original, non-normalized data
For example:
- Your house price model might have a normalized Y-intercept of 0.5
- This method converts it to a meaningful value like $150,000
This is typically used together with denormalized coefficients to create a complete model that works with original, non-normalized data.
Denormalize(TOutput, NormalizationParameters<T>)
Reverses the normalization of data using the original normalization parameters.
TOutput Denormalize(TOutput data, NormalizationParameters<T> parameters)
Parameters
dataTOutputThe normalized data to denormalize.
parametersNormalizationParameters<T>The normalization parameters that were used during normalization.
Returns
- TOutput
The denormalized data in its original scale.
Remarks
This method transforms normalized data back to its original scale using the normalization parameters that were generated during the normalization process.
For Beginners: This converts normalized values back to their original scale.
For example:
- If normalization converted ages (5, 18, 35, 62, 80) to (0.0, 0.17, 0.4, 0.76, 1.0)
- Denormalization would convert (0.0, 0.17, 0.4, 0.76, 1.0) back to (5, 18, 35, 62, 80)
This is typically used:
- After making predictions with a model (to convert predictions back to meaningful units)
- When you need to interpret normalized data in its original context
Denormalize(TOutput, List<NormalizationParameters<T>>, NormalizationParameters<T>)
Denormalizes model coefficients to make them applicable to non-normalized input data.
TOutput Denormalize(TOutput coefficients, List<NormalizationParameters<T>> xParams, NormalizationParameters<T> yParams)
Parameters
coefficientsTOutputThe model coefficients from a model trained on normalized data.
xParamsList<NormalizationParameters<T>>The normalization parameters used for the input features (X).
yParamsNormalizationParameters<T>The normalization parameters used for the target variable (Y).
Returns
- TOutput
Denormalized coefficients that can be used with original, non-normalized data.
Remarks
This method adjusts the coefficients of a model trained on normalized data so they can be used directly with non-normalized input data.
For Beginners: This converts the model's internal numbers to work with your original data.
When you train a model on normalized data:
- The model learns coefficients (weights) that work with normalized values
- To use the model with original, non-normalized data, these coefficients need adjustment
- This method performs that adjustment
For example:
- You trained a house price model on normalized data (size, bedrooms, age)
- The model learned coefficients like [0.7, 0.2, -0.1]
- This method converts these to coefficients that work with the original units (e.g., dollars per square foot, dollars per bedroom, etc.)
This is typically used when:
- You want to interpret what the model learned (e.g., "each additional bedroom adds $20,000")
- You want to use the model with non-normalized input data
NormalizeInput(TInput)
Normalizes input data to a standard range.
(TInput, List<NormalizationParameters<T>>) NormalizeInput(TInput data)
Parameters
dataTInputThe data to normalize.
Returns
- (TInput, List<NormalizationParameters<T>>)
A tuple containing:
- The normalized data
- A list of normalization parameters for each feature (needed for later denormalization)
Remarks
This method transforms each feature of the input data to a normalized scale and returns both the normalized data and the parameters used for normalization of each feature.
For Beginners: This converts a table of numbers to a standard scale.
For example:
- If your data contains information about houses (columns for size, bedrooms, age, price), each feature is normalized separately
- Size values might range from 1,000-5,000 sq ft, but are converted to 0-1
- Bedroom values might range from 1-6, but are also converted to 0-1
- The normalization parameters for each feature are saved separately
This is typically used to prepare multiple features (input variables) for machine learning.
NormalizeOutput(TOutput)
Normalizes output data to a standard range.
(TOutput, NormalizationParameters<T>) NormalizeOutput(TOutput data)
Parameters
dataTOutputThe data to normalize.
Returns
- (TOutput, NormalizationParameters<T>)
A tuple containing:
- The normalized data
- The normalization parameters that were used (needed for later denormalization)
Remarks
This method transforms the input data to a normalized scale and returns both the normalized data and the parameters used for normalization.
For Beginners: This converts a list of numbers to a standard scale.
For example:
- If your data contains ages (5, 18, 35, 62, 80), normalization might convert these to values between 0 and 1: (0.0, 0.17, 0.4, 0.76, 1.0)
- The normalization parameters (like minimum and maximum values) are also returned so you can reverse this process later
This is typically used to prepare a single feature or target variable for machine learning.