SkillAgentSearch skills...

BayesianChangePointJS

๐Ÿ“ˆPure JavaScript/TypeScript Bayesian changepoint detection for Browsers & NodeJS

Install / Use

npx skills add mathew-kurian/BayesianChangePointJS

Installs into whichever agent you are using.

About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Bayesian Online ChangePoint JS Detection

Edit BayesianChangePointJS

Pure JavaScript/TypeScript implementation of Bayesian Online Changepoint detection which runs for Browsers & NodeJS.

Example

import assert from "assert";
import BayesianChangePoint, { BreakPoint } from "bayesian-changepoint";

const breakpointVerifier = (
  next: BreakPoint<number>,
  prev: BreakPoint<number>
): boolean => {
  if (Math.abs(next.data - prev.data) >= 5) {
    return true;
  }

  return false;
};

const values = (breakPoints: BreakPoint<number>[]): number[] => {
  return breakPoints.map(breakPoint => breakPoint.data);
};

const indicies = (breakPoints: BreakPoint<number>[]): number[] => {
  return breakPoints.map(breakPoint => breakPoint.index);
};

const detection = new BayesianChangePoint<number>({
  breakpointVerifier
});

detection.exec([10, 10, 10, 10, 5000, 5000, 5000, 5000, 30, 30, 30, 30, 30]);

assert.deepEqual(values(detection.breakPoints()), [5000, 30]);
assert.deepEqual(indicies(detection.breakPoints()), [4, 8]);

Installation

npm install
npm test

Credits

Based off of Bayesian Online Changepoint

Related Skills

View on GitHub
GitHub Stars6
CategoryDevelopment
Updated1y ago
Forks1

Languages

TypeScript

Security Score

60/100

Audited on Dec 8, 2024

No findings