Table of Contents

Class RegressionHelper<T>

Namespace
AiDotNet.Helpers
Assembly
AiDotNet.dll

Helper class that provides common operations for regression analysis.

public static class RegressionHelper<T>

Type Parameters

T

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

Inheritance
RegressionHelper<T>
Inherited Members

Remarks

For Beginners: Regression is a technique used in AI to find relationships between variables. For example, predicting house prices based on features like size, location, and age. This helper class provides tools to make regression work better with your data.

Methods

CenterAndScale(Matrix<T>, Vector<T>)

Standardizes the input features and target values by centering them around zero and scaling them to have unit variance.

public static (Matrix<T> xScaled, Vector<T> yScaled, Vector<T> xMean, Vector<T> xStd, T yMean, T yStd) CenterAndScale(Matrix<T> x, Vector<T> y)

Parameters

x Matrix<T>

The input feature matrix where rows are samples and columns are features.

y Vector<T>

The target values vector.

Returns

(Matrix<T> xScaled, Vector<T> yScaled, Vector<T> xMean, Vector<T> xStd, T yMean, T yStd)

A tuple containing:

  • xScaled: The standardized feature matrix
  • yScaled: The standardized target values
  • xMean: The mean of each feature column
  • xStd: The standard deviation of each feature column
  • yMean: The mean of the target values
  • yStd: The standard deviation of the target values

Remarks

For Beginners: This method prepares your data for machine learning by making all features comparable to each other. Think of it like converting different measurements (inches, pounds, etc.) to a common scale.

For example, if one feature ranges from 0-1000 and another from 0-1, the larger one might dominate the model. Standardization solves this by:

  1. Subtracting the average (centering around zero)
  2. Dividing by the standard deviation (scaling to similar ranges)

The method returns both the transformed data and the values used for transformation, which you'll need later to transform new data or interpret results.