Created
December 27, 2023 01:49
-
-
Save smzn/1cfcad7a4122eb02af08ee3cabe46c38 to your computer and use it in GitHub Desktop.
各主成分の要素をヒストグラムで表示
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
# Total_Daily_Sales、Explained Variance、Cumulative Explained Varianceの列を除外 | |
data = pca_components_combined_df.drop(columns=['Total_Daily_Sales', 'Explained Variance', 'Cumulative Explained Variance']) | |
# 各行の要素をヒストグラムで表示 | |
for index, row in data.iterrows(): | |
plt.figure(figsize=(8, 4)) # プロットのサイズを設定 | |
plt.xticks(rotation=90) # x軸ラベルを縦に表示 | |
plt.bar(row.index, row.values) # 棒グラフを作成 | |
plt.xlabel('Columns') # x軸ラベル | |
plt.ylabel('Values') # y軸ラベル | |
plt.title(f'Histogram for PC {index}') # グラフのタイトル | |
plt.show() # グラフを表示 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment