Skip to main content

API Reference

Classes

Members

  • seed ML utilities including seeded random number generation

Constants

  • distributions Create parameter distribution objects

  • SUPPORTED_MARKS Attach lightweight rendering helpers to plot configuration objects. Allows calling config.show(Plot) in Observable without adding direct Plot dependency.

Functions

Returns: { X, columns, n, rows, encoders } where encoders is a mapping of column->encoder used

Optimizer

Base Optimizer class

Kind: global class

optimizer.minimize(lossFn, x0, options) ⇒ Object

Minimize a loss function

Kind: instance method of Optimizer
Returns: Object - {x, history}

ParamTypeDescription
lossFnfunctionFunction that returns {loss, gradient}
x0Array.<number>Initial parameters
optionsObjectAdditional options

optimizer.checkConvergence(gradient) ⇒ boolean

Check convergence based on gradient norm

Kind: instance method of Optimizer

ParamType
gradientArray.<number>

seed

ML utilities including seeded random number generation

Kind: global variable

distributions

Create parameter distribution objects

Kind: global constant

distributions.uniform(low, high) ⇒ Object

Uniform distribution

Kind: static method of distributions

ParamType
lownumber
highnumber

distributions.loguniform(low, high) ⇒ Object

Log-uniform distribution (for learning rates, etc.)

Kind: static method of distributions

ParamType
lownumber
highnumber

distributions.randint(low, high) ⇒ Object

Random integer

Kind: static method of distributions

ParamType
lownumber
highnumber

distributions.choice(options) ⇒ Object

Choice from options

Kind: static method of distributions

ParamType
optionsArray

SUPPORTED_MARKS

Attach lightweight rendering helpers to plot configuration objects. Allows calling config.show(Plot) in Observable without adding direct Plot dependency.

Kind: global constant

toMatrix(data) ⇒ Matrix

Convert array-like structure to Matrix

Kind: global function
Returns: Matrix - Matrix object

ParamTypeDescription
dataArray.<Array.<number>> | MatrixInput data

solveLeastSquares(A, b) ⇒ Matrix

Solve least squares problem: minimize ||Ax - b||^2

Kind: global function
Returns: Matrix - Solution x

ParamTypeDescription
AArray.<Array.<number>> | MatrixDesign matrix
bArray.<number> | Array.<Array.<number>> | MatrixTarget vector/matrix

covarianceMatrix(data, center) ⇒ Matrix

Compute covariance matrix

Kind: global function
Returns: Matrix - Covariance matrix

ParamTypeDescription
dataArray.<Array.<number>> | MatrixData matrix (rows = observations)
centerbooleanIf true, center the data

svd(data) ⇒ Object

Singular Value Decomposition

Kind: global function
Returns: Object - {U, s, V} where data ≈ U * diag(s) * V'

ParamTypeDescription
dataArray.<Array.<number>> | MatrixInput matrix

eig(data) ⇒ Object

Eigenvalue decomposition

Kind: global function
Returns: Object - {values, vectors}

ParamTypeDescription
dataArray.<Array.<number>> | MatrixSquare matrix

mmul(A, B) ⇒ Matrix

Matrix multiplication

Kind: global function
Returns: Matrix - A * B

ParamTypeDescription
AArray.<Array.<number>> | MatrixFirst matrix
BArray.<Array.<number>> | MatrixSecond matrix

transpose(data) ⇒ Matrix

Matrix transpose

Kind: global function
Returns: Matrix - Transposed matrix

ParamTypeDescription
dataArray.<Array.<number>> | MatrixInput matrix

inverse(data) ⇒ Matrix

Matrix inverse

Kind: global function
Returns: Matrix - Inverse matrix

ParamTypeDescription
dataArray.<Array.<number>> | MatrixSquare matrix

approxEqual(a, b, tolerance) ⇒ boolean

Approximate equality comparison for floating point numbers

Kind: global function
Returns: boolean - True if approximately equal

ParamTypeDescription
anumberFirst number
bnumberSecond number
tolerancenumberTolerance for comparison

guardFinite(value, name) ⇒ number

Guard against non-finite values

Kind: global function
Returns: number - The value if valid
Throws:

  • Error If value is not finite
ParamTypeDescription
valuenumberValue to check
namestringName for error message

guardPositive(value, name) ⇒ number

Guard against negative values

Kind: global function
Returns: number - The value if valid
Throws:

  • Error If value is negative
ParamTypeDescription
valuenumberValue to check
namestringName for error message

guardProbability(value, name) ⇒ number

Guard against values outside [0, 1]

Kind: global function
Returns: number - The value if valid
Throws:

  • Error If value is outside [0, 1]
ParamTypeDescription
valuenumberValue to check
namestringName for error message

sum(arr) ⇒ number

Sum of array

Kind: global function
Returns: number - Sum

ParamTypeDescription
arrArray.<number>Array of numbers

mean(arr) ⇒ number

Mean of array

Kind: global function
Returns: number - Mean

ParamTypeDescription
arrArray.<number>Array of numbers

variance(arr, sample) ⇒ number

Variance of array

Kind: global function
Returns: number - Variance

ParamTypeDescription
arrArray.<number>Array of numbers
samplebooleanIf true, use sample variance (n-1)

