Skip to content

Commit 1980c36

Browse files
authored
Merge pull request #2 from selimfirat/develop
v0.1.1 update
2 parents 6c588dc + 7c0a93e commit 1980c36

File tree

10 files changed

+19
-17
lines changed

10 files changed

+19
-17
lines changed

deploy.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
rm -rf ./build/ ./dist/ ./pysad.egg-info/
3+
python3 setup.py sdist bdist_wheel
4+
python3 -m twine upload dist/*

docs/features.rst

+3-4
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@ Streaming methods efficiently handle the limitied memory and processing time req
1616
Streaming Anomaly Detection Tools
1717
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1818

19-
`PySAD` contains stream simulators, evaluators, preprocessors, statistic trackers, postprocessors, probability calibrators and more.
20-
In addition to streaming models, `PySAD` also provides integrations for batch anomaly detectors of the `PyOD framework <https://github.com/yzhao062/pyod/>`_ so that they can be used in the streaming setting.
19+
`PySAD` contains stream simulators, evaluators, preprocessors, statistic trackers, postprocessors, probability calibrators and more. In addition to streaming models, `PySAD` also provides integrations for batch anomaly detectors of the `PyOD <https://github.com/yzhao062/pyod/>`_ so that they can be used in the streaming setting.
2120

2221

2322
Comprehensiveness
2423
^^^^^^^^^^^^^^^^^
2524

26-
`PySAD` provides models that are specifically designed for multivariate and univariate data. One can experiment via `PySAD` in supervised, semi-supervised and unsupervised setting.
25+
`PySAD` serves models that are specifically designed for both univariate and multivariate data. Furthermore, one can experiment via `PySAD` in supervised, semi-supervised and unsupervised setting.
2726

2827

2928
User Friendly
@@ -35,4 +34,4 @@ Users with any experience level can easily use `PySAD`. One can easily design ex
3534
Free and Open Source Software (FOSS)
3635
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3736

38-
`PySAD` is distributed under `3-Clause BSD License` and favors FOSS principles.
37+
`PySAD` is distributed under `BSD License 2.0 <https://github.com/selimfirat/pysad/blob/master/LICENSE>`_ and favors FOSS principles.

docs/license.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
License
22
=======
33

4-
This project is licensed under the `3-Clause BSD License <../LICENSE>`_.
4+
This project is licensed under the `BSD License 2.0 <https://github.com/selimfirat/pysad/blob/master/LICENSE>`_.
55

66
.. literalinclude:: ../LICENSE

examples/example_probability_calibration.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
np.random.seed(61) # Fix seed.
1010

1111
model = xStream() # Init model.
12-
calibrator = ConformalProbabilityCalibrator(windowed=True, window_size=300) # Init probability calibrator.
13-
streaming_data = Data().get_iterator("arrhythmia.mat") # Get streamer.
12+
calibrator = ConformalProbabilityCalibrator(windowed=True, window_size=300) # Init probability calibrator.
13+
streaming_data = Data().get_iterator("arrhythmia.mat") # Get streamer.
1414

1515
for i, (x, y_true) in enumerate(streaming_data): # Stream data.
1616
anomaly_score = model.fit_score_partial(x) # Fit to an instance x and score it.
1717

1818
calibrated_score = calibrator.fit_transform(anomaly_score) # Fit & calibrate score.
1919

2020
# Output if the instance is anomalous.
21-
if calibrated_score < 0.05: # If probability is less than 5%.
21+
if calibrated_score > 0.95: # If probability of being normal is less than 5%.
2222
print(f"Alert: {i}th data point is anomalous.")

examples/example_usage_short.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
from pysad.models import LODA
44
from pysad.utils import Data
55

6+
67
model = LODA() # Init model
78
metric = AUROCMetric() # Init area under receiver-operating- characteristics curve metric
8-
streaming_data = Data().get_iterator("arrhythmia.mat") # Get data streamer.
9+
streaming_data = Data().get_iterator("arrhythmia.mat") # Get data streamer.
910

1011
for x, y_true in streaming_data: # Stream data.
1112
anomaly_score = model.fit_score_partial(x) # Fit the instance to model and score the instance.

pysad/models/xstream.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ def score_partial(self, X):
7777
return score
7878

7979
def _compute_deltamax(self):
80-
#mx = np.max(np.concatenate(self.ref_window, axis=0), axis=0)
81-
#mn = np.min(np.concatenate(self.ref_window, axis=0), axis=0)
80+
# mx = np.max(np.concatenate(self.ref_window, axis=0), axis=0)
81+
# mn = np.min(np.concatenate(self.ref_window, axis=0), axis=0)
8282
mn, mx = get_minmax_array(np.concatenate(self.ref_window, axis=0))
8383

8484
deltamax = (mx - mn) / 2.0

pysad/transform/ensemble/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
The :mod:`pysad.transform.ensemble` module consist of ensemblers to combine scores from multiple anomaly detectors.
33
"""
4-
from .ensemblers import MaximumScoreEnsembler,AverageScoreEnsembler,MedianScoreEnsembler, PYODScoreEnsembler, AverageOfMaximumScoreEnsembler, MaximumOfAverageScoreEnsembler
4+
from .ensemblers import MaximumScoreEnsembler, AverageScoreEnsembler, MedianScoreEnsembler, AverageOfMaximumScoreEnsembler, MaximumOfAverageScoreEnsembler
55

66
__all__ = ["MaximumScoreEnsembler", "MedianScoreEnsembler", "AverageScoreEnsembler", "MaximumOfAverageScoreEnsembler", "AverageOfMaximumScoreEnsembler"]

pysad/transform/probability_calibration/conformal_prediction.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,4 @@ def transform_partial(self, score):
3939
Returns:
4040
float: Processed score.
4141
"""
42-
43-
return (np.sum(np.array(self.window.get()) <= score))/ (len(self.window.get()))
44-
42+
return (np.sum(np.array(self.window.get()) > score)) / (len(self.window.get()))

pysad/transform/probability_calibration/gaussian_tail.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def transform_partial(self, score):
5454
else:
5555
std = 1.0
5656

57-
return self._qfunction(score, mean, std)
57+
return 1 - self._qfunction(score, mean, std)
5858

5959
def _qfunction(self, x, mean, std):
6060
"""

pysad/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121
# 'X.Y.dev0' is the canonical version of 'X.Y.dev'
2222
#
2323

24-
__version__ = '0.1.0'
24+
__version__ = '0.1.1'

0 commit comments

Comments
 (0)