Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Extracting the cluster labels from a dendrogram

# Perform the necessary imports
import pandas as pd
from scipy.cluster.hierarchy import fcluster

# Use fcluster to extract labels: labels
labels = fcluster(mergings, ''specify an height'', criterion='distance')

# Create a DataFrame with labels and varieties as columns: df
df = pd.DataFrame({'labels': labels, 'varieties': varieties})

# Create crosstab: ct
ct = pd.crosstab(df['labels'], df['varieties'])

# Display ct
print(ct)
Comment

PREVIOUS NEXT
Code Example
Python :: decorrelation of data using PCA 
Python :: kite order syntax 
Python :: csv/gpd to shapefile python 
Python :: specifying random columns in numpy 
Python :: sample k-means clustering 
Python :: how to truncate a float in jinja template 
Python :: HIDING AND ENCRYPTING PASSWORDS IN PYTHON USING ADVPASS 
Python :: type hinting with default value python 
Python :: function for getting the basic statistic of our Dataframe in one go 
Python :: how to check if the update_one success in flask 
Python :: R-squared and MNSE error computation 
Python :: wn.synset vs wn.synsets in nltk 
Python :: egt id of current object django 
Python :: use decorator more than once 
Python :: insert key in binary tree recursively 
Python :: basic decorator example 
Python :: python detect ranges in list 
Python :: fichier python pour brython 
Python :: python sum whole matrix comand 
Python :: viola conda 
Python :: la commande pop python 
Python :: part of list into dataframe 
Python :: python argparse choice 
Python :: qt line edit set text python 
Python :: pandas typr of each cell in series 
Python :: two labels on one axis python 
Python :: somma array python 
Python :: openpyxl _cells_by_row 
Python :: numpy collapse last dimension 
Python :: python sort list of tuples lexicographically 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =