smile.feature
Class OneHotEncoder
- java.lang.Object
-
- smile.feature.OneHotEncoder
-
- All Implemented Interfaces:
- FeatureGenerator<double[]>
public class OneHotEncoder extends java.lang.Object implements FeatureGenerator<double[]>
Encode categorical integer features using a one-hot aka one-of-K scheme. Although some method such as decision trees can handle nominal variable directly, other methods generally require nominal variables converted to multiple binary dummy variables to indicate the presence or absence of a characteristic.
-
-
Constructor Summary
Constructors Constructor and Description OneHotEncoder(Attribute[] attributes)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description Attribute[]attributes()Returns the variable attributes of generated features.double[]feature(double[] x)Generates a feature for given object.
-
-
-
Constructor Detail
-
OneHotEncoder
public OneHotEncoder(Attribute[] attributes)
Constructor.- Parameters:
attributes- the variable attributes. Of which, nominal variables will be converted to binary dummy variables.
-
-
Method Detail
-
attributes
public Attribute[] attributes()
Description copied from interface:FeatureGeneratorReturns the variable attributes of generated features. Note that these are NOT the original variable attributes of objects.- Specified by:
attributesin interfaceFeatureGenerator<double[]>- Returns:
- the variable attributes of generated features
-
feature
public double[] feature(double[] x)
Description copied from interface:FeatureGeneratorGenerates a feature for given object.- Specified by:
featurein interfaceFeatureGenerator<double[]>- Parameters:
x- an object of interest.- Returns:
- a feature vector.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG