Home
API
Examples
Github
Home
API
Examples
Github
  • API

    • cluster

      • KMeans
    • datasets

      • Boston
      • HeartDisease
      • Iris
    • decomposition

      • PCA
    • ensemble

      • BaggingClassifier
      • RandomForestClassifier
    • feature_extraction

      • CountVectorizer
    • linear_model

      • Lasso
      • LinearRegression
      • LogisticRegression
      • Ridge
      • SGDClassifier
      • SGDRegressor
    • metrics

      • accuracyScore
      • confusion_matrix
      • mean_absolute_error
      • mean_squared_error
      • mean_squared_log_error
      • zeroOneLoss
    • model_selection

      • KFold
      • train_test_split
    • naive_bayes

      • GaussianNB
      • MultinomialNB
    • neighbors

      • KNeighborsClassifier
    • preprocessing

      • Binarizer
      • Imputer
      • LabelEncoder
      • MinMaxScaler
      • OneHotEncoder
      • PolynomialFeatures
      • add_dummy_feature
      • normalize
    • svm

      • BaseSVM
      • NuSVC
      • NuSVR
      • OneClassSVM
      • SVC
      • SVR
    • tree

      • DecisionTreeClassifier

preprocessing.LabelEncoder

Usage

import { LabelEncoder } from 'machinelearn/preprocessing';

const labelEncoder = new LabelEncoder();
const labelX = ['amsterdam', 'paris', 'tokyo'];
labelEncoder.fit(labelX);
const transformX = ['tokyo', 'tokyo', 'paris'];
const result = labelEncoder.transform(transformX);
// [ 2, 2, 1 ]

Constructors

  • constructor

Methods

  • fit

  • transform

Constructors


constructor

⊕ LabelEncoder()

Defined in

Parameters:

ParamTypeDefaultDescription

Returns: LabelEncoder

Methods


λ fit

Fit label encoder

Defined in preprocessing/label.ts:25

Parameters:

ParamTypeDefaultDescription
Xstring[] or number[] or boolean[]nullInput data in array or matrix

Returns:

void

λ transform

Transform labels to normalized encoding.

Given classes of ['amsterdam', 'paris', 'tokyo']

It transforms ["tokyo", "tokyo", "paris"]

Into [2, 2, 1]

Defined in preprocessing/label.ts:40

Parameters:

ParamTypeDefaultDescription
Xstring[] or number[] or boolean[]nullInput data to transform according to the fitted state

Returns:

any[]

Prev
Imputer
Next
MinMaxScaler