
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
A inference library for Bayesian Networks made with TypeScript.
Currently there are three inferences algorithms:
Calculate the probability of a node's state.
This function receives a network, a node's state, and the knowing states and will return the probability of the node's state give.
As mentioned above, there are three inferences engines, by default the junction tree algorithm is used to execute the infer function.
import { infer, inferences } from 'bayesjs';
infer(network, nodes, give); // Junction tree algorithm
inferences.enumeration.infer(network, nodes, give);
inferences.variableElimination.infer(network, nodes, give);
inferences.junctionTree.infer(network, nodes, give);
Given the rain-sprinkler-grasswet network. Image here.
import { infer } from 'bayesjs';
const network = // ...
// What is the probability that it is raining (RAIN = T)?
infer(network, { 'RAIN': 'T' }).toFixed(4) // 0.2000
// What is the probability that it is raining (RAIN = T), given the sprinkler is off (SPRINKLER = F)?
infer(network, { 'RAIN': 'T' }, { 'SPRINKLER': 'F' }).toFixed(4) // 0.2920
Add a node in a Bayesian Network.
This function receives a network and a node, check if the node can be appended on the network. If something is wrong an exception will be thrown, otherwise, a new network will return with the node added.
import { addNode } from 'bayesjs';
const networkWithRainAndSprinkler = // ...
const grassWet = {
id: 'GRASS_WET',
states: [ 'T', 'F' ],
parents: [ 'RAIN', 'SPRINKLER' ],
cpt: [
{ when: { 'RAIN': 'T', 'SPRINKLER': 'T' }, then: { 'T': 0.99, 'F': 0.01 } },
{ when: { 'RAIN': 'T', 'SPRINKLER': 'F' }, then: { 'T': 0.8, 'F': 0.2 } },
{ when: { 'RAIN': 'F', 'SPRINKLER': 'T' }, then: { 'T': 0.9, 'F': 0.1 } },
{ when: { 'RAIN': 'F', 'SPRINKLER': 'F' }, then: { 'T': 0, 'F': 1 } }
]
};
const newtwork = addNode(networkWithRainAndSprinkler, grassWet);
MIT
FAQs
Inference on Bayesian Networks
The npm package bayesjs receives a total of 121 weekly downloads. As such, bayesjs popularity was classified as not popular.
We found that bayesjs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.