OPTICS
API and practical guide for OPTICS in @kanaries/ml, including when to use it in JavaScript and TypeScript ML workflows.
Clusters.OPTICS
interface OPTICSOptions {
min_samples?: number;
max_eps?: number;
metric?: Distance.IDistanceType;
p?: number;
eps?: number;
}
constructor(options: OPTICSOptions = {})fitPredict(samplesX: number[][]): number[] returns cluster labels. Noise points are marked as -1.
const optics = new OPTICS({ eps: 0.5, min_samples: 5 });
const labels = optics.fitPredict(X);Practical guide: OPTICS in JavaScript and TypeScript
OPTICS captures density-based cluster structure across multiple scales and handles varying-density datasets.
When to use OPTICS
- DBSCAN-style sensitivity to a single epsilon is too limiting.
- You need ordering information to inspect hierarchical density structure.
- Noise handling is required for reliable segmentation.
Implementation workflow
- Prepare distance-scaled features and configure neighborhood constraints.
- Fit and analyze reachability or extracted cluster labels.
- Tune min-samples and extraction thresholds for your target behavior.
JavaScript deployment notes
- Prefer feature scaling for distance-based and gradient-based algorithms to improve stability.
- In browser apps, run heavy training in Web Workers to keep UI interactions smooth.
- Keep a simple baseline from the same module as a fallback model for comparison.
Search intents this page targets
OPTICS JavaScriptOPTICS TypeScriptOPTICS browser machine learning@kanaries/ml OPTICS
FAQ
What problem does OPTICS solve in JavaScript machine learning projects?
OPTICS helps teams implement production-ready ML workflows in browser and Node.js environments with a familiar scikit-learn-style API.
When should I choose OPTICS instead of other Clusters algorithms?
Use OPTICS when it best matches your data shape, labeling strategy, and runtime constraints. Benchmark against at least one alternative in the same module before finalizing defaults.
Can I run OPTICS in both browser and Node.js with @kanaries/ml?
Yes. @kanaries/ml is designed for JavaScript and TypeScript runtimes across browser applications, server-side Node.js services, and edge-friendly workflows.