Univariate detector#

KNNCAD Detector#

from streamad.util import StreamGenerator, UnivariateDS, plot
from streamad.model import KNNDetector

ds = UnivariateDS()
stream = StreamGenerator(ds.data)
model = KNNDetector()
scores = []

for x in stream.iter_item():
    score = model.fit_score(x)
    scores.append(score)

data, label, date, features = ds.data, ds.label, ds.date, ds.features
plot(data=data,scores=scores,date=date,features=features,label=label)

Spot Detector#

from streamad.util import StreamGenerator, UnivariateDS, plot
from streamad.model import SpotDetector

ds = UnivariateDS()
stream = StreamGenerator(ds.data)
model = SpotDetector(back_mean_len=10)
scores = []

for x in stream.iter_item():
    score = model.fit_score(x)
    scores.append(score)

data, label, date, features = ds.data, ds.label, ds.date, ds.features
plot(data=data,scores=scores,date=date,features=features,label=label)

RRCF Detector#

from streamad.util import StreamGenerator, UnivariateDS, plot
from streamad.model import RrcfDetector

ds = UnivariateDS()
stream = StreamGenerator(ds.data)
model = RrcfDetector()
scores = []

for x in stream.iter_item():
    score = model.fit_score(x)
    scores.append(score)

data, label, date, features = ds.data, ds.label, ds.date, ds.features
plot(data=data,scores=scores,date=date,features=features,label=label)

Spectral Residual Detector#

from streamad.util import StreamGenerator, UnivariateDS, plot
from streamad.model import SRDetector

ds = UnivariateDS()
stream = StreamGenerator(ds.data)
model = SRDetector()
scores = []

for x in stream.iter_item():
    score = model.fit_score(x)
    scores.append(score)

data, label, date, features = ds.data, ds.label, ds.date, ds.features
plot(data=data,scores=scores,date=date,features=features,label=label)

Z-score Detector#

from streamad.util import StreamGenerator, UnivariateDS, plot
from streamad.model import ZScoreDetector

ds = UnivariateDS()
stream = StreamGenerator(ds.data)
model = ZScoreDetector()
scores = []

for x in stream.iter_item():
    score = model.fit_score(x)
    scores.append(score)

data, label, date, features = ds.data, ds.label, ds.date, ds.features
plot(data=data,scores=scores,date=date,features=features,label=label)

One-class SVM Detector#

from streamad.util import StreamGenerator, UnivariateDS, plot
from streamad.model import OCSVMDetector

ds = UnivariateDS()
stream = StreamGenerator(ds.data)
model = OCSVMDetector()
scores = []

for x in stream.iter_item():
    score = model.fit_score(x)
    scores.append(score)

data, label, date, features = ds.data, ds.label, ds.date, ds.features
plot(data=data,scores=scores,date=date,features=features,label=label)

Median Absolute Deviation Detector#

from streamad.util import StreamGenerator, UnivariateDS, plot
from streamad.model import MadDetector

ds = UnivariateDS()
stream = StreamGenerator(ds.data)
model = MadDetector()
model.detrend
scores = []

for x in stream.iter_item():
    score = model.fit_score(x)
    scores.append(score)

data, label, date, features = ds.data, ds.label, ds.date, ds.features
plot(data=data,scores=scores,date=date,features=features,label=label)

Seasonal Arima Detector#

from streamad.util import StreamGenerator, UnivariateDS, plot
from streamad.model import SArimaDetector

ds = UnivariateDS()
stream = StreamGenerator(ds.data)
model = SArimaDetector()
scores = []

for x in stream.iter_item():
    score = model.fit_score(x)
    scores.append(score)

data, label, date, features = ds.data, ds.label, ds.date, ds.features
plot(data=data,scores=scores,date=date,features=features,label=label)