Last active
April 9, 2019 16:37
-
-
Save Jviejo/6d61356015dd50af35bdc35a79d04150 to your computer and use it in GitHub Desktop.
dendograma.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load the Pandas libraries with alias 'pd' | |
import pandas as pd | |
from matplotlib import pyplot as plt | |
from scipy.cluster.hierarchy import dendrogram, linkage | |
from sklearn import datasets | |
import numpy as np | |
# Read data from file 'filename.csv' | |
# (in the same directory that your python process is based) | |
# Control delimiters, rows, column names with read_csv (see later) | |
data = pd.read_csv("C:\\Users\\jviejo\\womantech\\python\\small.csv", sep='\t') | |
print(data.head()) | |
X=data | |
#single, media, complete, ward | |
Z = linkage(X, 'complete' , metric='euclidean') | |
plt.figure(figsize=(10, 8)) | |
plt.title('Dendograma single') | |
plt.xlabel('Indice') | |
plt.ylabel('Distancia') | |
max_d = 10 | |
dendrogram( | |
Z, | |
leaf_rotation=90., | |
leaf_font_size=8., | |
show_contracted=True | |
) | |
plt.axhline(y= max_d, c ='k') | |
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PRICE,MAINT,DOORS,PERSONS,SAFETY,CLASS | |
40000,2000,2,2,1,0 | |
30000,500,3,5,3,1 | |
10000,2000,5,4,3,1 | |
20000,1000,2,4,2,1 | |
40000,2000,5,2,3,0 | |
30000,1000,4,2,3,0 | |
30000,2000,3,4,3,0 | |
20000,1500,2,2,2,0 | |
10000,500,3,5,2,1 | |
40000,1000,2,4,3,1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment