Bayes
Learn how to use Bayes algorithms in @kanaries/ml for JavaScript and TypeScript machine learning projects.
How to use the Bayes module in real projects
The Bayes module is ideal for fast probabilistic baselines in JavaScript, especially when you need interpretable class probabilities and low-latency inference.
Selection checklist
- Start with BernoulliNB for binary/count-like feature presence signals (for example, flags or bag-of-words indicators).
- Use CategoricalNB when each feature is a discrete category index instead of a continuous value.
- Evaluate probability calibration and confusion matrix metrics before moving to more complex models.
Common implementation workflow
- Start from a simple baseline in this module and evaluate on a holdout split.
- Compare at least one alternative algorithm from this module before locking production defaults.
- Pair model quality metrics with runtime constraints (latency, memory, bundle size).
Common search intents
naive bayes javascriptcategorical naive bayes typescriptbernoulli nb browser ml
Explore algorithms in this module
FAQ
What problem does Bayes solve in JavaScript machine learning projects?
Bayes helps teams implement production-ready ML workflows in browser and Node.js environments with a familiar scikit-learn-style API.
When should I choose Bayes instead of other Bayes algorithms?
Use Bayes 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 Bayes 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.