bambinos / bambi

BAyesian Model-Building Interface (Bambi) in Python.
https://bambinos.github.io/bambi/
MIT License
1.08k stars 123 forks source link

AttributeError: 'Term' object has no attribute 'eval' #692

Closed kurvaraviteja355 closed 1 year ago

kurvaraviteja355 commented 1 year ago

I am not able to the understand why this error occurs and how to resolve please can someone help me `AttributeError Traceback (most recent call last) Cell In[38], line 9 import bambi as bmb 2 complete_model_priors = { 3 "Intercept": bmb.Prior("Normal", mu=0, sigma=10), 4 "Status": bmb.Prior("Normal", mu=0, sigma=5), 5 "MISX": bmb.Prior("Normal", mu=0, sigma=5), 6 "sigma": bmb.Prior("Exponential", lam=1 / 2), 7 } 8 # model sales as a function of PA, and MISX ----> 9 complete_model = bmb.Model( 10 formula="Rslr Sales Amount ~ Status + MISX", 11 data=data, 12 family="gaussian", 13 link="identity", 14 priors=complete_model_priors, 15 ) 17 complete_model

File c:\Users\raviteja.kurva\Anaconda3\envs\pm3env\lib\site-packages\bambi\models.py:160, in Model.init(self, formula, data, family, priors, link, categorical, potentials, dropna, auto_scale, noncentered, extra_namespace) 158 design = remove_common_intercept(design) 159 else: --> 160 design = fm.design_matrices( 161 self.formula.main, self.data, na_action, 1, additional_namespace 162 ) 164 if design.response is None: 165 raise ValueError( 166 "No outcome variable is set! " 167 "Please specify an outcome variable using the formula interface." 168 )

File ~\AppData\Roaming\Python\Python38\site-packages\formulae\matrices.py:523, in design_matrices(formula, data, na_action, env, extra_namespace) 520 else: 521 raise ValueError(f"'data' contains {incomplete_rows_n} incomplete rows.") --> 523 design = DesignMatrices(description, data, env) 524 return design

File ~\AppData\Roaming\Python\Python38\site-packages\formulae\matrices.py:54, in DesignMatrices.init(self, model, data, env) 51 self.model = model 53 # Evaluate terms in the model ---> 54 self.model.eval(data, env) 56 if self.model.response: 57 self.response = ResponseMatrix(self.model.response)

AttributeError: 'Term' object has no attribute 'eval'`

tomicapretto commented 1 year ago

Hi!

I think it happens because the response name has spaces in it. You could change it so it doesn't have spaces, or you could also use backticks

"`Rslr Sales Amount` ~ Status + MISX"

If that doesn't work, could you share a reproducible example?

kurvaraviteja355 commented 1 year ago

Hi!

I think it happens because the response name has spaces in it. You could change it so it doesn't have spaces, or you could also use backticks

Thank you, now its working