stddev(arr, sample) ⇒ number

Standard deviation of array

Kind: global function
Returns: number - Standard deviation

ParamTypeDescription
arrArray.<number>Array of numbers
samplebooleanIf true, use sample variance (n-1)

createOptimizer(name, options) ⇒ Optimizer

Convenience function to create optimizer by name

Kind: global function
Returns: Optimizer - Optimizer instance

ParamTypeDescription
namestringOptimizer name
optionsObjectOptimizer options

saveModel(model) ⇒ string

Save model to JSON

Kind: global function
Returns: string - JSON string representation of the model

ParamTypeDescription
modelObjectModel object with toJSON method or estimator instance

loadModel(json) ⇒ Object

Load model from JSON

Kind: global function
Returns: Object - Reconstructed model object

ParamTypeDescription
jsonstringJSON string representation

addSerializationSupport(EstimatorClass, toJSONFn)

Add toJSON method to an estimator class prototype This allows models to define their own serialization logic

Kind: global function

ParamTypeDescription
EstimatorClassfunctionEstimator class
toJSONFnfunctionCustom toJSON function

serializeValue(value) ⇒ any

Serialize model to file-safe object Handles special types like undefined, Infinity, NaN

Kind: global function
Returns: any - Serializable value

ParamTypeDescription
valueanyValue to serialize

deserializeValue(value) ⇒ any

Deserialize value from file-safe object

Kind: global function
Returns: any - Deserialized value

ParamTypeDescription
valueanyValue to deserialize

makeSaveable(model) ⇒ Object

Create a saveable model wrapper Adds save() method to any model object

Kind: global function
Returns: Object - Model with save() method

ParamTypeDescription
modelObjectModel object

isArqueroLike(data) ⇒ boolean

Check if input has Arquero-like interface

Kind: global function
Returns: boolean - True if has .objects() method

ParamTypeDescription
data\*Input data

normalize(data) ⇒ Array.<Object>

Normalize input to array of objects

Kind: global function
Returns: Array.<Object> - Array of row objects

ParamTypeDescription
dataArray.<Object> | ObjectInput data

toMatrix(data, columns) ⇒ Matrix

Convert table data to matrix

Kind: global function
Returns: Matrix - Matrix with selected columns

ParamTypeDescription
dataArray.<Object> | ObjectInput data
columnsArray.<string>Column names to extract

toVector(data, column) ⇒ Array.<number>

Convert table column to vector

Kind: global function
Returns: Array.<number> - 1D array

ParamTypeDescription
dataArray.<Object> | ObjectInput data
columnstringColumn name

toColumns(data, columns) ⇒ Object

Extract multiple columns as arrays

Kind: global function
Returns: Object - Object with column names as keys and arrays as values

ParamTypeDescription
dataArray.<Object> | ObjectInput data
columnsArray.<string>Column names

getColumns(data) ⇒ Array.<string>

Get column names from data

Kind: global function
Returns: Array.<string> - Column names

ParamTypeDescription
dataArray.<Object> | ObjectInput data

filter(data, predicate) ⇒ Array.<Object>

Filter rows based on predicate

Kind: global function
Returns: Array.<Object> - Filtered rows

ParamTypeDescription
dataArray.<Object> | ObjectInput data
predicatefunctionFilter function

select(data, columns) ⇒ Array.<Object>

Select specific columns

Kind: global function
Returns: Array.<Object> - Rows with selected columns

ParamTypeDescription
dataArray.<Object> | ObjectInput data
columnsArray.<string>Columns to select

isNumeric(v) ⇒ boolean

Helper: check if a value is numeric (finite number)

Kind: global function

ParamType
v\*

isMissing(v) ⇒ boolean

Helper: check if a value is considered missing

Kind: global function

ParamType
v\*

prepareX()

Prepare feature matrix X from table-like data. Supports optional categorical encoding: prepareX({ columns, data, omit_missing = true, encode = null })

encode can be:

  • null/false: no encoding (default)
  • true: auto-label encode any non-numeric columns
  • { colName: 'label' | 'onehot' } mapping per-column

Returns: { X, columns, n, rows, encoders } where encoders is a mapping of column->encoder used

Kind: global function

prepareXY()

Prepare feature matrix X and response vector y from table-like data. Supports categorical encoding for X and y via encode option: prepareXY({ X, y, data, omit_missing = true, encode = null })

encode semantics same as prepareX. For y, only 'label' encoding is supported (maps categories to integer class labels).

Returns: { X, y, columnsX, n, rows, encoders } where encoders may include encoders.y

Kind: global function

featureImportance(model, X, y, scoreFn, options) ⇒ Array.<Object>

Compute feature importance via permutation

Kind: global function
Returns: Array.<Object> - Feature importance scores

ParamTypeDescription
modelObjectFitted model with predict method
XArray.<Array.<number>>Feature matrix
yArray.<number>Target values
scoreFnfunctionScoring function (yTrue, yPred) => score
optionsObject{nRepeats, seed}

coefficientImportance(model, featureNames) ⇒ Array.<Object>

Compute coefficient-based feature importance (for linear models)

Kind: global function
Returns: Array.<Object> - Feature importance based on coefficients

ParamTypeDescription
modelObjectFitted linear model with coefficients
featureNamesArray.<string>Feature names (optional)

