階層的クラスタリングの樹形図作成で表示されるエラーの対処法

Pythonで気軽に化学・化学工学のsample_program_7.ipynbに含まれる階層的クラスタリングの樹形図の作成をおこなっています。

import pandas as pd
dataset=pd.read_csv('C:\Python\python_chem_chem_eng-main\iris_with_species.csv', index_col=0, header=0)
x=dataset.iloc[:,1:]
iris_types = dataset.iloc[:, 0]

selected_sample_numbers = [0, 1, 2, 3, 4, 59, 60, 64, 79, 81, 102, 105, 107, 109, 117]
x = x.iloc[selected_sample_numbers, :]
iris_types=iris_types.iloc[selected_sample_numbers]

autoscaled_x=(x-x.mean())/x.std()

from scipy.cluster.hierarchy import linkage, dendrogram, fcluster
clustering_results = linkage(autoscaled_x, metric='euclidean', method='ward')

import matplotlib.pyplot as plt
plt.rcParams['font.size'] = 18
dendrogram(clustering_results, labels=x.index, color_threshold=0, orientation='right')
plt.xlabel('distance')
plt.show()

しかし、これを実行させても、作図されず、以下のエラー表示が示されます。

どのように修正すればよいでしょうか。イメージ説明

コメントを投稿

0 コメント