Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bugfix in PLF constructor

Conflicts:
  • Loading branch information...
commit cb012b72fc8938768b28671f4e0eeec8c2af1a73 1 parent 4f19027
@hanke hanke authored
View
6 Makefile
@@ -0,0 +1,6 @@
+distclean:
+ rm -rf doc/api/html
+ -cd doc/manual && rm *.log *.aux *.pdf *.backup *.out *.toc
+
+manual:
+ cd doc/manual && pdflatex manual.tex && pdflatex manual.tex
View
1  TODO
@@ -0,0 +1 @@
+* Add support for topology support for stuff other than dense mask matrices, e.g. meshes.
View
54 doc/manual/manual.tex
@@ -2,7 +2,7 @@
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
-\usepackage{makeidx}
+% \usepackage{makeidx}
\usepackage[T1]{fontenc}
\usepackage{ifpdf}
@@ -27,7 +27,7 @@
\maketitle
\begin{abstract}
Write a nice little summary about \pymvpa\ldots
-\end{abstract}
+\end{abstract}
\begin{center}
This manual has been last updated for \pymvpa version xxx.
@@ -36,20 +36,66 @@
\tableofcontents
\section{What MVPA is good for?}
+
+
+
\section{A short example}
+
+
+
\section{Classifiers}
\subsection{Support vector machines}
\subsection{k-nearest neighbours}
\subsection{Logistic regression}
+
+
+
\section{Feature selection strategies}
\subsection{Searchlight}
\subsection{Recursive feature elimination}
\subsection{Incremental feature search}
+
+
+
\section{Notes for developers}
+\subsection{Unit tests}
+Every part of \pymvpa should have a reasonable set of tests that ensure it is
+working as expected. All unit tests have to be put into the \code{tests}
+directory and shall be registered in the \code{tests/tests\_main.py} file.
+
\subsection{Requirements for classes providing classifiers}
+With the \code{CrossValidation} class \pymvpa provides a generic cross-validation
+algorithm than can make use of an arbitrary classifier. \pymvpa already provides
+a number of algorithms, but additional classifiers can easily be added. There
+are only a few requirements that such classifier class has to comply with:
+
+\begin{description}
+ \item[One required constructor argument] The constructor must not have more
+ than one required argument. This argument is a \code{MVPAPattern} object
+ containing the training data -- and only the training data. The constructor
+ may take an arbitrary number of additional \textit{keyword arguments}.
+ \item[Automatic training] When a classifier object is created, the classifier
+ must automatically train itself. There must not be the need to make
+ additional method calls, e.g. the constructor has to deal with possible
+ problems like convergence errors automatically or raise an exception if it
+ cannot handle it.
+ \item[Must have \code{predict()} methods] Each classifier class has to provide
+ a \code{predict()} method that can be used to retrieve the classifiers
+ prediction for some test data. That method has to accept a sequence with the
+ test data and may not require more than this argument. The method has to
+ return a sequence with the list of predicted regressors -- one prediction
+ for each element of the supplied testdata sequence.
+ \end{description}
+
+In addition classifiers may provide more functionality like the
+\code{rateFeatures()} method required by the recursive feature elimination
+algorithm. However, this is not strictly necessary.
+
\subsection{Passing arguments to the \code{CrossValidation} class}
+
+
% Put the index at the end
-\index{Test}
-\printindex
+% \index{Test}
+% \printindex
\end{document}
View
4 doc/manual/pymvpa_manual.kilepr
@@ -17,10 +17,10 @@ QuickBuild=
[item:manual.tex]
archive=true
-column=28
+column=51
encoding=UTF-8
highlight=LaTeX
-line=15
+line=87
open=true
[item:pymvpa_manual.kilepr]
View
1  tests/test_main.py
@@ -23,6 +23,7 @@
'test_algorithms',
'test_knn',
'test_svm',
+ 'test_plf',
'test_crossval',
'test_searchlight',
'test_incrinclusion',
View
90 tests/test_plf.py
@@ -0,0 +1,90 @@
+### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
+#
+# Unit tests for PyMVPA logistic regression classifier
+#
+# Copyright (C) 2007 by
+# Michael Hanke <michael.hanke@gmail.com>
+#
+# This package is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# version 2 of the License, or (at your option) any later version.
+#
+# This package is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
+
+import unittest
+import mvpa
+import mvpa.plf as plf
+import numpy as np
+
+
+def pureMultivariateSignal(patterns, signal2noise = 1.5):
+ """ Create a 2d dataset with a clear multivariate signal, but no
+ univariate information.
+
+ %%%%%%%%%
+ % O % X %
+ %%%%%%%%%
+ % X % O %
+ %%%%%%%%%
+ """
+
+ # start with noise
+ data=np.random.normal(size=(4*patterns,2))
+
+ # add signal
+ data[:2*patterns,1] += signal2noise
+ data[2*patterns:4*patterns,1] -= signal2noise
+ data[:patterns,0] -= signal2noise
+ data[2*patterns:3*patterns,0] -= signal2noise
+ data[patterns:2+patterns,0] += signal2noise
+ data[3*patterns:4*patterns,0] += signal2noise
+
+ # two conditions
+ regs = [0 for i in xrange(patterns)] \
+ + [1 for i in xrange(patterns)] \
+ + [1 for i in xrange(patterns)] \
+ + [0 for i in xrange(patterns)]
+ regs = np.array(regs)
+
+ return mvpa.MVPAPattern(data, regs)
+
+
+class PLFTests(unittest.TestCase):
+
+
+ def testMultivariate(self):
+
+ mv_perf = []
+ uv_perf = []
+
+ for i in xrange(20):
+ train = pureMultivariateSignal( 20, 3 )
+ test = pureMultivariateSignal( 20, 3 )
+
+ k_mv = plf.PLF(train)
+ p_mv = k_mv.predict( test.pattern )
+ mv_perf.append( np.mean(p_mv==test.reg) )
+
+ k_uv = plf.PLF(train.selectFeatures([0]))
+ p_uv = k_uv.predict( test.selectFeatures([0]).pattern )
+ uv_perf.append( np.mean(p_uv==test.reg) )
+
+ mean_mv_perf = np.mean(mv_perf)
+ mean_uv_perf = np.mean(uv_perf)
+
+ self.failUnless( mean_mv_perf > 0.9 )
+ self.failUnless( mean_uv_perf < mean_mv_perf )
+
+
+def suite():
+ return unittest.makeSuite(PLFTests)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
Please sign in to comment.
Something went wrong with that request. Please try again.