partialDependence(model, X, feature, options) ⇒ Object

Compute partial dependence for a feature

Kind: global function
Returns: Object - {values, predictions}

ParamTypeDescription
modelObjectFitted model with predict method
XArray.<Array.<number>>Feature matrix
featurenumberFeature index
optionsObject{gridSize, percentiles}

residualPlotData(model, X, y) ⇒ Object

Compute residual plot data

Kind: global function
Returns: Object - {fitted, residuals, standardized}

ParamTypeDescription
modelObjectFitted model with predict method
XArray.<Array.<number>>Feature matrix
yArray.<number>Target values

correlationMatrix(X, featureNames) ⇒ Object

Compute correlation matrix

Kind: global function
Returns: Object - {matrix, features}

ParamTypeDescription
XArray.<Array.<number>>Feature matrix
featureNamesArray.<string>Feature names (optional)

learningCurve(fitFn, scoreFn, X, y, options) ⇒ Object

Learning curve data (performance vs training size)

Kind: global function
Returns: Object - {trainSizes, trainScores, testScores}

ParamTypeDescription
fitFnfunctionFunction to fit model: (X, y) => model
scoreFnfunctionScoring function: (yTrue, yPred) => score
XArray.<Array.<number>>Feature matrix
yArrayTarget values
optionsObject{trainSizes, cv}

euclideanDistance(a, b) ⇒ number

Euclidean distance between two points

Kind: global function
Returns: number - Distance

ParamTypeDescription
aArray.<number>First point
bArray.<number>Second point

createRandomGenerator(data, k) ⇒ Array.<Array.<number>>

Initialize centroids using k-means++ algorithm

Kind: global function
Returns: Array.<Array.<number>> - Initial centroids

ParamTypeDescription
dataArray.<Array.<number>>Data points
knumberNumber of clusters

initializeCentroidsKMeansPlusPlus(data, k, random) ⇒ Array.<Array.<number>>

Initialize centroids using k-means++ algorithm

Kind: global function
Returns: Array.<Array.<number>> - Initial centroids

ParamTypeDescription
dataArray.<Array.<number>>Data points
knumberNumber of clusters
randomfunctionRandom number generator returning [0,1)

assignClusters(data, centroids) ⇒ Array.<number>

Assign each point to nearest centroid

Kind: global function
Returns: Array.<number> - Cluster assignments

ParamTypeDescription
dataArray.<Array.<number>>Data points
centroidsArray.<Array.<number>>Current centroids

updateCentroids(data, labels, k) ⇒ Array.<Array.<number>>

Update centroids based on cluster assignments

Kind: global function
Returns: Array.<Array.<number>> - New centroids

ParamTypeDescription
dataArray.<Array.<number>>Data points
labelsArray.<number>Cluster assignments
knumberNumber of clusters

computeInertia(data, labels, centroids) ⇒ number

Compute within-cluster sum of squares (inertia)

Kind: global function
Returns: number - Inertia

ParamTypeDescription
dataArray.<Array.<number>>Data points
labelsArray.<number>Cluster assignments
centroidsArray.<Array.<number>>Centroids

fit(X, options) ⇒ Object

Fit k-means clustering model

Kind: global function
Returns: Object - {labels, centroids, inertia, iterations, converged}

ParamTypeDescription
XArray.<Array.<number>> | MatrixData matrix (n samples × d features)
optionsObject{k: number of clusters, maxIter: max iterations, tol: tolerance}

predict(model, X) ⇒ Array.<number>

Predict cluster labels for new data

Kind: global function
Returns: Array.<number> - Cluster labels

ParamTypeDescription
modelObjectFitted model from fit()
XArray.<Array.<number>>New data points

silhouetteScore(X, labels) ⇒ number

Compute silhouette score for clustering quality

Kind: global function
Returns: number - Silhouette score (range: -1 to 1, higher is better)

ParamTypeDescription
XArray.<Array.<number>>Data points
labelsArray.<number>Cluster assignments

mseLoss(yTrue, yPred) ⇒ Object

Mean Squared Error Loss

Kind: global function
Returns: Object - {loss, gradient}

ParamTypeDescription
yTrueArray.<number>True values
yPredArray.<number>Predicted values

maeLoss(yTrue, yPred) ⇒ Object

Mean Absolute Error Loss

Kind: global function
Returns: Object - {loss, gradient}

ParamTypeDescription
yTrueArray.<number>True values
yPredArray.<number>Predicted values

logLoss(yTrue, yPred, epsilon) ⇒ Object

Binary Cross-Entropy Loss (Log Loss)

Kind: global function
Returns: Object - {loss, gradient}

ParamTypeDescription
yTrueArray.<number>True labels (0 or 1)
yPredArray.<number>Predicted probabilities
epsilonnumberSmall value to avoid log(0)

crossEntropy(yTrue, yPred, epsilon) ⇒ Object

Categorical Cross-Entropy Loss

Kind: global function
Returns: Object - {loss, gradient}

ParamTypeDescription
yTrueArray.<Array.<number>>One-hot encoded true labels
yPredArray.<Array.<number>>Predicted probabilities
epsilonnumberSmall value to avoid log(0)

hingeLoss(yTrue, yPred) ⇒ Object

