No account yet ?
Point Order to Identify Clustering Structure is an algorithm for finding density-based clusters in spatial data.
OPTICS is similar to DBSCAN, but it addresses one of the main weaknesses of DBSCAN, namely the problem of detecting significant clusters in data of varying density.
To do this, the points in the database are ordered such that the spatially closest points become neighbors in order.
A special distance is stored for each point that represents the density that must be accepted for a cluster in order for both points to belong to it.
This is represented by a dendrogram.
Anomaly detection with OPTICS
Tested in Anaconda and Python 3.7
from sklearn.cluster import OPTICS from sklearn.datasets import make_blobs from numpy import quantile, where, random import matplotlib.pyplot as plt random.seed(123) x, _ = make_blobs(n_samples=350, centers=1, cluster_std=.4, center_box=(20, 5)) plt.scatter(x[:,0], x[:,1]) plt.grid(True) plt.show() model = OPTICS().fit(x) print(model) scores = model.core_distances_ thresh = quantile(scores, .98) print(thresh) index = where(scores >= thresh) values = x[index] print(values) plt.scatter(x[:,0], x[:,1]) plt.scatter(values[:,0],values[:,1], color='r') plt.legend(("normal", "anomal"), loc="best", fancybox=True, shadow=True) plt.grid(True) plt.show()
Source : https://www.datatechnotes.com/2020/12/anomaly-detection-with-optics-in-python.html
Welcome, my name is Eric Soupet and I am the administrator of the site elodees.com. elodees.com is a state of the art of Artificial Intelligence and aims to be collaborative, you can now offer content such as articles, events, tutorials, ... so don't hesitate !
Platform images credit : Pixabay - Pixabay License | Pexels - Pexels License