npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@agentix-e/causality-analyzer-pipeline

v0.1.0

Published

Causality Analyzer Pipeline — anomaly detection, causal graph discovery, RCA analysis, causal inference

Downloads

254

Readme

@agentix-e/causality-analyzer-pipeline

Complete causal AI pipeline — anomaly detection, causal discovery, root cause analysis, effect estimation, counterfactual reasoning, and model evaluation.

npm

Overview

@agentix-e/causality-analyzer-pipeline is the causal reasoning engine. It implements the full stack from raw metric ingestion to counterfactual "what-if" analysis, including academic-grade sensitivity testing and graph validation.

Architecture

Raw Data → Standardize → Detect Anomalies
                                ↓
              Causal Discovery (PC / FCI / Targeted)
                                ↓
              Root Cause Analysis (Bayesian / HT / RandomWalk / CIRCA)
                                ↓
              Effect Estimation (Backdoor / Frontdoor / IV / PS / DR)
                                ↓
              Sensitivity & Refutation (E-value / pR² / Bootstrap)
                                ↓
              Counterfactual Reasoning (SCM → Abduction → Action → Prediction)
                                ↓
              Model Evaluation (R² / MSE / Shapley RCA / Distribution Change)

Installation

npm install @agentix-e/causality-analyzer-pipeline
npm install @agentix-e/causality-analyzer-core  # peer dependency

Quick Start

1. Anomaly Detection

import { StatsDetector, SpectralResidualDetector, VotingDetector } from '@agentix-e/causality-analyzer-pipeline';

// Z-score detector
const detector = new StatsDetector({ method: 'zscore' });
detector.train(normalData);
const result = detector.update([5.2, 8.1]);  // anomalous!

// Ensemble voting
const ensemble = new VotingDetector({
  detectors: [statsDetector, srDetector],
  strategy: 'majority',
});
const voted = ensemble.detect(dataPoints);

2. Causal Discovery

import { Matrix } from 'ml-matrix';
import { pcAlgorithm, fciAlgorithm, targetedDiscovery } from '@agentix-e/causality-analyzer-pipeline';

// PC algorithm (no latent confounders)
const { graph } = pcAlgorithm(data, ['CPU', 'Memory', 'Latency']);

// FCI algorithm (with latent confounders)
const { pagEdges } = fciAlgorithm(data, nodeNames);

// Targeted: only find parents of 'Latency'
const parents = targetedDiscovery(data, ['Latency'], nodeNames);

3. Root Cause Analysis

import { CausalGraph, BayesianRCA, HTRCA, CIRCAPipeline } from '@agentix-e/causality-analyzer-pipeline';

// Bayesian Network RCA
const rca = new BayesianRCA();
rca.train(graph, anomalousNodes, data);
const result = rca.findRootCauses(['CPU', 'Latency']);

// Hypothesis Testing RCA (regression residuals)
const ht = new HTRCA();
ht.train(graph, data);
const htResult = ht.findRootCauses(['CPU', 'Latency'], data);

// CIRCA Pipeline (KDD 2022)
const circa = new CIRCAPipeline(graph);
const circaResult = circa.analyze(anomalyData, ['CPU', 'Latency']);

4. Causal Effect Estimation

import {
  adjustBackdoor, estimateIV, estimatePSMatching, estimateDoublyRobust
} from '@agentix-e/causality-analyzer-pipeline';

// Backdoor adjustment
const { ate, se } = adjustBackdoor(graph, 'Treatment', 'Outcome', data, nodeIndex);

// Instrumental Variables (2SLS)
const ivResult = estimateIV(data, treatmentIdx, outcomeIdx, ivIdx);

// Propensity Score Matching
const psmResult = estimatePSMatching(data, treatmentIdx, outcomeIdx, [confounderIdx]);

// Doubly Robust
const drResult = estimateDoublyRobust(data, treatmentIdx, outcomeIdx, [confounderIdx]);

5. Sensitivity Analysis

import { eValueSensitivity, robustnessValue } from '@agentix-e/causality-analyzer-pipeline';

const { eValue, interpretation } = eValueSensitivity(0.8);
// "E-value=4.22: strong robustness — only very strong unmeasured confounding..."

const { rv } = robustnessValue(0.8, 0.1, 1000);
// "RV=3.15: ROBUST — causal conclusion is well-supported"

6. Counterfactual Reasoning

import { CausalGraph, StructuralCausalModel } from '@agentix-e/causality-analyzer-pipeline';

const scm = new StructuralCausalModel(graph);
scm.train(data);

// What would latency be if we doubled memory?
const noise = scm.abduct({ Memory: 0.5, CPU: 0.8, Latency: 120 });
const cf = scm.counterfactual(noise, { Memory: 1.0 });

// Shapley-based anomaly attribution
import { shapleyAttribute } from '@agentix-e/causality-analyzer-pipeline';
const shapleyRCA = shapleyAttribute(scm, anomalousObservation, 5);

API Reference

📚 Full TypeDoc API: pnpm docs from the monorepo root.

Module Index

| Module | Key Exports | |--------|------------| | data/standardizer | standardize, discretize, extractWindows, imputeMean | | detect/stats-detector | StatsDetector (zscore/mad/iqr) | | detect/spectral-residual | SpectralResidualDetector (FFT-based) | | detect/spot | SPOTDetector, DSPOTDetector (extreme value) | | detect/voting-detector | VotingDetector (majority/max/weighted) | | graph/causal-graph | CausalGraph (DAG/PDAG/CPDAG) | | graph/pc | pcAlgorithm, fisherZTest | | graph/advanced-discovery | fciAlgorithm, growShrink, targetedDiscovery | | analyze/rca | BayesianRCA, RandomWalkRCA, HTRCA, FPGrowthRCA | | analyze/circa | RHTScorer, DAScorer, CIRCAPipeline | | infer/causal-inference | CausalAnalysis, identifyBackdoor, identifyFrontdoor, refutePlaceboTreatment, refuteBootstrap | | infer/effect-estimation | adjustBackdoor, estimateFrontdoor, estimateIV, estimatePSMatching, estimateDoublyRobust | | infer/sensitivity | eValueSensitivity, partialRSensitivity, robustnessValue | | infer/do-calculus | identifyByDoCalculus (3 rules + ID algorithm) | | infer/mediation | naturalDirectEffect, arrowStrength | | infer/cate-fairness | estimateCATE, estimateIPW, checkFairness | | infer/bootstrap-ci | bootstrapATE, bootstrapATEParallel, parallelBootstrap | | gcm/structural-causal-model | StructuralCausalModel, cateToRCA | | gcm/model-evaluation | evaluateMechanismR2, evaluateMSE, shapleyAttribute, bootstrapRCA | | gcm/nonlinear-mechanisms | PostNonlinearMechanism, fitLogisticPNL, autoAssignMechanisms, parentRelevance | | gcm/distribution-change | detectMechanismChanges, distributionChangeRobust, changeAttributionCI | | gcm/graph-falsification | falsifyGraph, lmcFalsification | | viz/viz-data | buildGraphVizData, buildTimeseriesVizData, buildRankingVizData | | viz/fusion | FusionAnalyzer (metric + trace + log) |

Deterministic Reproducibility

All stochastic algorithms accept an optional seed parameter for reproducible results:

// With seed → deterministic
const result = shapleyAttribute(scm, obs, 5, seed);
const ci = bootstrapRCA(scm, obs, 200, 0.05, seed);

// Without seed → non-deterministic (uses Math.random)
const result2 = shapleyAttribute(scm, obs, 5);

License

MIT