Skip to content

INNE skips BaseDetector.__init__, so an out-of-range contamination is accepted silently #752

Description

@owgreen-dev

INNE.__init__ (pyod/models/inne.py:84-90) assigns self.contamination = contamination directly and never calls super().__init__, so the range check in BaseDetector.__init__ (base.py:62-66) is bypassed.

Evidence (v3.6.6):

>>> KNN(contamination=0.9)
ValueError: contamination must be in (0, 0.5], got: 0.900000
>>> INNE(contamination=0.9)
INNE(contamination=0.9, ...)      # accepted

Every other tabular detector rejects this at construction. INNE(contamination=0.9).fit(X) then labels 90% of the training set as outliers.

Proposed fix: super().__init__(contamination=contamination) and drop the direct assignment. One line plus a test. Happy to PR.

Found with a script that checks every detector for the sklearn parameter contract (get_params/clone/refit); drafted with Claude Code assistance and verified by hand.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions