API Reference
Complete reference documentation for all tangent/ds modules and functions.
Modules
| Module | Namespace | Description |
|---|---|---|
| Statistics | ds.stats |
GLM, hypothesis tests, distributions, model comparison |
| Machine Learning | ds.ml |
KNN, trees, forests, MLP, preprocessing, validation |
| Multivariate Analysis | ds.mva |
PCA, LDA, RDA, CCA ordination methods |
| Visualization | ds.plot |
Observable Plot configs for biplots, ROC, diagnostics |
| Core Utilities | ds.core |
Math, linear algebra, tables, formulas, optimization |
Usage Pattern
Most tangent/ds classes follow the fit-predict pattern:
import * as ds from '@tangent/ds';
// 1. Create a model
const model = new ds.ml.KNNClassifier({ k: 5 });
// 2. Fit to data (Table API)
model.fit({ data: myData, X: ['feature1', 'feature2'], y: 'target' });
// 3. Make predictions
const predictions = model.predict({ data: newData, X: ['feature1', 'feature2'] });
Input Styles
All estimators support multiple input styles:
Table API (recommended):
model.fit({ data: myData, X: ['col1', 'col2'], y: 'target' })
Array API:
model.fit(X, y)
Formula API (GLM only):
model.fit({ formula: 'y ~ x1 + x2', data: myData })
Serialization
All models support persistence via JSON:
const json = model.toJSON();
const restored = ModelClass.fromJSON(json);