Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge remote-tracking branch 'gh-master/master'

* gh-master/master:
  ENH: let's become greedierin terms of dependecies to test deeper
  BF: assure tuple for the comparison of the fit params
  BF: we need swig for building, also added shogun-python-modular
  ENH: just added a call to apt-cache policy to see what is available
  ENH: Adding initial .travis.yml
  ENH: raise explicit exception if no measurements were received in MCNullDist
  BF: make computation of "default C" for SVM tollerate datasets with small int types
  just a usecase test (not enabled) for recent question from edmung chong
  • Loading branch information...
commit 417ec800a34ecf0970bd65190c04a015392c2307 2 parents a066932 + cdd1917
@hanke hanke authored
View
26 .travis.yml
@@ -0,0 +1,26 @@
+# vim ft=yaml
+# travis-ci.org definition for PyMVPA build (based on nipype configuration
+# which in turn was based on nipy)
+#
+# We pretend to be erlang because we need can't use the python support in
+# travis-ci; it uses virtualenvs, they do not have numpy, scipy, matplotlib,
+# and it is impractical to build them
+language: erlang
+env:
+ - PYTHON=python PYSUF=''
+ # - PYTHON=python3 PYSUF=3 : python3-numpy not currently available
+install:
+ #- sudo apt-get install $PYTHON-dev
+ - sudo apt-get install swig
+ - sudo apt-get install $PYTHON-numpy
+ - sudo apt-get install $PYTHON-scipy
+ - sudo apt-cache policy # What is actually available?
+ - sudo apt-get install $PYTHON-h5py
+ - sudo easy_install$PYSUF nibabel # Latest pypi
+ - sudo apt-get install $PYTHON-nose
+ - sudo apt-get install shogun-python-modular
+ - sudo apt-get install $PYTHON-mdp $PYTHON-psutil $PYTHON-sklearn liblapack-dev
+ - make
+script:
+ # Run only nonlabile tests
+ - make unittest-nonlabile
View
19 mvpa2/clfs/_svmbase.py
@@ -266,7 +266,24 @@ def _get_default_c(self, data):
"""
if self.params.kernel.__kernel_name__ == 'linear':
- datasetnorm = np.mean(np.sqrt(np.sum(data*data, axis=1)))
+ # TODO: move into a function wrapper for
+ # np.linalg.norm
+ if np.issubdtype(data.dtype, np.integer):
+ # we are dealing with integers and overflows are
+ # possible, so assure working with floats
+ def sq_func(x):
+ y = x.astype(float) # copy as float
+ y *= y # in-place square
+ return y
+ else:
+ sq_func = np.square
+ # perform it per each sample so we do not double memory
+ # with calling sq_func on full data
+ # Having a list of norms here automagically resolves issue
+ # with memmapped operations on which return
+ # in turn another memmap
+ datasetnorm = np.mean([np.sqrt(np.sum(sq_func(s)))
+ for s in data])
if datasetnorm == 0:
warning("Obtained degenerate data with zero norm for training "
"of %s. Scaling of C cannot be done." % self)
View
6 mvpa2/clfs/stats.py
@@ -405,7 +405,11 @@ def fit(self, measure, ds):
if __debug__:
debug('STATMC', ' Skipped: %d permutations' % skipped)
-
+ if not len(dist_samples) and skipped > 0:
+ raise RuntimeError(
+ 'Failed to obtain any value from %s. %d measurements were '
+ 'skipped. Check above warnings, and your code/data'
+ % (measure, skipped))
# store samples as (npermutations x nsamples x nfeatures)
dist_samples = np.asanyarray(dist_samples)
# for the ca storage use a dataset with
View
5 mvpa2/tests/test_stats_sp.py
@@ -296,7 +296,10 @@ def test_scipy_fit_2fparams(self):
t = scipy.stats.t
d = t(10, 1, 10).rvs(10)
params = t.fit(d, floc=1, fscale=10.)
- self.assertEqual(params[1:], (1, 10.))
+ # assured result to be a tuple due to failure on
+ # travis-ci (ubuntu precise)
+ # http://travis-ci.org/#!/PyMVPA/PyMVPA/builds/2459017
+ self.assertEqual(tuple(params[1:]), (1, 10.))
# df's are apparently quite difficult to assess unless plenty
# of samples
#self.assertTrue(abs(params[0] - 10) < 7) # estimate df at least in the right ball park
View
8 mvpa2/tests/test_svm.py
@@ -10,6 +10,8 @@
import numpy as np
+from mvpa2.datasets import dataset_wizard
+
from mvpa2.testing import *
from mvpa2.testing.clfs import *
from mvpa2.testing.datasets import *
@@ -174,6 +176,12 @@ def test_sillyness(self):
self.assertRaises(TypeError, sg.SVM, C=10, kernel_type='RBF',
coef0=3)
+ @sweepargs(clf=clfswh['svm', 'linear', '!meta', 'C_SVC'][:1])
+ def test_C_on_int_dataset(self, clf):
+ a = np.arange(8, dtype=np.int16).reshape(4,-1)
+ a[0,0] = 322 # the value which would overflow
+ self.assertTrue(np.isfinite(clf._get_default_c(a)))
+
def suite():
return unittest.makeSuite(SVMTests)
View
28 mvpa2/tests/test_usecases.py
@@ -98,3 +98,31 @@ def test_sifter_superord_usecase():
# I don't think that this would ever fail, so not marking it labile
assert(np.mean(accs_regular) > .8)
assert(np.mean(accs_super) < .6)
+
+def _test_edmund_chong_20120907():
+ from mvpa2.suite import *
+ from mvpa2.testing.datasets import datasets
+ repeater = Repeater(count=20)
+
+ partitioner = ChainNode([NFoldPartitioner(cvtype=1),
+ Balancer(attr='targets',
+ count=1, # for real data > 1
+ limit='partitions',
+ apply_selection=True
+ )],
+ space='partitions')
+
+ clf = LinearCSVMC() #choice of classifier
+ permutator = AttributePermutator('targets', limit={'partitions': 1},
+ count=1)
+ null_cv = CrossValidation(
+ clf,
+ ChainNode([partitioner, permutator], space=partitioner.get_space()),
+ errorfx=mean_mismatch_error)
+ distr_est = MCNullDist(repeater, tail='left', measure=null_cv,
+ enable_ca=['dist_samples'])
+ cvte = CrossValidation(clf, partitioner,
+ errorfx=mean_mismatch_error,
+ null_dist=distr_est,
+ enable_ca=['stats'])
+ errors = cvte(datasets['uni2small'])
Please sign in to comment.
Something went wrong with that request. Please try again.