Skip to content

Commit

Permalink
DSN random state fix and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KulikDM committed Dec 5, 2023
1 parent a875c6b commit e84e8bb
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand Down Expand Up @@ -42,7 +42,7 @@ repos:
name: Sort imports

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.1.4
rev: v0.1.7
hooks:
- id: ruff
args: [--exit-non-zero-on-fix, --fix, --line-length=180]
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ smallest uncertainty about its mean and is the most robust (best least
accurate prediction). However, for interpretability and general
performance the ``FILTER`` thresholder is a good fit.

Further utilities are available for assiting in the selection of the
Further utilities are available for assisting in the selection of the
most optimal outlier detection and thresholding methods `ranking
<https://pythresh.readthedocs.io/en/latest/ranking.html>`_ as well as
determining the confidence with regards to the selected thresholding
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ provided the smallest uncertainty about its mean and is the most robust
(best least accurate prediction). However, for interpretability and
general performance the ``FILTER`` thresholder is a good fit.

Further utilities are available for assiting in the selection of the
Further utilities are available for assisting in the selection of the
most optimal outlier detection and thresholding methods `ranking
<https://pythresh.readthedocs.io/en/latest/ranking.html>`_ as well as
determining the confidence with regards to the selected thresholding
Expand Down
10 changes: 6 additions & 4 deletions pythresh/test/test_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,17 @@ def setUp(self):
self.methods = ['gaussian', 'savgol', 'hilbert', 'wiener', 'medfilt',
'decimate', 'detrend', 'resample']

self.sigma = 'auto'
pre_sig = len(scores)

self.sigmas = ['auto', int(pre_sig**0.6), int(pre_sig**75)]

def test_prediction_labels(self):

params = product(self.all_scores, self.methods)
params = product(self.all_scores, self.methods, self.sigmas)

for scores, method in params:
for scores, method, sigma in params:

self.thres = FILTER(method=method, sigma=self.sigma)
self.thres = FILTER(method=method, sigma=sigma)
pred_labels = self.thres.eval(scores)
assert (self.thres.thresh_ is not None)

Expand Down
3 changes: 2 additions & 1 deletion pythresh/thresholds/dsn.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ def _MAH_metric(self):
"""Calculate the Mahalanobis distance."""

# fit a Minimum Covariance Determinant (MCD) robust estimator to data
robust_cov = MinCovDet().fit(np.array([self.val_norm]).T)
robust_cov = MinCovDet(random_state=self.random_state).fit(
np.array([self.val_norm]).T)

# Get the Mahalanobis distance
dist = robust_cov.mahalanobis(np.array([self.val_data]).T)
Expand Down

0 comments on commit e84e8bb

Please sign in to comment.