How do I plot (in python) the distance graph for a given value of min-points in DBSCAN???

I am looking for the knee and corresponding epsilon value.

In the sklearn I do not see any method that return such distances.... Am I missing something?
Sep 5, 2018 in Python 4,808 views

## 1 answer to this question.

You probably want to use the matrix operations provided by numpy to speed up your distance matrix calculation.

```def k_distances2(x, k):
dim0 = x.shape[0]
dim1 = x.shape[1]
p=-2*x.dot(x.T)+np.sum(x**2, axis=1).T+ np.repeat(np.sum(x**2, axis=1),dim0,axis=0).reshape(dim0,dim0)
p = np.sqrt(p)
p.sort(axis=1)
p=p[:,:k]
pm= p.flatten()
pm= np.sort(pm)
return p, pm
m, m2= k_distances2(X, 2)
plt.plot(m2)
plt.ylabel("k-distances")
plt.grid(True)
plt.show()```
• 58,090 points

## Plot a pie-chart in Python in Matplotlib

Not sure which dataset you are using. ...READ MORE

## how to plot a boxplot in python using seaborn?

following is the syntax for a boxplot ...READ MORE

## How can I rename a file in Python?

yes, you can use "os.rename" for that. ...READ MORE

## how do i change string to a list?

suppose you have a string with a ...READ MORE

## how can i randomly select items from a list?

You can also use the random library's ...READ MORE

+1 vote

## how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE