ChangePoint API Reference

class changepoint.ArgpCpd(scale=0.5, length_scale=10.0, noise_level=0.01, max_lag=3, alpha0=2.0, beta0=1.0, logistic_hazard_h=..., logistic_hazard_a=1.0, logistic_hazard_b=1.0)

Autoregressive Gaussian Process Change Point detection

Based on Ryan Turner’s [thesis](https://www.repository.cam.ac.uk/bitstream/handle/1810/242181/thesis.pdf?sequence=1&isAllowed=y).

Parameters:
scale: float

Scale of the ConstantKernel

length_scale:float

Length Scale of RBFKernel

noise_level: float

Noise standard deviation for the WhiteKernel

max_lag: int > 0

Maximum Autoregressive lag

alpha0float

Scale Gamma distribution alpha parameter

beta0: float

Scale Gamma distribution beta parameter

logistic_hazard_h: float

Hazard scale in logit units.

logistic_hazard_a: float

Roughly the slope of the logistic hazard function

logistic_hazard_b: float

The offset of the logistic hazard function.

Methods

reset()

Reset the argpcpd to starting state

step(datum)

Observe a new datum and return the run length probabilities

reset()

Reset the argpcpd to starting state

step(datum)

Observe a new datum and return the run length probabilities

Parameters:
datum: float

Next datum in the data stream.

Returns:
List[float]

A list of change point probabilities.

changepoint.BetaBernoulli(alpha=0.5, beta=0.5)

Beta prior on a Bernoulli random variable.

Parameters:
alpha: float > 0

alpha parameter of beta distribution

beta: float > 0

beta parameter of beta distribution

Returns:
Beta prior on Bernoulli distribution
Raises:
ValueError: alpha or beta is <= 0, infinite, or NaN
class changepoint.Bocpd(prior, lam)

Online Bayesian Change Point Detection state container Create a new BOCPD

Parameters:
prior: Prior

The (conjugate) prior, which also describes the likelihood distribution for the stream.

lam: float

Expected mean run length. A smaller value means changepoints are believed to occur at shorter intervals.

Raises:
ValueError: lam <= 0.0

Methods

reset()

Reset the Bocpd to the new state

step(datum)

Observe a new datum.

reset()

Reset the Bocpd to the new state

step(datum)

Observe a new datum. Returns the run length probabilities for each step.

changepoint.NormalGamma(m=0.0, r=1.0, s=1.0, v=1.0)

Normal Gamma prior on univariate Normal random variable.

Parameters:
m: float

Prior mean

r: float > 0.0
s: float > 0.0
v: float > 0.0
Returns:
Normal Gamma-Square prior
Raises:
ValueError:
  • m, r, s, v is infinite or NaN,

  • r, s, v <= 0.0

changepoint.NormalInvChiSquared(m=0.0, k=1.0, v=1.0, s2=1.0)

Normal Inverse-Chi-Squared prior on univariate Normal random variable.

Parameters:
m: float

Prior mean

k: float > 0.0

Amount of confidence in the prior mean; measured in pseudo observations.

v: float > 0.0

Amount of confidence in the prior variance; measured in pseudo observations.

s2: float > 0.0

Prior variance

Returns:
Normal Inverse-Chi-Square prior
Raises:
ValueError:
  • m, k, v, s2 is infinite or NaN,

  • k, v, s2 <= 0.0

changepoint.NormalInvGamma(m=0.0, v=1.0, a=1.0, b=1.0)

Normal Inverse-Gamma prior on univariate Normal random variable.

Parameters:
m: float

Prior mean

v: float > 0.0
a: float > 0.0
b: float > 0.0
Returns:
Normal Inverse-Gamma prior
Raises:
ValueError:
  • m, v, a, b is infinite or NaN,

  • v, a, b <= 0.0

changepoint.NormalInvWishart(mu, k, df, scale)

Normal Inverse-Wishart prior on multivariate Normal random variable.

changepoint.PoissonGamma(shape=1.0, rate=1.0)

Gamma prior on a Poisson random variable.

Parameters:
shape: float > 0

The Gamma distribution shape parameter

rate: float > 0

The Gamma distribution rate parameter

Returns:
Gamma prior on Poisson
Raises:
ValueError: shape or rate is <= 0, infinite, or NaN
class changepoint.Prior(kind, *args)

Prior distribution, which also describes the liklihood distribution of the change point detector.

Methods

beta_bernoulli

normal_gamma

normal_inv_chi_squared

normal_inv_gamma

normal_inv_wishart

poisson_gamma

static beta_bernoulli(alpha=0.5, beta=0.5)
static normal_gamma(m=0.0, r=1.0, s=1.0, v=1.0)
static normal_inv_chi_squared(m=0.0, k=1.0, v=1.0, s2=1.0)
static normal_inv_gamma(m=0.0, v=1.0, a=1.0, b=1.0)
static normal_inv_wishart(mu, k, df, scale)
static poisson_gamma(shape=1.0, rate=1.0)
changepoint.infer_changepoints(history, n_samples)

Given the runlength probabilities vector for each step, and a Monte Carlo step size, return the probability that a change point occurred on a given step.

Parameters:
history: List[List[float]]

Run length probabilities for a sequence of observations.

n_samples: int

Number of samples to draw from run-length process.

changepoint.infer_pseudo_cmf_changepoints(history, n_samples)

Creates a pseudo cmf distribution for change-point locations.

This calculates the cumulative sum of the infer_changepoints return value mod 1.0.

Parameters:
history: List[List[float]]

Run length probabilities for a sequence of observations.

n_samples: int

Number of samples to draw from run-length process.

changepoint.map_changepoints(history)

Returns the most likely index (step) that a changepoint occurred. Each point corresponds to an individual changepoint.

Parameters:
history: List[List[float]]

Run length probabilities for a sequence of observations.