Hinge Loss (for SVM)

Kind: global function
Returns: Object - {loss, gradient}

ParamTypeDescription
yTrueArray.<number>True labels (-1 or 1)
yPredArray.<number>Predicted scores

huberLoss(yTrue, yPred, delta) ⇒ Object

Huber Loss (robust to outliers)

Kind: global function
Returns: Object - {loss, gradient}

ParamTypeDescription
yTrueArray.<number>True values
yPredArray.<number>Predicted values
deltanumberThreshold for switching from quadratic to linear

getLossFunction(name) ⇒ function

Get loss function by name

Kind: global function
Returns: function - Loss function

ParamTypeDescription
namestringLoss function name

mse(yTrue, yPred) ⇒ number

Mean Squared Error

Kind: global function
Returns: number - MSE

ParamTypeDescription
yTrueArray.<number>True values
yPredArray.<number>Predicted values

rmse(yTrue, yPred) ⇒ number

Root Mean Squared Error

Kind: global function
Returns: number - RMSE

ParamTypeDescription
yTrueArray.<number>True values
yPredArray.<number>Predicted values

mae(yTrue, yPred) ⇒ number

Mean Absolute Error

Kind: global function
Returns: number - MAE

ParamTypeDescription
yTrueArray.<number>True values
yPredArray.<number>Predicted values

r2(yTrue, yPred) ⇒ number

R² (coefficient of determination)

Kind: global function
Returns: number - R²

ParamTypeDescription
yTrueArray.<number>True values
yPredArray.<number>Predicted values

accuracy(yTrue, yPred) ⇒ number

Accuracy score

Kind: global function
Returns: number - Accuracy

ParamTypeDescription
yTrueArrayTrue labels
yPredArrayPredicted labels

confusionMatrix(yTrue, yPred) ⇒ Object

Confusion matrix

Kind: global function
Returns: Object - {matrix, labels}

ParamTypeDescription
yTrueArrayTrue labels
yPredArrayPredicted labels

precision(yTrue, yPred, positiveLabel) ⇒ number

Precision score (for binary classification)

Kind: global function
Returns: number - Precision

ParamTypeDescription
yTrueArrayTrue labels
yPredArrayPredicted labels
positiveLabel\*Label to consider as positive

recall(yTrue, yPred, positiveLabel) ⇒ number

Recall score (for binary classification)

Kind: global function
Returns: number - Recall

ParamTypeDescription
yTrueArrayTrue labels
yPredArrayPredicted labels
positiveLabel\*Label to consider as positive

f1(yTrue, yPred, positiveLabel) ⇒ number

F1 score

Kind: global function
Returns: number - F1 score

ParamTypeDescription
yTrueArrayTrue labels
yPredArrayPredicted labels
positiveLabel\*Label to consider as positive

logLoss(yTrue, yPred, eps) ⇒ number

Log loss (cross-entropy loss)

Kind: global function
Returns: number - Log loss

ParamTypeDescription
yTrueArrayTrue labels (0 or 1)
yPredArray.<number>Predicted probabilities
epsnumberSmall constant to avoid log(0)

rocAuc(yTrue, yPred) ⇒ number

ROC AUC score (simplified for binary classification)

Kind: global function
Returns: number - AUC

ParamTypeDescription
yTrueArrayTrue labels (0 or 1)
yPredArray.<number>Predicted probabilities

cohenKappa(yTrue, yPred) ⇒ number

Cohen's Kappa coefficient

Kind: global function
Returns: number - Kappa

ParamTypeDescription
yTrueArrayTrue labels
yPredArrayPredicted labels

adjustedRandIndex(yTrue, yPred) ⇒ number

Adjusted Rand Index

Kind: global function
Returns: number - Adjusted Rand Index

ParamTypeDescription
yTrueArrayTrue labels
yPredArrayPredicted labels

initializeWeights(nIn, nOut) ⇒ Array.<Array.<number>>

Initialize weights using Xavier/Glorot initialization

Kind: global function
Returns: Array.<Array.<number>> - Weight matrix

ParamTypeDescription
nInnumberInput size
nOutnumberOutput size

forward(input, layers) ⇒ Object

Forward pass through network

Kind: global function
Returns: Object - {activations, outputs}

ParamTypeDescription
inputArray.<number>Input vector
layersArray.<Object>Network layers

backward(target, forwardResult, layers) ⇒ Array.<Object>

Backward pass (backpropagation)

Kind: global function
Returns: Array.<Object> - Gradients for each layer

ParamTypeDescription
targetArray.<number>Target output
forwardResultObjectResult from forward pass
layersArray.<Object>Network layers

createNetwork(layerSizes, activation) ⇒ Array.<Object>

Create MLP architecture

Kind: global function
Returns: Array.<Object> - Initialized layers

ParamTypeDescription
layerSizesArray.<number>Size of each layer [input, hidden1, ..., output]
activationstringActivation function ('sigmoid', 'relu', 'tanh')

fit(X, y, options) ⇒ Object

Train MLP using mini-batch gradient descent

Kind: global function
Returns: Object - {layers, losses, epochs}

ParamTypeDescription
XArray.<Array.<number>>Training data
yArray.<Array.<number>> | Array.<number>Target values
optionsObjectTraining options

