<div dir="ltr"><span style="font-size:12.8px">Dear Experts,</span><br><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Can anyone respond to my request (in this thread) about doing Monte Carlo testing when the dataset is unbalanced and partitioning like</span></div><div><span style="font-size:12.8px"><br></span></div>par = ChainNode([NFoldPartitioner(<wbr>cvtype=2, attr='chunks'),<br> Sifter([('partitions', 2),<br> ('targets', dict(uvalues=['cond1', 'cond2'],<br> balanced=True))])<br><div> ], space='partitions')</div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">is used?</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">I will really appreciate your help.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Thank you,</span></div><div><span style="font-size:12.8px">Anna.</span></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 11, 2017 at 12:16 PM, Anna Manelis <span dir="ltr"><<a href="mailto:anna.manelis@gmail.com" target="_blank">anna.manelis@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div><br></div>Dear Experts,<br><br></div>I have an unbalanced dataset (group1=16 subjects ('better'), group2=12 subjects ('worse'). I would like to perform Monte-Carlo testing of the SMLR between-subject classification analysis (performed on cope images). I used the permutation_test.py script as an example and tried to adjust it for my unbalanced dataset. <br><br></div>Any feedback on whether the script below makes sense is greatly appreciated.<br><div><br><br>lm = 0.2 # The value was determined through the nested cross-validation procedure<br><br>clf = SMLR(lm=lm, fit_all_weights=False, descr='SMLR(lm=%g)' % lm)<br><br>### how often do we want to shuffle the data<br>repeater = Repeater(count=200)<br><br>### permute the training part of a dataset exactly ONCE<br>permutator = AttributePermutator('targets', limit={'partitions': 1}, count=1)<br><br>### Make sure that each group ("better" and "worse") has the same number of samples<br>par = ChainNode([NFoldPartitioner(<wbr>cvtype=2, attr='chunks'),<br> Sifter([('partitions', 2),<br> ('targets', dict(uvalues=['better', 'worse'],<br> balanced=True))])<br> ], space='partitions')<br><br></div><div>### I believe this will apply permutator on each fold created by par.<br></div><div>par_perm = ChainNode([par, permutator], space=par.get_space())<br><br># CV with null-distribution estimation that permutes the training data for<br># each fold independently<br>null_cv = CrossValidation(<br> clf,<br> par_perm,<br> errorfx=mean_mismatch_error)<br><br># Monte Carlo distribution estimator<br>distr_est = MCNullDist(repeater, tail='left', measure=null_cv,<br> enable_ca=['dist_samples'])<br><br># actual CV with H0 distribution estimation<br>cv = CrossValidation(clf, par, errorfx=mean_mismatch_error,<br> null_dist=distr_est, enable_ca=['stats'])<br><br><br>err = cv(ds_mni_bw)<br><br>p = err.ca.null_prob<br>np.asscalar(p)<br><br><br></div><div>Thank you very much,<br></div><div>Anna.<br></div><div><br><br><br></div></div>
</blockquote></div><br></div></div>