scverse / scverse/mantispy

ECOD aggregates as pyod does, not as the paper's Algorithm 1

Closed
#72 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.