ECOD aggregates as pyod does, not as the paper's Algorithm 1
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8
- Forks
- 0
- Avg merge
- 12h 18m
- Merged PRs (30d)
- 26
Description
Problem
pp.outliers(method="ecod") sums over features the per-feature maximum of the three tail scores, as pyod does. Algorithm 1 of Li et al. (2023) takes the maximum of the three per-row sums instead. The two orders flag different cells. The _core/_ecod.py docstring said the opposite ("the reverse order gives plausible scores that are not ECOD"); that wording is being corrected under #35.
Reproduction
import numpy as np
from scipy.stats import skew
from mantispy._core._ecod import column_ecdf, ecod_scores
X = np.random.default_rng(0).standard_t(3, size=(500, 20))
U_l, U_r = -np.log(column_ecdf(X)), -np.log(column_ecdf(-X))
U_skew = np.where(skew(X, axis=0) < 0, U_l, U_r)
sum_of_max = np.maximum(np.maximum(U_l, U_r), U_skew).sum(axis=1) # pyod
max_of_sum = np.maximum(np.maximum(U_l.sum(axis=1), U_r.sum(axis=1)), U_skew.sum(axis=1)) # paper
np.allclose(ecod_scores(X), sum_of_max) # True
top = lambda s: set(np.argsort(s)[-25:])
len(top(sum_of_max) & top(max_of_sum)) # 7 of 25
Expected
A deliberate choice between pyod's aggregation and the paper's, recorded in the pp.outliers docstring so that users know which ECOD they get.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read mantispy/_core/_ecod.py and the pp.outliers docstring, then run the reproduction using column_ecdf and ecod_scores. Determine which aggregation is intended, record that deliberate choice in the pp.outliers documentation, and make sure the documented behavior matches the selected ECOD scores.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100