Using this example on the scikit-learn site, I am attempting to do some anomaly detection using LOF. What I end up with is this:
clf = LocalOutlierFactor(n_neighbors=20, contamination='auto') y_pred = clf.fit_predict(df) data_scores = clf.negative_outlier_factor_
My dataframe contains 47 columns. My immediate issue is that I'm not sure how to use
data_scores to detect anomalies. (The example on the site above uses an 2-column dataframe, I believe, so it's a bit more straightforward.) For example, if I manually multiply a value in my data by 10, I can see a corresponding increase in the
data_scores maximum absolute value. But what does that get me? It might help me to identify which row of the data contains an anomaly, but can it help me identify which field in that row? I'm probably missing something big-picture here, so feel free to point me in the right direction.
I'm hoping for a little guidance on topic(s) I might look into. The LOF examples online all seem to stop with the code I included above, assuming the user will know what to do with the numpy array the
negative_outlier_factor_ method returns.