Google Groupes

Re: [hddm-users] hddm tutorial


stein...@gmail.com 14 mai 2015 00:46
Envoyé au groupe : hddm-users
yes, correct. 64 bit Mountain Lion with 64 bit Anaconda.

Am Freitag, 13. Juni 2014 09:11:56 UTC+2 schrieb Thomas:
But you are running OSX 64-bit with anaconda 64-bit, right?


On Wed, Jun 11, 2014 at 1:54 PM, <stein...@gmail.com> wrote:
Hi Thomas, 
thanks for the quick reply. There is a little misunderstanding though: I'm trying to get hddm working on OSX mountain lion (10.8.5) for which there is no 32 bit version.
It's these error messages, that I was referring to:

""""""""
1.pip install -U pymc

Command /Applications/anaconda/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/vf/zy_t4gd13831lkzwvkq1qk6m0000gn/T/pip_build_qiangshen/pymc/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/vf/zy_t4gd13831lkzwvkq1qk6m0000gn/T/pip-HYXzxx-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /private/var/folders/vf/zy_t4gd13831lkzwvkq1qk6m0000gn/T/pip_build_qiangshen/pymc
Storing debug log for failure in /Users/qiangshen/.pip/pip.log

2. pip install -U kabuki

Command python setup.py egg_info failed with error code 1 in /private/var/folders/vf/zy_t4gd13831lkzwvkq1qk6m0000gn/T/pip_build_qiangshen/kabuki
Storing debug log for failure in /Users/qiangshen/.pip/pip.log

3. pip install -U hddm 

Command python setup.py egg_info failed with error code 1 in /private/var/folders/vf/zy_t4gd13831lkzwvkq1qk6m0000gn/T/pip_build_qiangshen/hddm
Storing debug log for failure in /Users/qiangshen/.pip/pip.log

""""""

So I suppose I need to install a Fortran compiler now? 

Cheers,
Benjamin

Am Mittwoch, 11. Juni 2014 12:51:25 UTC+2 schrieb Thomas:
Hi Benjamin,

A user posted windows build instructions in another thread:
"
I wanted to install HDDM on a windows machine but was riddled with either DLL or MS visual studio errors, especially with PyMC. I tried clean python install and also Anaconda with no luck. Here is a procedure that worked for me so thought maybe I will post it here in case people are still looking for a solution. As the procedure depends on MinGW32 please make sure that you install everything 32 bit even though your Windows is 64 bit.

You need admin rights to do many of the following.

1. Install Python 2.7.6 32 bit. Lets call the install directory path_to_Python27.
2. Get Numpy and Scipy 2.7 32 bit installers from their websites and install.
3. Install setuptools and pip (32 bit) from http://www.lfd.uci.edu/~gohlke/pythonlibs/
4. Install MinGW32 and append the corresponding bin folder to your environments PATH variable. You can get MinGW32 here http://sourceforge.net/projects/mingw/files/
5. Create file: path_to_Python27\Lib\
distutils\distutils.cfg and put following two lines in there:

[build]
compiler=mingw32

6. Start "cmd" and run following commands in the path_to_Python27\scripts directory (make sure that you dont have any python instances running)

pip install matplotlib
pip install pymc
pip install pandas
pip install kabuki
pip install hddm
"

See if that helps. Otherwise I should update the conda windows packages soon.

Thomas



On Wed, Jun 11, 2014 at 12:31 PM, <stein...@gmail.com> wrote:
Hi Quiang,

did you find a solution? I'm stuck precisely where you have been. Any hints on where to get the right compiler or how to work around the Fortran compiler problem?

Thanks a lot,
Benjamin

Am Sonntag, 8. Juni 2014 03:39:21 UTC+2 schrieb Qiang Shen:
Hi Thomas,

      I figured it out, it needs a Fortran compiler which is not available in the original OSX. Thank you all the same.

best wishes,

Qiang

On Saturday, June 7, 2014 11:19:37 PM UTC+8, Thomas wrote:
Can you paste the full error log?


On Sat, Jun 7, 2014 at 5:13 PM, Qiang Shen <johns...@gmail.com> wrote:
Do you know how to fix this? Thanks.


