OPTICS algorithm with different epsilons on different axes

163 views Asked by At

I am trying to cluster the supplied charging power to different vehicles.

import numpy as np
import matplotlib.pyplot as plt
from sklearn.cluster import DBSCAN
from sklearn.cluster import KMeans, AgglomerativeClustering, DBSCAN, OPTICS, cluster_optics_dbscan

df_temp_12 = list(map(lambda x, y: [x, y], VehicleList, Power))
Eps = 1.3
dbscan_12_object = OPTICS(eps=Eps, cluster_method="dbscan")
dbscan_12 = dbscan_12_object.fit_predict(df_temp_12)

My present output looks like this:

enter image description here

I am trying to cluster mainly along the horizontal axis ( as is shown by the cluster in Green). If you notice closely, all other clusters have not been clustered in the same way (i.e. along the horizontal) and hence I am trying to figure out if i can change the EPS value along each axis separately, and if so, how?

EDIT: After the suggestion by @PlzBePython the output looks like this. Precisely what I needed enter image description here

1

There are 1 answers

0
PlzBePython On BEST ANSWER

If you already know that you want to cluster along a specific axis, why not cluster that feature in isolation?

So for example:

data = np.array(Power).reshape((-1, 1))
clusterer = sklearn.cluster.OPTICS(eps=1.3, cluster_method="dbscan")
clustered_data = clusterer.fit(data).labels_

Otherwise, I would try creating OPTICS without parameter (default is to identify clusters across all scales)

clusterer = sklearn.cluster.OPTICS()

or using Gaussian Mixture.