# Thresholder#

Thresholder can help you to normalize the score into a range of 0 to 1, where 1 represents the anomalies.

All thresholders can work in two ways:

1. Global way (with parameter is_global = True): It can “remember” the distribution of all history scores with little memory usage.

2. Rolling way (with parameter is_global = Flase): It only keeps the score within a rolling window, and uses them as references.

## ZScore Thresholder#

It reports the scores that beyond k times (sigma) of standard deviation as anomalies.

from streamad.util import StreamGenerator, UnivariateDS, plot

ds = UnivariateDS()
stream = StreamGenerator(ds.data)
model = ZScoreThresholder(detector=KNNDetector(),sigma=2)

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)