yzhao062 / pyod

A Python Library for Outlier and Anomaly Detection, Integrating Classical and Deep Learning Techniques
http://pyod.readthedocs.io
BSD 2-Clause "Simplified" License
8.58k stars 1.37k forks source link

consistency in pyod algorithm's predictions #430

Open yairVanti opened 2 years ago

yairVanti commented 2 years ago

hi, i am using suod as a wrapper to pyod to be used for tabular anomaly detection. i am running the below algorithms. the problem is that for test reasons i need consistency in the results. i dont get it , each train & predict cycle i get different results. i noticed that just some of the algorithms expose random_state attribute that i can set. it that the reason of the inconsistency ? is there a way to get the same results each time for the same dataset ?

COPOD(contamination=self.contamination), IForest(n_estimators=100,contamination=self.contamination,random_state=self.random_state), ECOD(contamination=self.contamination), LOF(n_neighbors=5,contamination=self.contamination), MCD(contamination=self.contamination,random_state=self.random_state), HBOS(contamination=self.contamination), PCA(contamination=self.contamination), KNN(contamination=self.contamination,n_neighbors=5), KNN(n_neighbors=15,contamination=self.contamination)

thanks

metesynnada commented 2 years ago

Probably random seed/random state is the main cause.

RyanZurrin commented 2 years ago

I am having the same issue myself. I am going to try the random seed/random and try to fix my results. Please let me know if you tried this at all and had any luck.

yzhao062 commented 2 years ago

IForest(n_estimators=100,contamination=self.contamination,random_state=self.random_state) will give you different results...but will not be too different!