predict(model, X) ⇒ Array.<Array.<number>>

Predict using trained MLP

Kind: global function
Returns: Array.<Array.<number>> - Predictions

ParamTypeDescription
modelObjectTrained model from fit()
XArray.<Array.<number>> | Array.<number>Input data

evaluate(model, X, y) ⇒ Object

Evaluate model on test data

Kind: global function
Returns: Object - {mse, mae}

ParamTypeDescription
modelObjectTrained model
XArray.<Array.<number>>Test inputs
yArray.<Array.<number>> | Array.<number>Test targets

polynomialFeatures(X, degree) ⇒ Array.<Array.<number>>

Create polynomial features from input

Kind: global function
Returns: Array.<Array.<number>> - Polynomial features

ParamTypeDescription
XArray.<Array.<number>> | MatrixInput features (n × 1 for univariate)
degreenumberPolynomial degree

fit(X, y, options) ⇒ Object

Fit polynomial regression model

Kind: global function
Returns: Object - {coefficients, degree, fitted, residuals, rSquared}

ParamTypeDescription
XArray.<Array.<number>> | Array.<number>Input data (can be 1D for univariate)
yArray.<number>Target values
optionsObject{degree: polynomial degree, intercept: include intercept}

predict(model, X, options) ⇒ Array.<number>

Predict using polynomial regression model

Kind: global function
Returns: Array.<number> - Predictions

ParamTypeDescription
modelObjectFitted model from fit()
XArray.<Array.<number>> | Array.<number>New data
optionsObject{intercept: boolean}

train(model, X, y, options) ⇒ Object

Train a model with gradient-based optimization

Kind: global function
Returns: Object - Training history

ParamTypeDescription
modelObjectModel with forward and backward methods
XArray.<Array.<number>>Feature matrix
yArray.<number> | Array.<Array.<number>>Target values
optionsObjectTraining options

trainFunction(lossFn, params0, options) ⇒ Object

Simple training loop for functions (not models)

Kind: global function
Returns: Object - {params, history}

ParamTypeDescription
lossFnfunctionLoss function that returns {loss, gradient}
params0Array.<number>Initial parameters
optionsObjectTraining options

earlyStopping(patience, minDelta) ⇒ Object

Early stopping callback

Kind: global function
Returns: Object - Callback object with state

ParamTypeDescription
patiencenumberNumber of epochs to wait for improvement
minDeltanumberMinimum change to qualify as improvement

learningRateScheduler(scheduleFn, optimizer) ⇒ Object

Learning rate scheduler callback

Kind: global function
Returns: Object - Callback object

ParamTypeDescription
scheduleFnfunctionFunction (epoch) => learningRate
optimizerOptimizerOptimizer to update

modelCheckpoint(metric) ⇒ Object

Model checkpoint callback

Kind: global function
Returns: Object - Callback object with state

ParamTypeDescription
metricstringMetric to monitor ('loss' or 'valLoss')

GridSearchCV(fitFn, scoreFn, X, y, paramGrid, options) ⇒ Object

Grid Search Cross-Validation

Kind: global function
Returns: Object - {bestParams, bestScore, bestModel, results}

ParamTypeDescription
fitFnfunctionFunction (X, y, params) => model
scoreFnfunctionFunction (model, X, y) => score
XArrayFeature matrix
yArrayTarget values
paramGridObjectParameter grid {param1: [values], param2: [values]}
optionsObject{k, shuffle, metric}

new exports.GridSearchCV(estimatorFn, paramGrid, scoreFn, cv)

Create grid search

ParamTypeDefaultDescription
estimatorFnfunctionFunction that creates estimator: (params) => estimator
paramGridObjectGrid of parameters: {param1: [val1, val2], ...}
scoreFnfunctionScoring function: (yTrue, yPred) => score
cvnumber5Number of cross-validation folds

GridSearchCVGridSearchCV

Simple GridSearchCV for hyperparameter tuning

Kind: global class of GridSearchCV

gridSearchCV.fit(X, y) ⇒ GridSearchCV

Perform grid search with cross-validation

Kind: instance method of GridSearchCV
Returns: GridSearchCV - this

ParamTypeDescription
XArrayFeature matrix
yArrayTarget values

gridSearchCV.predict(X) ⇒ Array

Predict using best estimator

Kind: instance method of GridSearchCV
Returns: Array - Predictions

ParamTypeDescription
XArrayFeature matrix

gridSearchCV.getResults() ⇒ Array.<Object>

Get results sorted by score

Kind: instance method of GridSearchCV
Returns: Array.<Object> - Results

RandomSearchCV(fitFn, scoreFn, X, y, paramDistributions, options) ⇒ Object

Random Search Cross-Validation

Kind: global function
Returns: Object - {bestParams, bestScore, bestModel, results}

ParamTypeDescription
fitFnfunctionFunction (X, y, params) => model
scoreFnfunctionFunction (model, X, y) => score
XArrayFeature matrix
yArrayTarget values
paramDistributionsObjectParameter distributions
optionsObject{nIter, k, shuffle, seed}

generateParamCombinations(paramGrid) ⇒ Array.<Object>

Generate all combinations from parameter grid

Kind: global function
Returns: Array.<Object> - Array of parameter combinations

ParamType
paramGridObject

