uber / orbit

A Python package for Bayesian forecasting with object-oriented design and probabilistic models under the hood.
https://orbit-ml.readthedocs.io/en/stable/
Other
1.87k stars 134 forks source link

Type error when implementing fitting models from orbit.models.dlt #641

Open nportman opened 2 years ago

nportman commented 2 years ago

I attempted to reproduce the results of ETSFull model on load_iclaims() data using code example provided in orbit documentation, however, I ran into TypeError issue. I did the install of orbit-ml package on Windows 10, and below is the code that I used:

%matplotlib inline import orbit from orbit.utils.dataset import load_iclaims from orbit.models.dlt import ETSFull from orbit.diagnostics.plot import plot_predicted_data df = load_iclaims() date_col = 'week' response_col = 'claims' df = load_iclaims() date_col = 'week' response_col = 'claims' dlt = ETSFull( response_col=response_col, date_col=date_col, seasonality=52, seed=8888, ) dlt.fit(train_df)

Here is the output of the above code:

TypeError Traceback (most recent call last)

in ----> 1 dlt.fit(train_df) ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\orbit\models\template.py in fit(self, df) ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\orbit\estimators\stan_estimator.py in fit(self, model_name, model_param_names, data_input, fitter, init_values) 105 # passing callable from the model as seen in `initfun1()` 106 # https://pystan2.readthedocs.io/en/latest/api.html --> 107 # if None, use default as defined in class variable 108 init_values = init_values or self.stan_init 109 # with suppress_stdout_stderr(): ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\orbit\utils\stan.py in get_compiled_stan_model(stan_model_name) 42 """ 43 ---> 44 compile_stan_model(stan_model_name) 45 46 model_file = pkg_resources.resource_filename( ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\orbit\utils\stan.py in compile_stan_model(stan_model_name) 10 Compile stan model and save as pkl 11 """ ---> 12 source_model = pkg_resources.resource_filename( 13 'orbit', 14 'stan/{}.stan'.format(stan_model_name) ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pkg_resources\__init__.py in resource_filename(self, package_or_requirement, resource_name) 1133 def resource_filename(self, package_or_requirement, resource_name): 1134 """Return a true filesystem path for specified resource""" -> 1135 return get_provider(package_or_requirement).get_resource_filename( 1136 self, resource_name 1137 ) ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pkg_resources\__init__.py in get_provider(moduleOrReq) 352 module = sys.modules[moduleOrReq] 353 loader = getattr(module, '__loader__', None) --> 354 return _find_adapter(_provider_factories, loader)(module) 355 356 ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pkg_resources\__init__.py in __init__(self, module) 1382 def __init__(self, module): 1383 self.loader = getattr(module, '__loader__', None) -> 1384 self.module_path = os.path.dirname(getattr(module, '__file__', '')) 1385 1386 def get_resource_filename(self, manager, resource_name): C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\ntpath.py in dirname(p) 221 def dirname(p): 222 """Returns the directory component of a pathname""" --> 223 return split(p)[0] 224 225 # Is a path a symbolic link? C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\ntpath.py in split(p) 183 Return tuple (head, tail) where tail is everything after the final slash. 184 Either part may be empty.""" --> 185 p = os.fspath(p) 186 seps = _get_bothseps(p) 187 d, p = splitdrive(p) TypeError: expected str, bytes or os.PathLike object, not NoneType
wangzhishi commented 2 years ago

hi @nportman, how did get orbit installed on your machine? pip or conda? did you use a virtual env?

vperilla commented 2 years ago

Same issue here.

I'm using pyenv (Python 3.7) on Linux. I installed orbit via pip. Seems to works fine if I install Orbit from code.