【发布时间】:2019-01-22 13:58:40
【问题描述】:
我有 X 的数据框,其中包含 40 城市的 40 特征。比我的目标变量y 的形式为pandas.core.series.Series
X.shape
(170, 40)
type(y)
pandas.core.series.Series
y.shape
(170,)
我想尝试从sklearn 应用SelectKBest 算法
from sklearn.feature_selection import SelectKBest
from sklearn.feature_selection import chi2
X_new = SelectKBest(chi2, k=2).fit_transform(X, y)
但我收到以下错误
ValueError: 未知标签类型: (array([
【问题讨论】:
-
X数据框中的 dtypes 怎么样?确保他们不是objects。 -
@amanb 我有
int64和float64 -
好吧,我认为这个问题已经在其他帖子中得到了多次回答,并在stackoverflow中进行了广泛的探索。
-
在将
y传递给SelectKBest之前,您确定y是一个系列吗?因为我刚刚尝试将SelectKBest与y作为一个系列并且它有效。或者问题可能出在其他地方,不是y是一个系列,而是dtype中的值
标签: python arrays pandas dataframe