ceholden / yatsm

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

Postprocess commission test - TypeError: 'numpy.float64' object does not support item assignment #77

Closed valpasq closed 8 years ago

valpasq commented 8 years ago

Tried running YATSM with the postprocess commission test enabled using this specification:

# Parameters common to all timeseries analysis models within YATSM package
YATSM:
    algorithm: "CCDCesque"
    prediction: "GLMNET_Lasso20"
    design_matrix: "1 + x + harm(x, 1) + harm(x, 2)"
    reverse: False
    commission_alpha: 0.05
    # Re-fit each segment, adding new coefficients & RMSE info to record
    refit:
        prefix: [robust]
        prediction: [RLM]

and got the following error:

14:30:29:DEBUG:66:config_parser.convert_config:Predicting using "GLMNET_Lasso20" pickle specified from configuration file (/usr3/graduate/valpasq/Documents/yatsm/yatsm/regression/pickles/glmnet_Lasso20.pkl)
14:30:29:DEBUG:93:cache.test_cache:Attempt reading in from cache directory?: True
14:30:29:DEBUG:95:cache.test_cache:Attempt writing to cache directory?: True
14:30:29:INFO:75:line.line:Job 0 of 500 - using config file /projectnb/landsat/projects/Massachusetts/p013r031/p013r031_config.yaml
14:30:29:DEBUG:90:line.line:Responsible for lines: [   0  500 1000 1500 2000 2500 3000 3500 4000 4500 5000 5500 6000 6500]
14:30:29:DEBUG:128:line.line:Running line 0
14:30:29:DEBUG:158:reader.read_line:Read in Y from cache file
19:52:00:DEBUG:188:line.line:    Saving YATSM output to /projectnb/landsat/projects/Massachusetts/p013r031/images/YATSM/yatsm_r0.npz
19:52:00:DEBUG:195:line.line:Line 0 took 19290.838645s to run
19:52:00:DEBUG:128:line.line:Running line 500
19:52:00:DEBUG:158:reader.read_line:Read in Y from cache file
Traceback (most recent call last):
  File "/usr3/graduate/valpasq/conda/envs/yatsm/bin/yatsm", line 9, in <module>
    load_entry_point('yatsm==0.6.0.dev0', 'console_scripts', 'yatsm')()
  File "/usr3/graduate/valpasq/conda/envs/yatsm/lib/python2.7/site-packages/click/core.py", line 664, in __call__
    return self.main(*args, **kwargs)
  File "/usr3/graduate/valpasq/conda/envs/yatsm/lib/python2.7/site-packages/click/core.py", line 644, in main
    rv = self.invoke(ctx)
  File "/usr3/graduate/valpasq/conda/envs/yatsm/lib/python2.7/site-packages/click/core.py", line 991, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr3/graduate/valpasq/conda/envs/yatsm/lib/python2.7/site-packages/click/core.py", line 837, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr3/graduate/valpasq/conda/envs/yatsm/lib/python2.7/site-packages/click/core.py", line 464, in invoke
    return callback(*args, **kwargs)
  File "/usr3/graduate/valpasq/Documents/yatsm_conda/yatsm/cli/line.py", line 173, in line
    yatsm, cfg['YATSM']['commission_alpha'])
  File "/usr3/graduate/valpasq/Documents/yatsm_conda/yatsm/algorithms/postprocess.py", line 88, in commission_test
    yatsm.Y[b, m_1_start:m_1_end])[1]
TypeError: 'numpy.float64' object does not support item assignment

I was using the conda environment, so hoping this isn't yet another environment issue...

ceholden commented 8 years ago

I don't seem to be able to reproduce the error you're seeing. Two things jump out at me as really odd from your log:

1) The first line of the image took 5+ hours 2) You're running YATSM from a conda installation but using pickles from your other installation

Have you tried running the meager number of tests provided against your installation? Can you catch the exception and inspect the data with a debugger? Do well pixels that are known to have actual data run correctly?

ceholden commented 8 years ago

Turns out that I was able to reproduce the error for column 1124 in row 500 of your dataset. I guess the timing you're seeing is pretty accurate -- haven't benchmarked the commission test before so I guess it's pretty slow. My original hunch was there was something wacky going on with differences in your yatsm/yatsm_conda environments causing glmnet to never converge or produce real statistical estimates.

The error occurred on a pixel that had two changes and the bug would only occur on the second second iteration of the loop over the result record. Fixed and added a test to exercise this scenario in commit referenced above