我正在尝试用Python绘制2DMCA图。我正在尝试复制在王子Github存储库https://github.com/MaxHalford/prince中找到的教程
我目前正在做以下工作:
import pandas as pd
X = pd.read_csv('https://archive.ics.uci.edu/ml/machine-learning-databases/balloons/adult+stretch.data')
X.columns = ['Color', 'Size', 'Action', 'Age', 'Inflated']
mca = prince.MCA(X,n_components=2)
但是,当我运行plot命令时,即使软件包中有一个plot_coordinates函数,我也会收到以下错误。
mca.plot_coordinates(X = X)
AttributeError: 'MCA' object has no attribute 'plot_coordinates'
任何帮助纠正这个问题的人都将不胜感激。谢谢。
发布于 2021-07-27 20:39:10
要使用plot_coordinates函数,首先需要初始化MCA对象,并用数据对其进行拟合。
X = pd.read_csv('https://archive.ics.uci.edu/ml/machine-learning-databases/balloons/adult+stretch.data')
X.columns = ['Color', 'Size', 'Action', 'Age', 'Inflated']
fig, ax = plt.subplots()
mc = prince.MCA(n_components=2).fit(X)
mc.plot_coordinates(X=X, ax=ax)
ax.set_xlabel('Component 1', fontsize=16)
ax.set_ylabel('Component 2', fontsize=16)
https://stackoverflow.com/questions/67391441
复制相似问题