<html><head></head><body>Let's continue at <a href="https://github.com/PyMVPA/PyMVPA/issues/581">https://github.com/PyMVPA/PyMVPA/issues/581</a><br>
<br>
I will have a look later today<br>
<br>
Thanks!<br><br><div class="gmail_quote">On April 29, 2018 3:52:15 AM EDT, Richard Dinga <dinga92@gmail.com> wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div dir="ltr"><div>Thanks, this seems to be the solution according to documentation, but it doesn't work for my data. Here is an example using tutorial data:<br><br>from mvpa2.suite import *<br>datapath = '/usr/share/data/pymvpa2-tutorial/'<br>haxby = load_tutorial_data(datapath,<br>        roi='vt',<br>        add_fa={'vt_thr_glm': os.path.join(datapath, 'haxby2001',<br>                                           'sub001', 'masks',<br>                                                     'orig', 'vt.nii.gz')})<br>poly_detrend(haxby, polyord=1, chunks_attr='chunks')<br>haxby = haxby[np.array([l in ['rest', 'house', 'face']<br>                           for l in haxby.targets], dtype='bool')]<br>zscore(haxby, chunks_attr='chunks', param_est=('targets', ['rest']), <br>       dtype='float32')<br>haxby = haxby[haxby.sa.targets != 'rest']<br>haxby = remove_invariant_features(haxby)<br><br>clf = GNB(enable_ca='estimates', logprob=True, normalize=True)<br>cv = CrossValidation(clf, NFoldPartitioner(attr='chunks'), postproc=None)<br>cv_results = cv(haxby)<br>print clf.ca.estimates<br><br>[[          inf           inf]<br> [-234.34792494    0.        ]<br> [          inf           inf]<br> ..., <br> [          inf           inf]<br> [          inf           inf]<br> [          inf           inf]]<br><br></div>However it works with test data:<br><br>from mvpa2.testing.datasets import *<br>ds_test = datasets['uni2medium']<br>cv_results = cv(ds_test)<br>print np.round(np.exp(clf.ca.estimates), 3)<br><br>[[ 0.956  0.044]<br> [ 1.     0.   ]<br> [ 1.     0.   ]<br> ..., <br> [ 0.     1.   ]<br> [ 0.168  0.832]<br> [ 0.001  0.999]]<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 26, 2018 at 6:11 PM, Yaroslav Halchenko <span dir="ltr"><<a href="mailto:debian@onerussian.com" target="_blank">debian@onerussian.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><br>
On Thu, 26 Apr 2018, Richard Dinga wrote:<br>
<br>
> Hi,<br>
> I am trying to get a probability prediction for each sample from<br>
> cross-validation. I used .ca.stats.sets to get those, however, for GNB<br>
> these all look like this:<br>
<br>
> print cvte.ca.stats.sets[0][2]<br>
> [[-1009.22758728 -1079.77409491]<br>
>  [ -795.59690176 -1038.32481958]<br>
>  [ -875.73917377 -1189.377741  ]<br>
>  ...,<br>
>  [-1483.49338276  -856.61441132]<br>
>  [-1308.29372328  -815.90664933]<br>
>  [-1169.79999768  -737.54291075]]<br>
<br>
> I thought these are log probabilities, but after exponentiation, they are<br>
> all 0, although based on accuracy and AUC the classifier works fine.<br>
<br>
> Any idea how to fix this or is this as good as it can get? My ultimate goal<br>
> is to get GNB probabilities from GNB searchlight. Trying the same thing<br>
> using SMLR seems to produce valid probabilities (in a sane range and rows<br>
> sums to 1).<br>
<br>
> Best regards,<br>
> Richard<br>
<br>
<br>
</div></div>Try using setting normalize=True for your GNB.  Here is from GNB? in ipython,<br>
check other parameters which might be relevant:<br>
<br>
normalize : bool, optional<br>
  Normalize (log)prob by P(data). Requires probabilities thus for<br>
  `logprob` case would require exponentiation of 'logprob's, thus<br>
  disabled by default since does not impact classification output.<br>
  Constraints: value must be convertible to type bool. [Default:<br>
  False]<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
-- <br>
Yaroslav O. Halchenko<br>
Center for Open Neuroscience     <a href="http://centerforopenneuroscience.org" rel="noreferrer" target="_blank">http://<wbr>centerforopenneuroscience.org</a><br>
Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755<br>
Phone: +1 (603) 646-9834                       Fax: +1 (603) 646-1419<br>
WWW:   <a href="http://www.linkedin.com/in/yarik" rel="noreferrer" target="_blank">http://www.linkedin.com/in/<wbr>yarik</a>        <br>
<br>
______________________________<wbr>_________________<br>
Pkg-ExpPsy-PyMVPA mailing list<br>
<a href="mailto:Pkg-ExpPsy-PyMVPA@alioth-lists.debian.net">Pkg-ExpPsy-PyMVPA@alioth-<wbr>lists.debian.net</a><br>
<a href="https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/pkg-exppsy-pymvpa" rel="noreferrer" target="_blank">https://alioth-lists.debian.<wbr>net/cgi-bin/mailman/listinfo/<wbr>pkg-exppsy-pymvpa</a></font></span></blockquote></div><br></div>
</blockquote></div><br>
-- <br>
Sent from a phone which beats iPhone.</body></html>