CategoricalEncoding Class

Represents an encoding of the levels in a categorical variable.

Definition

Namespace: Extreme.DataAnalysis
Assembly: Extreme.Numerics (in Extreme.Numerics.dll) Version: 8.1.23
C#
[SerializableAttribute]
public abstract class CategoricalEncoding
Inheritance
Object  →  CategoricalEncoding

Remarks

Use the CategoricalEncoding class to specify how a categorical variable should be encoded as indicator variables. An encoding is a set of mappings from categories to real numbers. The mappings are returned as Index<T> objects.

Encodings can have two forms: full rank and reduced rank. A full rank encoding means that, when the encoding is applied to each category, the resulting matrix has full rank. Reduced rank encoding means that the resulting matrix does not have full rank. This is useful when specifying models that include a constant term. In such cases, the full rank encoding and the constant term are linearly dependent.

To create an encoding, use one of the static methods of the CategoricalEncoding class. You can then use the GetFullRankEncoding(Int32) or GetReducedRankEncoding(Int32) to get the encoding. Alternatively, you can inherit from CategoricalEncoding

The creation of indicator variables is mostly transparent. To create an indicator variable, use the index with the WithCategories<U>(IList<U>) method.

Constructors

CategoricalEncoding Constructs a new encoding object.

Methods

BackwardDifference(IIndex) Returns an encoding where every level is compared to the prior level.
BackwardDifference(IIndex, Int32) Returns an encoding where every level is compared to the prior level.
Deviation Returns an encoding where every level except the reference level is encoded using one of three values: 1 if the value equals the level, -1 if the value equals the reference level, and 0 otherwise.
Dummy Also called one hot encoding. Every level except the reference level is encoded using a binary variable.
EqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
ForwardDifference(IIndex) Returns an encoding where every level is compared to the next level.
ForwardDifference(IIndex, Int32) Returns an encoding where every level is compared to the next level.
GetContrastMatrix Returns a matrix whose columns contain the contrasts for the encoding.
GetFullRankEncoding(Int32) Returns the encoding with full rank of the specified position
GetFullRankEncoding<T>(Int32) Returns the encoding with full rank of the specified position
GetFullRankEncodingCore<T> Returns the encoding with full rank of the specified position
GetHashCodeServes as the default hash function.
(Inherited from Object)
GetLevelString Returns a string representation for the specified level.
GetReducedRankEncoding(Int32) Returns the encoding with reduced rank of the specified position
GetReducedRankEncoding<T>(Int32) Returns the encoding with reduced rank of the specified position
GetReducedRankEncodingCore<T> Returns the encoding with reduced rank of the specified position
GetTypeGets the Type of the current instance.
(Inherited from Object)
Helmert(IIndex) Returns an encoding where every level is compared to all the next levels.
Helmert(IIndex, Int32) Returns an encoding where every level is compared to all the next levels.
MemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
OrthogonalPolynomial Returns an encoding where levels are encoded to reflect trends in the levels. This encoding only makes sense for evenly spaced ordinal factors.
ReverseHelmert(IIndex) Returns an encoding where every level is compared to all the next levels.
ReverseHelmert(IIndex, Int32) Returns an encoding where every level is compared to all the next levels.
Simple Returns an encoding where every level is compared to the reference level.
ToStringReturns a string that represents the current object.
(Inherited from Object)

See Also