Skip to content

Commit

Permalink
Updating: adding dbscan
Browse files Browse the repository at this point in the history
  • Loading branch information
gallettilance committed Feb 9, 2022
1 parent 09dbc7f commit 4614d57
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
5 changes: 5 additions & 0 deletions 04-dbscan/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# DBScan

We will implement DBScan together in class

In addition to the requirements.txt, you need to install the `cs506` python package from [02-library](../02-library/).
18 changes: 18 additions & 0 deletions 04-dbscan/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import numpy as np
import matplotlib.pyplot as plt
import sklearn.datasets as datasets
from sklearn.preprocessing import StandardScaler

from cs506 import dbscan

centers = [[1, 1], [-1, -1], [1, -1]]
X, _ = datasets.make_blobs(n_samples=750, centers=centers, cluster_std=0.4,
random_state=0)
plt.scatter(X[:,0],X[:,1],s=10, alpha=0.8)
plt.show()

clustering = dbscan.DBC(X, 3, .2).dbscan()
colors = np.array([x for x in 'bgrcmykbgrcmykbgrcmykbgrcmyk'])
colors = np.hstack([colors] * 20)
plt.scatter(X[:, 0], X[:, 1], color=colors[clustering].tolist(), s=10, alpha=0.8)
plt.show()
11 changes: 11 additions & 0 deletions 04-dbscan/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cycler==0.10.0
joblib==0.14.0
kiwisolver==1.1.0
matplotlib==3.1.1
numpy==1.17.4
pyparsing==2.4.5
python-dateutil==2.8.1
scikit-learn==0.21.3
scipy==1.3.2
six==1.13.0
sklearn==0.0

0 comments on commit 4614d57

Please sign in to comment.