sampleParams(paramDistributions) ⇒ Object

Sample parameters from distributions

Kind: global function
Returns: Object - Sampled parameters

ParamType
paramDistributionsObject

sampleFromDistribution(distribution) ⇒ number

Sample from a distribution object

Kind: global function
Returns: number - Sampled value

ParamTypeDescription
distributionObject{type, ...params}

setSeed(value)

Set random seed for reproducibility

Kind: global function

ParamTypeDescription
valuenumberSeed value

random() ⇒ number

Seeded random number generator (LCG)

Kind: global function
Returns: number - Random number between 0 and 1

randomInt(min, max) ⇒ number

Random integer in range [min, max)

Kind: global function
Returns: number - Random integer

ParamTypeDescription
minnumberMinimum value (inclusive)
maxnumberMaximum value (exclusive)

shuffle(arr) ⇒ Array

Shuffle array in place using seeded random

Kind: global function
Returns: Array - Shuffled array

ParamTypeDescription
arrArrayArray to shuffle

sample(arr, k) ⇒ Array

Sample without replacement

Kind: global function
Returns: Array - Sampled elements

ParamTypeDescription
arrArrayArray to sample from
knumberNumber of samples

trainTestSplit(X, y, options) ⇒ Object

Split data into train and test sets

Kind: global function
Returns: Object - {XTrain, XTest, yTrain, yTest, trainIndices, testIndices}

ParamTypeDescription
XArrayFeature matrix
yArrayTarget values (optional)
optionsObject{ratio, shuffle, seed}

kFold(X, y, k, shuffle) ⇒ Array.<Object>

K-Fold cross-validation generator

Kind: global function
Returns: Array.<Object> - Array of fold objects

ParamTypeDescription
XArrayFeature matrix
yArrayTarget values
knumberNumber of folds
shufflebooleanWhether to shuffle data

stratifiedKFold(X, y, k) ⇒ Array.<Object>

Stratified K-Fold for classification with balanced class distribution

Kind: global function
Returns: Array.<Object> - Array of fold objects

ParamTypeDescription
XArrayFeature matrix
yArrayTarget labels
knumberNumber of folds

groupKFold(X, y, groups, k) ⇒ Array.<Object>

Group K-Fold keeping group membership intact

Kind: global function
Returns: Array.<Object> - Array of fold objects

ParamTypeDescription
XArrayFeature matrix
yArrayTarget values
groupsArrayGroup labels
knumberNumber of folds

leaveOneOut(X, y) ⇒ Array.<Object>

Leave-One-Out cross-validation

Kind: global function
Returns: Array.<Object> - Array of fold objects

ParamTypeDescription
XArrayFeature matrix
yArrayTarget values

shuffleSplit(X, y, options) ⇒ Array.<Object>

Shuffle Split - repeated random train-test splits

Kind: global function
Returns: Array.<Object> - Array of split objects

ParamTypeDescription
XArrayFeature matrix
yArrayTarget values
optionsObject{nSplits, testRatio, seed}

crossValidate(fitFn, scoreFn, X, y, folds) ⇒ Object

Execute cross-validation with a model

Kind: global function
Returns: Object - {scores, meanScore, stdScore}

ParamTypeDescription
fitFnfunctionFunction that fits model: (XTrain, yTrain) => model
scoreFnfunctionFunction that scores model: (model, XTest, yTest) => score
XArrayFeature matrix
yArrayTarget values
foldsArray.<Object>Fold objects from kFold, etc.

fit()

Fit CCA model.

Accepts either numeric matrices (fit(XMatrix, YMatrix, options)) or a declarative object: fit({ X: ['col1', ...], Y: ['colA', ...], data, omit_missing, center, scale }).

Kind: global function

euclideanDistance(a, b) ⇒ number

Compute Euclidean distance between two points

Kind: global function
Returns: number - Distance

ParamTypeDescription
aArray.<number>First point
bArray.<number>Second point

computeDistanceMatrix(data) ⇒ Array.<Array.<number>>

Compute pairwise distance matrix

Kind: global function
Returns: Array.<Array.<number>> - Distance matrix

ParamTypeDescription
dataArray.<Array.<number>>Data points

clusterDistance(cluster1, cluster2, distances, linkage) ⇒ number

Find minimum distance between two clusters

Kind: global function
Returns: number - Distance between clusters

ParamTypeDescription
cluster1Array.<number>Indices in cluster 1
cluster2Array.<number>Indices in cluster 2
distancesArray.<Array.<number>>Distance matrix
linkagestringLinkage method

fit(X, options) ⇒ Object

Fit hierarchical clustering

Kind: global function
Returns: Object - {dendrogram, distances}

