Encode target labels with value between 0 and n_classes-1.
class danfo.LabelEncoder
danfo.js provides the LabelEncoder class for encoding Series and Arrays to integer between 0 and n_classes -1. This is mostly used as a preprocessing step before most machine learning tasks.
The API is similar to sklearn's LabelEncoder, and provides a fit and transform method.
Examples
Label Encode values in a Series
constdfd=require('danfojs-node')let data = ["dog","cat","man","dog","cat","man","man","cat"]let series =newdfd.Series(data)let encode =newdfd.LabelEncoder()encode.fit(series)console.log(encode);let sf_enc =encode.transform(series.values)console.log(sf_enc)let new_sf =encode.transform(["dog","man"])console.log(new_sf)