0% found this document useful (0 votes)
2 views1 page

Dbscan Code Python

The document contains a Jupyter Notebook code for implementing DBSCAN clustering using Python. It includes data preparation with pandas, scaling features with StandardScaler, and visualizing the clustering results with matplotlib. The code demonstrates how to apply the DBSCAN algorithm to a simple dataset and plot the clusters.

Uploaded by

ashiq.26.2005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Dbscan Code Python

The document contains a Jupyter Notebook code for implementing DBSCAN clustering using Python. It includes data preparation with pandas, scaling features with StandardScaler, and visualizing the clustering results with matplotlib. The code demonstrates how to apply the DBSCAN algorithm to a simple dataset and plot the clusters.

Uploaded by

ashiq.26.2005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

4/4/25, 1:55 PM ML 9 DBSCAN .

ipynb - Colab

E0323006 - Shyam Parthiv

Add blockquote

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.cluster import DBSCAN
from sklearn.preprocessing import StandardScaler

data = {
'Feature1' : [10,12,15,18,20,22,25,30,35,40],
'Feature2' : [5,7,10,12,14,17,20,25,30,35]
}

df = pd.DataFrame(data)

scaler = StandardScaler()
df_scaled = scaler.fit_transform(df)

dbscan = DBSCAN(eps=0.5, min_samples=5)


df['Cluster'] = dbscan.fit_predict(df_scaled)

plt.scatter(df['Feature1'], df['Feature2'], c=df['Cluster'], cmap='viridis', edgecolors='k')


# Access the mean_ and scale_ attributes instead of mean and scale
plt.scatter(df['Feature1'],df['Feature2'],c=df['Cluster'],cmap='viridis',edgecolors='k')
plt.xlabel('Feature1')
plt.ylabel('Feature2')
plt.title('DBSCAN Clustering')
plt.show()

https://colab.research.google.com/drive/1kmTJzeaofW-LMADJjOS759IJzFQT4wNC?authuser=1#scrollTo=KF8MjqYE32rk&printMode=true 1/1

You might also like