Skip to content

Contamination parameter in LOCI #194

Description

@shortydips24

Testing multiple values of the contamination parameter yielded the same percentage of outliers (~13%). Review of the source code describes the contamination parameter used in the threshold. However, when looking at the source code for the threshold, the contamination parameter is set to k and does not use the contamination parameter. The contamination parameter is defined in the function as a parameter but not called at any point during the source code.

threshold_ : float
The threshold is based on contamination. It is the
n_samples * contamination most abnormal samples in
decision_scores_. The threshold is calculated for generating
binary outlier labels.

self.threshold_ = k

self.labels_ = (self.decision_scores_ > self.threshold_).astype('int').ravel()

Therefore, the number of outliers is defined only by the value of k, and not the contamination parameter. The % of outliers generated does not match the expected % of outliers.

One other finding of note, when looking at the function calculate_decision_score, outlier scores are only generated for a hardcoded value of n_hat:
if n_hat >= 20:
outlier_scores[p_ix] = mdef / sigma_mdef
if mdef > (self.threshold
* sigma_mdef):

Current logic does not seem to output outlier_scores when n_hat <20. Authors should consider parameterizing this value with n_hat having a default of >= 20 or to throw an error message when n_hat is not >=20.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions