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

metrics.accuracyScore

▸ accuracyScore(y_true: `object`, y_pred: `object`, normalize: `object`)

Usage

import { accuracyScore } from 'machinelearn/metrics';

const accResult = accuracyScore(
 [0, 1, 2, 3],
 [0, 2, 1, 3]
);

// accuracy result: 0.5

Defined in metrics/classification.ts:98

Parameters:

ParamTypeDefaultDescription
y_truestring[] or number[]null1d array-like, or label indicator array / sparse matrix
y_predstring[] or number[]null1d array-like, or label indicator array / sparse matrix
options.normalizebooleantrue

Returns:

number

Next
confusion_matrix