我想使用the prince package的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']
mca = prince.MCA(n_iter=3, copy=True, check_input=True, engine='auto', random_state=42)
mca = mca.fit(X)
mca.plot_coordinates(x=X,
ax=None,
figsize=(6, 6),
show_row_points=True,
row_points_size=10,
show_row_labels=False,
show_column_points=True,
column_points_size=30,
show_column_labels=False,
legend_n_cols=1)
只需复制粘贴并尝试运行它,就会抛出:
/home/user/anaconda3/envs/python38/lib/python3.8/site-packages/prince/one_hot.py:31: FutureWarning: The SparseDataFrame class is removed from pandas. Accessing it from the top-level namespace will also be removed in the next version
return pd.SparseDataFrame(
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-18-6fd265f4e0f4> in <module>
3
4 mca = prince.MCA(n_iter=3, copy=True, check_input=True, engine='auto', random_state=42)
----> 5 mca = mca.fit(X)
6
7
~/anaconda3/envs/python38/lib/python3.8/site-packages/prince/mca.py in fit(self, X, y)
26
27 # Apply CA to the indicator matrix
---> 28 super().fit(self.one_hot_.transform(X))
29
30 # Compute the total inertia
~/anaconda3/envs/python38/lib/python3.8/site-packages/prince/one_hot.py in transform(self, X)
29
30 def transform(self, X):
---> 31 return pd.SparseDataFrame(
32 data=super().transform(X),
33 columns=self.column_names_,
TypeError: SparseDataFrame() takes no arguments
你知道我需要在什么地方做些什么才能让它工作吗?我迫切需要做的阴谋,我还没有找到另一个包,可以做到这一点
我刚刚第一次尝试使用
prince
包,但在重新安装anacondapython 3.7
和最新的prince/numpy/pandas/scikit_learn
堆栈时,运行自述文件中的示例时遇到了相同的错误。在prince
中使用不推荐的pandas类SparseDataFrame
似乎是一个问题。有一个悬而未决的问题。解决办法是降级到pandas-0.24.2
:这使它起作用
相关问题 更多 >
编程相关推荐