ParamTypeDescription
XArray.<Array.<number>>Data matrix
optionsObject{linkage: 'single'

cut(model, k) ⇒ Array.<number>

Cut dendrogram to get k clusters

Kind: global function
Returns: Array.<number> - Cluster assignments

ParamTypeDescription
modelObjectFitted HCA model
knumberNumber of clusters

cutHeight(model, height) ⇒ Array.<number>

Cut dendrogram at specific height

Kind: global function
Returns: Array.<number> - Cluster assignments

ParamTypeDescription
modelObjectFitted HCA model
heightnumberHeight to cut at

standardize(data, scale) ⇒ Object

Standardize data (center and optionally scale)

Kind: global function
Returns: Object - {standardized, means, sds}

ParamTypeDefaultDescription
dataArray.<Array.<number>>Data matrix
scalebooleanfalseIf true, scale to unit variance

fit(X, options) ⇒ Object

Fit PCA model

Kind: global function
Returns: Object - PCA model

ParamTypeDescription
XArray.<Array.<number>> | MatrixData matrix (n x p)
optionsObject{scale: boolean, center: boolean}

transform(model, X) ⇒ Array.<Object>

Transform new data using fitted PCA model

Kind: global function
Returns: Array.<Object> - Transformed scores

ParamTypeDescription
modelObjectFitted PCA model
XArray.<Array.<number>>New data

cumulativeVariance(model) ⇒ Array.<number>

Get cumulative variance explained

Kind: global function
Returns: Array.<number> - Cumulative variance explained

ParamTypeDescription
modelObjectFitted PCA model

fit(Y, X, options) ⇒ Object

Fit RDA model

Kind: global function
Returns: Object - RDA model

ParamTypeDescription
YArray.<Array.<number>>Response matrix (n x q)
XArray.<Array.<number>>Explanatory matrix (n x p)
optionsObject{scale: boolean}

transform(model, Y, X) ⇒ Array.<Object>

Transform new data using fitted RDA model

Kind: global function
Returns: Array.<Object> - Canonical scores

ParamTypeDescription
modelObjectFitted RDA model
YArray.<Array.<number>>New response data
XArray.<Array.<number>>New explanatory data

plotROC(yTrue, yProb, options) ⇒ Object

Generate ROC curve plot configuration

Kind: global function
Returns: Object - Plot configuration with ROC curve data and AUC

ParamTypeDescription
yTrueArray.<number>True binary labels (0 or 1)
yProbArray.<number>Predicted probabilities for positive class
optionsObject{width, height, showDiagonal}

plotPrecisionRecall(yTrue, yProb, options) ⇒ Object

Generate precision-recall curve plot configuration

Kind: global function
Returns: Object - Plot configuration with precision-recall curve and average precision

ParamTypeDescription
yTrueArray.<number>True binary labels (0 or 1)
yProbArray.<number>Predicted probabilities for positive class
optionsObject{width, height, showBaseline}

plotConfusionMatrix(yTrue, yPred, options) ⇒ Object

Generate confusion matrix plot configuration

Kind: global function
Returns: Object - Plot configuration with confusion matrix

ParamTypeDescription
yTrueArrayTrue labels
yPredArrayPredicted labels
optionsObject{width, height, normalize, labels}

plotCalibration(yTrue, yProb, options) ⇒ Object

Generate calibration curve plot configuration Shows how well predicted probabilities match actual frequencies

Kind: global function
Returns: Object - Plot configuration with calibration curve

ParamTypeDescription
yTrueArray.<number>True binary labels (0 or 1)
yProbArray.<number>Predicted probabilities
optionsObject{width, height, nBins}

ordiplot(result, options) ⇒ Object

Generate unified ordination plot configuration Works with PCA, LDA, and RDA results

Kind: global function
Returns: Object - Plot configuration

ParamTypeDescription
resultObjectOrdination result (from PCA, LDA, or RDA)
optionsObjectConfiguration options
options.typestringType of ordination ('pca', 'lda', 'rda') - auto-detected if not specified
options.colorBystring | nullArray of colors/groups for points (optional)
options.labelsArray.<string> | nullLabels for points (optional)
options.showLoadingsbooleanShow loading vectors (PCA/RDA only)
options.showCentroidsbooleanShow class centroids (LDA only)
options.showConvexHullsbooleanShow convex hulls around groups (optional)
options.axis1numberFirst axis to plot (default: 1)
options.axis2numberSecond axis to plot (default: 2)
options.widthnumberPlot width (default: 640)
options.heightnumberPlot height (default: 400)
options.loadingScalenumberScale factor for loading vectors (default: 3)

plotHCA(result) ⇒ Object

Generate dendrogram data structure

Kind: global function
Returns: Object - Dendrogram tree structure

ParamTypeDescription
resultObjectHCA result from mva.hca.fit()

dendrogramLayout(dendrogramData, options) ⇒ Object

Convert dendrogram to layout coordinates

Kind: global function
Returns: Object - Layout with coordinates

ParamTypeDescription
dendrogramDataObjectResult from plotHCA
optionsObject{width, height, orientation}

plotLDA(result, options) ⇒ Object

Generate LDA scatter plot configuration

Kind: global function
Returns: Object - Plot configuration

ParamTypeDescription
resultObjectLDA result from mva.lda.fit()
optionsObject{width, height, ldX, ldY}

plotPCA(result, options) ⇒ Object

Generate PCA biplot configuration

Kind: global function
Returns: Object - Plot configuration

ParamTypeDescription
resultObjectPCA result from mva.pca.fit()
optionsObject{colorBy, showLoadings, width, height}

plotScree(result, options) ⇒ Object

Generate PCA scree plot configuration

Kind: global function
Returns: Object - Plot configuration

ParamTypeDescription
resultObjectPCA result
optionsObject{width, height}

plotRDA(result, options) ⇒ Object

Generate RDA triplot configuration

Kind: global function
Returns: Object - Plot configuration

ParamTypeDescription
resultObjectRDA result from mva.rda.fit()
optionsObject{width, height, axis1, axis2}

attachShow(config) ⇒ Object

Attach a .show() helper to the configuration if marks are present.

Kind: global function
Returns: Object - The same config with a non-enumerable show() helper

ParamTypeDescription
configObjectPlot configuration object

plotFeatureImportance(importances, options) ⇒ Object

Generate feature importance bar plot configuration

Kind: global function
Returns: Object - Plot configuration

ParamTypeDescription
importancesArray.<Object>Feature importance array
optionsObject{width, height, topN}

plotPartialDependence(pdResult, options) ⇒ Object

Generate partial dependence plot configuration

Kind: global function
Returns: Object - Plot configuration

ParamTypeDescription
pdResultObjectResult from partialDependence()
optionsObject{width, height, featureName}

plotCorrelationMatrix(corrResult, options) ⇒ Object

Generate correlation matrix heatmap configuration

Kind: global function
Returns: Object - Plot configuration

ParamTypeDescription
corrResultObjectResult from correlationMatrix()
optionsObject{width, height}

plotResiduals(residualData, options) ⇒ Object

Generate residual plot configuration

Kind: global function
Returns: Object - Plot configuration

ParamTypeDescription
residualDataObjectResult from residualPlotData()
optionsObject{width, height, standardized}

plotQQ(residualData, options) ⇒ Object

Generate Q-Q plot configuration for normality check

Kind: global function
Returns: Object - Plot configuration

ParamTypeDescription
residualDataObjectResult from residualPlotData()
optionsObject{width, height}

erfInv(x) ⇒ number

Approximate error function inverse (for Q-Q plot)

Kind: global function
Returns: number - Inverse erf

ParamTypeDescription
xnumberInput value

plotLearningCurve(lcResult, options) ⇒ Object

Generate learning curve plot configuration

Kind: global function
Returns: Object - Plot configuration

ParamTypeDescription
lcResultObjectResult from learningCurve()
optionsObject{width, height}

fit(X, y, options) ⇒ Object

Fit OLS linear regression Supports two calling styles:

  • Array/matrix style (backward compatible): fit(X, y, { intercept })
  • Declarative table style: fit({ X: 'col' | ['col1','col2'], y: 'target', data, omit_missing, intercept })

Kind: global function
Returns: Object - {coefficients, fitted, residuals, rSquared, adjRSquared, se, n, p}

ParamTypeDescription
XArray.<Array.<number>> | Matrix | ObjectDesign matrix or options object when using table style
yArray.<number> | stringResponse vector or (when using array/matrix style) ignored if options object provided
optionsObject{ intercept: boolean, omit_missing: boolean } (when using array/matrix style)

predict(coefficients, X, options) ⇒ Array.<number>

Predict using fitted model

Kind: global function
Returns: Array.<number> - Predictions

ParamTypeDescription
coefficientsArray.<number>Model coefficients
XArray.<Array.<number>> | MatrixNew design matrix
optionsObject{intercept: boolean}

summary(model) ⇒ Object

Summary statistics for regression

Kind: global function
Returns: Object - Summary information

ParamTypeDescription
modelObjectFitted model from fit()

fit(X, y, groups, options) ⇒ Object

Fit simple random-intercept linear mixed model

Kind: global function
Returns: Object - {fixedEffects, randomEffects, varFixed, varRandom, logLikelihood}

ParamTypeDescription
XArray.<Array.<number>> | MatrixFixed effects design matrix
yArray.<number>Response vector
groupsArray.<(number|string)>Group indicators
optionsObject{intercept: boolean, maxIter: number, tol: number}

predict(model, X, groups, options) ⇒ Array.<number>

Predict using fitted LMM

Kind: global function
Returns: Array.<number> - Predictions

ParamTypeDescription
modelObjectFitted model
XArray.<Array.<number>> | MatrixDesign matrix
groupsArray.<(number|string)>Group indicators
optionsObject{intercept: boolean}

sigmoid(z) ⇒ number

Logistic (sigmoid) function

Kind: global function
Returns: number - Probability between 0 and 1

ParamTypeDescription
znumberInput value

fit(X, y, options) ⇒ Object

Fit logistic regression using IRLS

Kind: global function
Returns: Object - {coefficients, fitted, logLikelihood, iterations, converged}

ParamTypeDescription
XArray.<Array.<number>> | MatrixDesign matrix
yArray.<number>Binary response (0 or 1)
optionsObject{intercept: boolean, maxIter: number, tol: number}

predict(coefficients, X, options) ⇒ Array.<number>

Predict probabilities using fitted model

Kind: global function
Returns: Array.<number> - Predicted probabilities

ParamTypeDescription
coefficientsArray.<number>Model coefficients
XArray.<Array.<number>> | MatrixNew design matrix
optionsObject{intercept: boolean}

classify(probabilities, threshold) ⇒ Array.<number>

Classify based on threshold

Kind: global function
Returns: Array.<number> - Binary predictions (0 or 1)

ParamTypeDescription
probabilitiesArray.<number>Predicted probabilities
thresholdnumberClassification threshold