fin separation front/back
This commit is contained in:
17
backend/dbscan_strategy.py
Normal file
17
backend/dbscan_strategy.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from sklearn.cluster import DBSCAN
|
||||
|
||||
def perform_dbscan_clustering(data, data_name, eps, min_samples):
|
||||
x = data[data_name].to_numpy()
|
||||
dbscan = DBSCAN(eps=eps, min_samples=min_samples)
|
||||
y_dbscan = dbscan.fit_predict(x)
|
||||
|
||||
fig = plt.figure()
|
||||
if len(data_name) == 2:
|
||||
ax = fig.add_subplot(projection='rectilinear')
|
||||
plt.scatter(x[:, 0], x[:, 1], c=y_dbscan, s=50, cmap="viridis")
|
||||
else:
|
||||
ax = fig.add_subplot(projection='3d')
|
||||
ax.scatter(x[:, 0], x[:, 1], x[:, 2], c=y_dbscan, s=50, cmap="viridis")
|
||||
return fig
|
Reference in New Issue
Block a user