https://github.com/mathew-kurian/bayesianchangepointjs
📈Pure JavaScript/TypeScript Bayesian changepoint detection for Browsers & NodeJS
https://github.com/mathew-kurian/bayesianchangepointjs
alerts analysis bayesian browser changepoint commonjs detection javascript nodejs typescript
Last synced: 11 months ago
JSON representation
📈Pure JavaScript/TypeScript Bayesian changepoint detection for Browsers & NodeJS
- Host: GitHub
- URL: https://github.com/mathew-kurian/bayesianchangepointjs
- Owner: mathew-kurian
- Created: 2020-04-01T04:55:10.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-30T20:00:08.000Z (over 3 years ago)
- Last Synced: 2025-08-19T15:40:08.933Z (11 months ago)
- Topics: alerts, analysis, bayesian, browser, changepoint, commonjs, detection, javascript, nodejs, typescript
- Language: TypeScript
- Homepage: https://arxiv.org/pdf/0710.3742.pdf
- Size: 97.7 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Bayesian Online ChangePoint JS Detection
[](https://codesandbox.io/s/hopeful-hawking-vpftt?fontsize=14&hidenavigation=1&theme=dark)
Pure JavaScript/TypeScript implementation of [Bayesian Online Changepoint](https://arxiv.org/pdf/0710.3742.pdf) detection which runs for Browsers & NodeJS.
## Example
```typescript
import assert from "assert";
import BayesianChangePoint, { BreakPoint } from "bayesian-changepoint";
const breakpointVerifier = (
next: BreakPoint,
prev: BreakPoint
): boolean => {
if (Math.abs(next.data - prev.data) >= 5) {
return true;
}
return false;
};
const values = (breakPoints: BreakPoint[]): number[] => {
return breakPoints.map(breakPoint => breakPoint.data);
};
const indicies = (breakPoints: BreakPoint[]): number[] => {
return breakPoints.map(breakPoint => breakPoint.index);
};
const detection = new BayesianChangePoint({
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
```bash
npm install
npm test
```
## Credits
Based off of [Bayesian Online Changepoint](https://arxiv.org/pdf/0710.3742.pdf)