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.normalize

▸ normalize(X: `object`, norm: `object`)

Usage

import { normalize } from 'machinelearn/preprocessing';

const result = normalize([
  [1, -1, 2],
  [2, 0, 0],
  [0, 1, -1],
], { norm: 'l2' });
console.log(result);
// [ [ 0.4082482904638631, -0.4082482904638631, 0.8164965809277261 ],
// [ 1, 0, 0 ],
// [ 0, 0.7071067811865475, -0.7071067811865475 ] ]

Defined in preprocessing/data.ts:700

Parameters:

ParamTypeDefaultDescription
Xnumber[][]nullThe data to normalize
options.normstring'l2'

Returns:

number[][]

Prev
add_dummy_feature