Univariate Feature Scores
Rank classification and regression features with chi-square, ANOVA F, and k-nearest-neighbor mutual information JavaScript functions from @kanaries/ml.
View as MarkdownUnivariate feature scores
Algorithm overview
Univariate scores examine one feature at a time. Chi-square is suited to non-negative count features, ANOVA F measures class separation, and mutual information detects more general nonlinear dependence using discrete counts or k-nearest-neighbor entropy estimates.
JavaScript implementation
@kanaries/ml makes these score functions available in browser and Node.js code through FeatureSelection, including seeded jitter for repeated continuous values.
Quick start example
import { FeatureSelection } from '@kanaries/ml';
const X = [[0, 1], [1, 0], [5, 1], [6, 0]];
const y = [0, 0, 1, 1];
const [fScores, pValues] = FeatureSelection.fClassif(X, y);
const information = FeatureSelection.mutualInfoClassif(X, y, { randomState: 42 });
console.log({ fScores, pValues, information });Detailed API reference
chi2(X, y)andfClassif(X, y)return[scores, pValues].mutualInfoClassif(X, y, options?)andmutualInfoRegression(X, y, options?)return one non-negative score per feature.- Mutual-information options are
discreteFeatures?: boolean | boolean[],nNeighbors?: number(default3), andrandomState?: number.
SelectFromModel, RFE, and RFECV
Run model-based and recursive feature selection in JavaScript or TypeScript with SelectFromModel, RFE, and RFECV from @kanaries/ml.
Text Feature Extraction
Convert raw text into sparse count and TF-IDF matrices in JavaScript or TypeScript for browser and Node.js machine-learning pipelines.