I am trying to fine anomalies in the data set I have. This is CPU usage data for a process.
My data looks something like below
My code to find anomalies looks like something below
outlier_detector = OutlierDetector(LocalOutlierFactor(contamination=0.05))
anomalies = outlier_detector.fit_detect(df_anomaly)
print(anomalies)
The anomalies output shows me something like below
How can I filter the anomalies output for all values which have True in the set? Is anomalies output a dataframe or something else?
The question was answered by Contributors on GitHub.
The anomalies object is a pandas.core.series.Series
You can convert it to a list and use the data in your own plot.
# With datetime and boolean
anomailes_list = anomalies.reset_index().values.tolist()
anomailes_list
# Just boolean results
anomailes_list = anomalies.to_list()
anomailes_list
# List of values that are True
anomalies_true = [value for value in anomalies.to_list() if value]