BaseNEncoder<T>

Models & Types · AiDotNet.Preprocessing.Encoders

Encodes categorical features using base-N representation.

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

For Beginners

BaseNEncoder is like counting in different number systems:

  • Base 2 (binary): Uses 0 and 1 → most compact
  • Base 3 (ternary): Uses 0, 1, 2 → slightly more columns
  • Higher bases = fewer columns but more possible values per column

How It Works

BaseNEncoder converts category indices to base-N representation, creating multiple columns with digits in the specified base. This is a generalization of binary encoding (base 2).

For example, with base=3 and 9 categories (0-8):

  • Category 0 → [0, 0]
  • Category 4 → [1, 1] (4 = 1*3 + 1)
  • Category 8 → [2, 2] (8 = 2*3 + 2)

Constructors

Constructor Summary
BaseNEncoder(int base_, BaseNHandleUnknown handleUnknown, int[] columnIndices) Creates a new instance of BaseNEncoder.

Properties

Property Summary
BaseNHandleUnknown HandleUnknown { get; } Gets how unknown categories are handled.
bool SupportsInverseTransform { get; } Gets whether this transformer supports inverse transformation.
int Base { get; } Gets the base used for encoding.
int NOutputFeatures { get; } Gets the number of output features.

Methods

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