Skip to content

Commit

Permalink
Fixing corner case in local anomaly detectors trained with one row
Browse files Browse the repository at this point in the history
  • Loading branch information
mmerce committed Jun 10, 2020
1 parent 9310f2a commit 513b9d3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
6 changes: 6 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
History
-------

4.32.1 (2020-06-10)
~~~~~~~~~~~~~~~~~~~

- Fixing local anomaly scores prediction for corner cases of samples with
one row.

4.32.0 (2020-05-19)
~~~~~~~~~~~~~~~~~~~

Expand Down
8 changes: 5 additions & 3 deletions bigml/anomaly.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def __init__(self, anomaly, api=None):
"Score will"
" not be available")
else:
default_depth = (
2 * (DEPTH_FACTOR + \
default_depth = self.mean_depth if \
self.sample_size == 1 else (2 * (DEPTH_FACTOR + \
math.log(self.sample_size - 1) - \
(float(self.sample_size - 1) / self.sample_size)))
self.expected_mean_depth = min(self.mean_depth,
Expand Down Expand Up @@ -128,7 +128,9 @@ def anomaly_score(self, input_data):
value between 0 and 1.
"""

# corner case with only one record
if self.sample_size == 1:
return 1
# Checks and cleans input_data leaving the fields used in the model
input_data = self.filter_input_data(input_data)

Expand Down
2 changes: 1 addition & 1 deletion bigml/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '4.32.0'
__version__ = '4.32.1'
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.. toctree::
:hidden:

index
ml_resources
creating_resources
101_model
Expand Down

0 comments on commit 513b9d3

Please sign in to comment.