python 中的方差分析特征选择

ANOVA Feature Selection in python

data=pd.read_csv("https://raw.githubusercontent.com/sharmaroshan/Online-Shoppers-Purchasing- Intention/master/online_shoppers_intention.csv")

我正在尝试根据方差分析(分类变量与数值变量)执行特征选择。

因变量:收入 自变量:行政,Administrative_Duration

import statsmodels.api as sm
from   statsmodels.formula.api import ols
from   statsmodels.stats.anova import anova_lm
model = ols('Revenue ~ Informational',data = data).fit()
anova_table=anova_lm(model)

但是出现以下错误,

Value Error(Shape issue)

问题与数据中的列 Revenue 有关,因为它是布尔值。 事实上,如果您将布尔值转换为整数,那么它就可以工作:

data.Revenue = data.Revenue.astype(int)