SplineTransformer<T>

Models & Types · AiDotNet.Preprocessing.FeatureGeneration

Generates B-spline basis functions for features.

Inheritance: TransformerBase<T, Matrix<T>, Matrix<T>> → SplineTransformer<T>

For Beginners

B-splines let your model capture curved (non-linear) patterns:

  • Linear models only find straight-line relationships
  • Splines create multiple smooth curves that join at “knots”
  • Each input feature becomes multiple features representing different curve segments

Example: Age effect on income might be curved (rises until 50, then plateaus). Splines capture this without needing polynomial features.

How It Works

SplineTransformer creates B-spline basis functions from input features. B-splines are piecewise polynomials that provide a flexible way to model non-linear relationships while maintaining smoothness.

The knots can be placed uniformly across the feature range or at quantile positions to ensure roughly equal numbers of samples between knots.

Constructors

Constructor Summary
SplineTransformer(int nKnots, int degree, SplineKnotStrategy knotStrategy, bool includeIntercept, SplineExtrapolation extrapolation, int[] columnIndices) Creates a new instance of SplineTransformer.

Properties

Property Summary
SplineExtrapolation Extrapolation { get; } Gets the extrapolation strategy.
SplineKnotStrategy KnotStrategy { get; } Gets the knot placement strategy.
Vector<T>[] Knots { get; } Gets the fitted knots for each feature.
bool IncludeIntercept { get; } Gets whether the intercept term is included.
bool SupportsInverseTransform { get; } Gets whether this transformer supports inverse transformation.
int Degree { get; } Gets the degree of the spline.
int NKnots { get; } Gets the number of internal knots.

Methods

Method Summary
string[] GetFeatureNamesOut(string[] inputFeatureNames) Gets the output feature names after transformation.