On Saturday, June 7, 2014 11:07:12 PM UTC+8, Qiang Shen wrote:
Hi Thomas, 

     Recently I moved to a new place and need to install the HDDM again on Mac. But I failed to install it correctly. I have tried Anaconda 1.9.2 and Anaconda 2.0.0. Below are the error information. 


1.pip install -U pymc

Command /Applications/anaconda/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/vf/zy_t4gd13831lkzwvkq1qk6m0000gn/T/pip_build_qiangshen/pymc/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/vf/zy_t4gd13831lkzwvkq1qk6m0000gn/T/pip-HYXzxx-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /private/var/folders/vf/zy_t4gd13831lkzwvkq1qk6m0000gn/T/pip_build_qiangshen/pymc
Storing debug log for failure in /Users/qiangshen/.pip/pip.log

2. pip install -U kabuki

Command python setup.py egg_info failed with error code 1 in /private/var/folders/vf/zy_t4gd13831lkzwvkq1qk6m0000gn/T/pip_build_qiangshen/kabuki
Storing debug log for failure in /Users/qiangshen/.pip/pip.log



3. pip install -U hddm 

Command python setup.py egg_info failed with error code 1 in /private/var/folders/vf/zy_t4gd13831lkzwvkq1qk6m0000gn/T/pip_build_qiangshen/hddm
Storing debug log for failure in /Users/qiangshen/.pip/pip.log

  

On Sunday, June 1, 2014 8:05:37 PM UTC+8, Thomas wrote:
Hi Qiang,

Thanks, I fixed the issues in the tutorial you mentioned.

