Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
293 views
in Technique[技术] by (71.8m points)

DBSCAN Clustering - Python exporting of Iris with a new column

I found this to get the relevant clustered data to a new column. But the below is an example.

 from sklearn.cluster import DBSCAN
    import numpy as np
    import pandas as pd
    
    X = np.array([[1, 2], [2, 2], [2, 3],
                  [8, 7], [8, 8], [25, 80]])
    df = pd.DataFrame(X)
    clustering = DBSCAN(eps=3, min_samples=2).fit(df)
    df["clusters"] = clustering.labels_

I have a file on this location "C:Users5807DesktopNew folder (5)FinalX.csv"

And there are text fields as well as number fields. so the columns stated in the above report are,

"Sepal_length","Sepal_width","Petal_length","Petal_width" , "Species_name","Species_No","ID","K-Means","Hierarchical"

So i need to get a new column after "Hierarchical" column which is the clusters of DBSCAN. that means Cluster 1, cluster 2 o cluster 3.

This is basically total iris data set with added two more columns. There are 150 rows and i want to export all to a new file with that additional DBSCAN column

Thanks

question from:https://stackoverflow.com/questions/65888167/dbscan-clustering-python-exporting-of-iris-with-a-new-column

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...