lifelines
lifelines copied to clipboard
unable to load a saved `WeibullAFTFitter` model
Hello, I have saved a WeibullAFTFitter model as a pkl file.
Versions being used:
Python: 3.9.16
lifelines: 0.27.7
Here is the entire stacktrace. I am able to load CoxPHFitter with a problem, the code only breaks with WeibullAFTFitter
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[21], line 2
1 for w in weibull_files:
----> 2 load_saved_model(w)
File ~/git/gqc/loe_coe_app_deven_fork/pipe_breaks/tl/loader.py:12, in load_saved_model(pkl_file)
6 def load_saved_model(pkl_file: str | Path):
7 """Load trained model
8
9 Args:
10 pkl_file (str | Path): path to the saved model
11 """
---> 12 model = pickle.load(open(pkl_file, 'rb'))
13 return model
File ~/mambaforge/envs/lifelines/lib/python3.9/site-packages/formulaic/formula.py:277, in Formula.__getattr__(self, attr)
275 def __getattr__(self, attr: str) -> Any:
276 # Keep substructures wrapped to retain access to helper functions.
--> 277 subformula = super().__getattr__(attr)
278 if attr != "root":
279 return Formula.from_spec(subformula)
File ~/mambaforge/envs/lifelines/lib/python3.9/site-packages/formulaic/parser/types/structured.py:405, in Structured.__getattr__(self, attr)
403 def __getattr__(self, attr: str) -> Any:
404 if attr.startswith("_"):
--> 405 raise AttributeError(attr)
406 if attr in self._structure:
407 return self._structure[attr]
AttributeError: __dict__
I'm not able to repro this. Can you share you dump code, and what verion of formualic you are using?