0

When I try to run this model

y, X =dmatrices('price - area + bedrooms + bathrooms', df, return_type='dataframe')

vif=pd.DataFrame()
vif["VIF Factor"]=[variance_inflation_factor(X.values, i) for i in range(X.shape[1])]
vif["features"]=X.columns
vif

it gets this error:

PatsyError                                Traceback (most recent call last)
<ipython-input-27-4e351f766736> in <module>()
----> 1 y, X =dmatrices('price - area + bedrooms + bathrooms', df, return_type='dataframe')
      2 
      3 vif=pd.DataFrame()
      4 vif["VIF Factor"]=[variance_inflation_factor(X.values, i) for i in range(X.shape[1])]
      5 vif["features"]=X.columns

/opt/conda/lib/python3.6/site-packages/patsy/highlevel.py in dmatrices(formula_like, data, eval_env, NA_action, return_type)
    310                                       NA_action, return_type)
    311     if lhs.shape[1] == 0:
--> 312         raise PatsyError("model is missing required outcome variables")
    313     return (lhs, rhs)

PatsyError: model is missing required outcome variables

Why is this happening and what can I do to fix it?

Emi OB
  • 2,814
  • 3
  • 13
  • 29

1 Answers1

0

the wrong thing is I put "-" sign after price instead of "~"

the right code should be

y, X =dmatrices('price ~ area + bedrooms + bathrooms', df, return_type='dataframe')

vif=pd.DataFrame()
vif["VIF Factor"]=[variance_inflation_factor(X.values, i) for i in range(X.shape[1])]
vif["features"]=X.columns
vif