HDDMRegression should accept a p_outlier keyword argument (e.g. HDDMRegression(data, 'v~x', p_outlier=.05). Does it not?

Thomas


On Wed, May 21, 2014 at 9:37 AM, Qiang Shen <johns...@gmail.com> wrote:
Hi Thomas,

    In the tutorial, "a_var" should be "a_std",that’s the reasons why it was not listed in the table which should be 4 rows * 8 columns. and also for the posterior plot. In addition, all the plots seem not correctly presented in current version of the tutorial. 

     For the outlier removal, it is possible to apply it in the with-subject situation? I tested, it seems not work for hddm.HDDMRegressor function. Then how we can make it work in such situation, we have to remove the outliers in advance?

best wishes,

Qiang 



On Saturday, May 17, 2014 4:03:36 PM UTC+8, Qiang Shen wrote:
Thanks! Thomas.

On Friday, May 16, 2014 7:36:37 AM UTC+8, Thomas wrote:
Sorry about that, should be fixed now. Let me know if there are any other problems.

Thomas


On Wed, May 14, 2014 at 12:45 AM, Qiang Shen <johns...@gmail.com> wrote:
Dear Thomas,

I proceed to test the scripts and came across the 2nd error I mentioned to you last time again,  see below for details. For the rest of content in the link you sent me, it all works!

hddm.analyze.plot_posterior_nodes([v_WL, v_LL, v_WW])


hddm.analyze.plot_posterior_nodes([v_WL, v_LL, v_WW])
<matplotlib.figure.Figure at 0x10e598590>
Traceback (most recent call last):

  File "<ipython-input-58-1eee4f977a76>", line 1, in <module>
    hddm.analyze.plot_posterior_nodes([v_WL, v_LL, v_WW])

  File "/Applications/anaconda/lib/python2.7/site-packages/kabuki/analyze.py", line 34, in plot_posterior_nodes
    lb = min([min(node.trace()[:]) for node in nodes])

AttributeError: 'float' object has no attribute 'trace'





On Wednesday, May 14, 2014 9:45:56 AM UTC+8, Qiang Shen wrote:
Dear Thomas,

    It's so excited that now it works for the following code and I have successfully plotted the attached graph, I'll check whether the following scripts also work on my side. Thanks a lot!
for i, subj_data in data.groupby('subj_idx'):
    subj_data.rt.hist(bins=20, histtype='step', ax=ax)

best,

Qiang 

On Tuesday, May 13, 2014 1:07:33 AM UTC+8, Thomas wrote:
Or were you using hddm_demo.ipynb from the examples directory?

Let me know if that fixes your problems.

Thomas


On Mon, May 12, 2014 at 12:05 AM, Qiang Shen <johns...@gmail.com> wrote:
Hi Thomas,

 Thanks for your reply, initially I haven't import kabuki because it's not mentioned in the tutorial, but after import of kabuki,it's still not work for
for i, subj_data in data.groupby('subj_idx'):
    ax.hist(subj_data.rt, bins=20, histtype='step')

Here is the information.

print pymc.__version__
print kabuki.__version__
print hddm.__version__

2.3.2
0.5.4
0.5.3

Traceback (most recent call last):

  File "<ipython-input-14-c2c318cf1f63>", line 4, in <module>
    ax.hist(subj_data.rt, bins=20, histtype='step')

  File "/Applications/anaconda/lib/python2.7/site-packages/matplotlib/axes.py", line 8249, in hist
    if isinstance(x, np.ndarray) or not iterable(x[0]):

  File "/Applications/anaconda/lib/python2.7/site-packages/pandas/core/series.py", line 491, in __getitem__
    result = self.index.get_value(self, key)

  File "/Applications/anaconda/lib/python2.7/site-packages/pandas/core/index.py", line 1032, in get_value
    return self._engine.get_value(s, k)

  File "index.pyx", line 97, in pandas.index.IndexEngine.get_value (pandas/index.c:2661)

  File "index.pyx", line 105, in pandas.index.IndexEngine.get_value (pandas/index.c:2476)

  File "index.pyx", line 149, in pandas.index.IndexEngine.get_loc (pandas/index.c:3215)

  File "hashtable.pyx", line 382, in pandas.hashtable.Int64HashTable.get_item (pandas/hashtable.c:6942)

  File "hashtable.pyx", line 388, in pandas.hashtable.Int64HashTable.get_item (pandas/hashtable.c:6883)

KeyError: 0


In [15]:


On Sunday, May 11, 2014 8:58:15 PM UTC+8, Thomas wrote:
Hi Qiang,

Windows should make not difference.

Still not sure you have the right versions, can you do:

print pymc.__version__
print kabuki.__version__
print hddm.__version__

After imporiting each module?


On Sat, May 10, 2014 at 5:31 AM, Qiang Shen <johns...@gmail.com> wrote:
Dear Thomas,

 Do you have any suggestions for the error I mentioned? or it might be better to use Windows for this analysis? Thanks.

best wishes,

Qiang


On Thursday, May 8, 2014 11:14:57 AM UTC+8, Qiang Shen wrote:
Dear Thomas,

     Thanks for your reply. The ipython notebook of Anaconda can't be started on my computer and it seem not have a good solution for this.  So I tried both ipython-qtconsole and  spyder of Anaconda to run the analysis,in general it works smoothly but both can't run the commands I mentioned correctly. Below are the information for my current version of the software, ipython is already the most updated version.


Python 2.7.6 |Anaconda 1.9.2 (x86_64)| (default, Jan 10 2014, 11:23:15) 
Type "copyright", "credits" or "license" for more information.

IPython 2.0.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.
%guiref   -> A brief reference about the graphical user interface.




 best wishes,

Qiang 

On Wednesday, May 7, 2014 10:26:21 PM UTC+8, Thomas wrote:
Hi Qiang,

Seems like the notebook needs to be updated. Are you using the ipython notebook directly or the website?

Thomas


On Wed, May 7, 2014 at 4:51 AM, Qiang Shen <johns...@gmail.com> wrote:
Hi Thomas,

     Thanks, I proceed to try the HDDM, below are the problem I came across so far, do you know why? Does that mean the software is still not correctly installed on my OSX?
 


1. for i, subj_data in data.groupby('subj_idx'):
    ax.hist(subj_data.rt, bins=20, histtype='step')
    
Traceback (most recent call last):

  File "<ipython-input-3-3ff08f9d5cbe>", line 2, in <module>
    ax.hist(subj_data.rt, bins=20, histtype='step')

  File "/Applications/anaconda/lib/python2.7/site-packages/matplotlib/axes.py", line 8249, in hist
    if isinstance(x, np.ndarray) or not iterable(x[0]):

  File "/Applications/anaconda/lib/python2.7/site-packages/pandas/core/series.py", line 491, in __getitem__
    result = self.index.get_value(self, key)

  File "/Applications/anaconda/lib/python2.7/site-packages/pandas/core/index.py", line 1032, in get_value
    return self._engine.get_value(s, k)

  File "index.pyx", line 97, in pandas.index.IndexEngine.get_value (pandas/index.c:2661)

  File "index.pyx", line 105, in pandas.index.IndexEngine.get_value (pandas/index.c:2476)

  File "index.pyx", line 149, in pandas.index.IndexEngine.get_loc (pandas/index.c:3215)

  File "hashtable.pyx", line 382, in pandas.hashtable.Int64HashTable.get_item (pandas/hashtable.c:6942)

  File "hashtable.pyx", line 388, in pandas.hashtable.Int64HashTable.get_item (pandas/hashtable.c:6883)

KeyError: 0




2.hddm.analyze.plot_posterior_nodes([v_WL, v_LL, v_WW])
<matplotlib.figure.Figure at 0x10ef799d0>
Traceback (most recent call last):

  File "<ipython-input-13-1eee4f977a76>", line 1, in <module>
    hddm.analyze.plot_posterior_nodes([v_WL, v_LL, v_WW])

  File "/Applications/anaconda/lib/python2.7/site-packages/kabuki/analyze.py", line 34, in plot_posterior_nodes
    lb = min([min(node.trace()[:]) for node in nodes])

AttributeError: 'float' object has no attribute 'trace'


3.
m_no_outlier = hddm.HDDMInfo(outlier_data)

m_no_outlier = hddm.HDDMInfo(outlier_data)
Traceback (most recent call last):

  File "<ipython-input-25-59a817d0b4fc>", line 1, in <module>
    m_no_outlier = hddm.HDDMInfo(outlier_data)

AttributeError: 'module' object has no attribute 'HDDMInfo'

On Tuesday, May 6, 2014 8:32:02 PM UTC+8, Thomas wrote:
Hi Qiang,

Glad that it's working and thanks for letting us know.

I think there is a problem with the conda package for OSX which we'll have to fix.

Thomas


On Tue, May 6, 2014 at 8:25 AM, Qiang Shen <johns...@gmail.com> wrote:
Hi Thomas,

     I have figured out the error after "model = hddm.HDDM(data, depends_on={'v':'difficulty'})". I just updated the software using the command you mentioned in the mailing list, then it's solved! 
         pip install -U pymc
         pip install -U kabuki
         pip install -U hddm.


      Below are the steps I tried for the HDDM instalment on Mac.
       1. install anaconda
       2. Following instruction, I typed in the terminal the following command.
          conda install -c pymc pymc   
          conda install -c twiecki hddm    
      After this, the Numpy version is 1.7.1, so I tried "conda install -c pymc pymc" again to link the Numpy to version 1.8.
       3. Then I typed
           pip install -U pymc
           pip install -U kabuki
           pip install -U hddm














On Tuesday, May 6, 2014 10:28:37 AM UTC+8, Qiang Shen wrote:
Hi Thomas,

   Here it is.
data = hddm.load_csv('simple_difficulty.csv')

model = hddm.HDDM(data, depends_on={'v':'difficulty'})
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-20-442fbac9eed4> in <module>()
----> 1 model = hddm.HDDM(data, depends_on={'v':'difficulty'})

/Applications/anaconda/lib/python2.7/site-packages/hddm/models/hddm_info.pyc in __init__(self, *args, **kwargs)
    111         self.is_informative = kwargs.pop('informative', True)
    112 
--> 113         super(HDDM, self).__init__(*args, **kwargs)
    114 
    115     def _create_stochastic_knodes(self, include):

/Applications/anaconda/lib/python2.7/site-packages/hddm/models/base.pyc in __init__(self, data, bias, include, wiener_params, p_outlier, **kwargs)
    687         self.wfpt_class = hddm.likelihoods.generate_wfpt_stochastic_class(wp, cdf_range=self.cdf_range)
    688 
--> 689         super(HDDMBase, self).__init__(data, **kwargs)
    690 
    691     def __getstate__(self):

/Applications/anaconda/lib/python2.7/site-packages/hddm/models/base.pyc in __init__(self, data, **kwargs)
     38         self.std_depends = kwargs.pop('std_depends', False)
     39 
---> 40         super(AccumulatorModel, self).__init__(data, **kwargs)
     41 
     42 

/Applications/anaconda/lib/python2.7/site-packages/kabuki/hierarchical.pyc in __init__(self, data, is_group_model, depends_on, trace_subjs, plot_subjs, plot_var, group_only_nodes)
    345         self.db = None
    346 
--> 347         self._setup_model()
    348 
    349     def _setup_model(self):

/Applications/anaconda/lib/python2.7/site-packages/kabuki/hierarchical.pyc in _setup_model(self)
    356 
    357         # constructs pymc nodes etc and connects them appropriately
--> 358         self.create_model()
    359 
    360     def __getstate__(self):

/Applications/anaconda/lib/python2.7/site-packages/kabuki/hierarchical.pyc in create_model(self, max_retries)
    426         for tries in range(max_retries):
    427             try:
--> 428                 _create()
    429             except (pm.ZeroProbability, ValueError):
    430                 continue

/Applications/anaconda/lib/python2.7/site-packages/kabuki/hierarchical.pyc in _create()
    422         def _create():
    423             for knode in self.knodes:
--> 424                 knode.create()
    425 
    426         for tries in range(max_retries):

/Applications/anaconda/lib/python2.7/site-packages/kabuki/hierarchical.pyc in create(self)
    165                 kwargs['doc'] = node_name
    166 
--> 167             node = self.create_node(node_name, kwargs, grouped_data)
    168 
    169             if node is not None:

/Applications/anaconda/lib/python2.7/site-packages/kabuki/hierarchical.pyc in create_node(self, node_name, kwargs, data)
    173     def create_node(self, node_name, kwargs, data):
    174         #actually create the node
--> 175         return self.pymc_node(name=node_name, **kwargs)
    176 
    177     def create_tag_and_subj_idx(self, cols, uniq_elem):

/Applications/anaconda/lib/python2.7/site-packages/pymc/distributions.pyc in __init__(self, *args, **kwds)
    269                 random = debug_wrapper(random)
    270             else:
--> 271                 Stochastic.__init__(self, logp=logp, random=random, logp_partial_gradients = logp_partial_gradients, dtype=dtype, **arg_dict_out)
    272 
    273     new_class.__name__ = name

/Applications/anaconda/lib/python2.7/site-packages/pymc/PyMCObjects.pyc in __init__(self, logp, doc, name, parents, random, trace, value, dtype, rseed, observed, cache_depth, plot, verbose, isdata, check_logp, logp_partial_gradients)
    746                           dtype=dtype,
    747                           plot=plot,
--> 748                           verbose=verbose)
    749 
    750         # self._logp.force_compute()

/Applications/anaconda/lib/python2.7/site-packages/pymc/Node.pyc in __init__(self, doc, name, parents, cache_depth, trace, dtype, plot, verbose)
    214         self.extended_children = set()
    215 
--> 216         Node.__init__(self, doc, name, parents, cache_depth, verbose=verbose)
    217 
    218         if self.dtype is None:

/Applications/anaconda/lib/python2.7/site-packages/pymc/Node.pyc in __init__(self, doc, name, parents, cache_depth, verbose)
    125 
    126         # Initialize
--> 127         self.parents = parents
    128 
    129     def _get_parents(self):

/Applications/anaconda/lib/python2.7/site-packages/pymc/Node.pyc in _set_parents(self, new_parents)
    148 
    149         # Get new lazy function
--> 150         self.gen_lazy_function()
    151 
    152     parents = property(

/Applications/anaconda/lib/pyt
...