ceholden / yatsm

Yet Another Time Series Model
https://yatsm.readthedocs.org/en/latest/
MIT License
63 stars 30 forks source link

glmnet/fortran error when running yatsm line #82

Closed parevalo closed 8 years ago

parevalo commented 8 years ago

I'm trying to run yatsm line and getting the following error:

15:15:19:INFO:51:line.line:Job 1 of 400 - using config file /projectnb/landsat/projects/Colombia/images/005057/Results/FIT1/557_FIT1.yaml
0-th dimension must be fixed to 4 but got 6

Traceback (most recent call last):
  File "/usr3/graduate/parevalo/miniconda2/envs/conda_env/bin/yatsm", line 9, in <module>
    load_entry_point('yatsm==0.6.0.dev0', 'console_scripts', 'yatsm')()
  File "/usr3/graduate/parevalo/miniconda2/envs/conda_env/lib/python2.7/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr3/graduate/parevalo/miniconda2/envs/conda_env/lib/python2.7/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr3/graduate/parevalo/miniconda2/envs/conda_env/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr3/graduate/parevalo/miniconda2/envs/conda_env/lib/python2.7/site-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr3/graduate/parevalo/miniconda2/envs/conda_env/lib/python2.7/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/usr3/graduate/parevalo/miniconda2/envs/conda_env/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr3/graduate/parevalo/miniconda2/envs/conda_env/lib/python2.7/site-packages/yatsm/cli/line.py", line 156, in line
    yatsm.fit(_X, _Y, _dates, **algo_cfg.get('fit', {}))
  File "/usr3/graduate/parevalo/miniconda2/envs/conda_env/lib/python2.7/site-packages/yatsm/algorithms/ccdc.py", line 222, in fit
    self.train()
  File "/usr3/graduate/parevalo/miniconda2/envs/conda_env/lib/python2.7/site-packages/yatsm/algorithms/ccdc.py", line 326, in train
    bands=self.test_indices)
  File "/usr3/graduate/parevalo/miniconda2/envs/conda_env/lib/python2.7/site-packages/yatsm/algorithms/yatsm.py", line 195, in fit_models
    model.fit(X, y, **self.estimator_fit)
  File "/usr3/graduate/parevalo/miniconda2/envs/conda_env/lib/python2.7/site-packages/glmnet/elastic_net.py", line 86, in fit
    enet_path(X, y, alpha=self.alpha, **kwargs)
  File "/usr3/graduate/parevalo/miniconda2/envs/conda_env/lib/python2.7/site-packages/glmnet/elastic_net.py", line 349, in enet_path
    = elastic_net(X, y, alpha, **kwargs)
  File "/usr3/graduate/parevalo/miniconda2/envs/conda_env/lib/python2.7/site-packages/glmnet/glmnet.py", line 91, in elastic_net
    nlam=nlam, isd=standardize)
_glmnet.error: failed in converting 6th argument `vp' of _glmnet.elnet to C/Fortran array

I'm not even sure how to try to debug it myself or trace the cause of the problem. Also, I checked your glmnet-python repository and you suggested using the fork by the user "shuras" and tried to install that to see if it fixed the problem but the installation was unsuccessful.

ceholden commented 8 years ago

Yeah that recommendation is for other users. My fork, specifically, is a dependency of YATSM and is the only one that works similar enough to sklearn to be useful.

I don't have read permissions to view your Python installation files but I'd be happy to take a look tomorrow in person. My guesses are either:

  1. Maybe glmnet dependency is out of date
  2. Pickle could be out of date. The version of the code in the pickle you're trying to import needs to be the same version as the code you're trying to run.
  3. A bug in parsing your weights

I'll have to check, but I think you can use one of the pickles built when you install YATSM alongside fit options. Looks like I check for the actual pickle file being "built-in" to YATSM before I go looking for it where the user specifies in config_parser.py. If not, change it to allow:

YATSM:
    prediction: BUILT_IN_ESTIMATOR

...
BUILT_IN_ESTIMATOR:
    # no need to specify since it's included in package
    # pickle: some_file.pkl
    fit:
        penalties: [1, 1, 1, 1, 1, 1]
parevalo commented 8 years ago

Ahh, the problem must be the pickle version then. I wasn't aware that they needed to be the same version, I was just lazy and used the same ones that were available for release 0.5.5. The reason why I used those was because there seemed to be no "pre-built" pickles in your latest version.

On Mon, Mar 7, 2016 at 9:11 PM, Chris Holden notifications@github.com wrote:

Yeah that recommendation is for other users. My fork, specifically, is a dependency of YATSM and is the only one that works similar enough to sklearn to be useful.

I don't have read permissions to view your Python installation files but I'd be happy to take a look tomorrow in person. My guesses are either:

  1. Maybe glmnet dependency is out of date
  2. Pickle could be out of date. The version of the code in the pickle you're trying to import needs to be the same version as the code you're trying to run.
  3. A bug in parsing your weights

I'll have to check, but I think you can use one of the pickles built when you install YATSM alongside fit options. Looks like I check for the actual pickle file being "built-in" to YATSM before I go looking for it where the user specifies in config_parser.py. If not, change it to allow:

YATSM: prediction: BUILT_IN_ESTIMATOR

...BUILT_IN_ESTIMATOR:

no need to specify since it's included in package

# pickle: some_file.pkl
fit:
    penalties: [1, 1, 1, 1, 1, 1]

— Reply to this email directly or view it on GitHub https://github.com/ceholden/yatsm/issues/82#issuecomment-193556833.

ceholden commented 8 years ago

OK let's make sure it's the problem tomorrow then and I'll try to write up something instructive.

What you're basically a victim of a transition out of a bad design decision. There's a good Python talk on YouTube on science model serialization I'll try to dig up that is relevant to this discussion, but I haven't found it just yet.

ceholden commented 8 years ago

Issue resolved. Configuration file in question used 4 coefficients but specified 6 penalties for Lasso.

Follow up: document model fit option specification in configuration docs (#37)