Mooventh Chiyan
Mooventh Chiyan

Reputation: 29

ANOVA Feature Selection in python

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

I'm trying to perform feature selection based on ANOVA (Categorical vs Numerical variable).

dependent variable: Revenue independent variable: Administrative,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)

But getting an following error,

Value Error(Shape issue)

Upvotes: 1

Views: 785

Answers (1)

DavideBrex
DavideBrex

Reputation: 2424

The problem is related to the column Revenue in data, because it is boolean. In fact, if you convert from boolean to integer then it works:

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

Upvotes: 3

Related Questions