Sign In

causal-tree-decomposition

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

causal-tree-decomposition

Standalone causal tree probability engine. Decompose predictions into weighted causal nodes, compute combined probability, sensitivity analysis, what-if scenarios. Zero dependencies.

latest
Source
npmnpm
Version
2.0.0
Version published
Weekly downloads
5
400%
Maintainers
1
Weekly downloads
 
Created
Source

causal-tree-decomposition

Decompose complex predictions into causal trees. Compute combined probability, run sensitivity analysis and what-if scenarios. Zero dependencies.

npm

import { CausalTree, node, or } from 'causal-tree-decomposition'

const tree = new CausalTree('Oil exceeds $100 by Dec 2026')
tree.add(or('Supply disruption', 0.3, [
  node('Hormuz closure', 0.15),
  node('Russia further cuts', 0.2),
]))
tree.add(node('OPEC cuts production', 0.25))

tree.compute()                        // 0.52
tree.sensitivity()                    // [{ label: 'OPEC cuts', impact: 0.12 }, ...]
tree.whatIf('Hormuz closure', 0.95)   // { probability: 0.81, delta: +0.29 }
console.log(tree.toString())

Install

npm install causal-tree-decomposition

API

  • CausalTree(title, operator?) — create tree (default OR)
  • .add(node) — add root node
  • .compute() — combined probability
  • .sensitivity() — which nodes matter most
  • .whatIf(label, newProb) — counterfactual
  • .toJSON() / fromJSON() — serialize
  • .toString() — pretty print
  • .flatten() — all leaf nodes

Helpers

  • node(label, prob) — leaf node
  • or(label, prob, children?) — OR node
  • and(label, prob, children?) — AND node

License

MIT — SimpleFunctions

Keywords

causal-inference

FAQs

Package last updated on 06 Apr 2026

Did you know?

Socket

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.

Install

Related posts