[pymvpa] how to serialize/pickle/save a trained SVM?

Yaroslav Halchenko debian at onerussian.com
Mon May 11 13:52:32 UTC 2009


Sorry, but we have not bothered about saving trained classifiers yet :-/
Indeed pickling would not work atm due to swig bindings, and although
for linear SVM you can extract coefficients of the sep plane normal +
bias in the sensitivity, you would not be able to recreate SVM from it
(although creating a tiny linear classifier based on those weights would
be quite simple).

I am not sure what would be the best way to proceed at this point,
alternatives are:

1. expose saving facilities from underlying externals (libsvm, sg) but
then we would need also to implement loading and it would not work
nicely anyways since none of the additional params (enabled states, etc)
would be stored.

Also this would only work for basic classifiers, and not smth more
evolved (FeatureSelectionClassifier, etc), so may be 

2. try making all classifiers serializable/initializable by exposing
the results of training (to be generic, probably SVs coefficients
instead of plain plane coefficients, so it would work also for
non-linear SVMs)

more ideas?

On Mon, 11 May 2009, Emanuele Olivetti wrote:

> Dear All,
>
> I'm playing with SVMs (libSVM backend) and after a very long training
> I'd like to exploit the outcome for a while. Is there a way to save to
> file (i.e., pickle/serialization) the trained SVM?
>
> Currently pickle does not work since it relies on a PySwigObject
> which is... "unpicklable" :-)
>
> As far as I remember libsvm alone can dump the training results
> (support vectors etc.) to file for later use. Is this wrapped in some way?
>
> Any idea?
>
> Thanks a lot,
>
> Emanuele
>
>
> _______________________________________________
> Pkg-ExpPsy-PyMVPA mailing list
> Pkg-ExpPsy-PyMVPA at lists.alioth.debian.org
> http://lists.alioth.debian.org/mailman/listinfo/pkg-exppsy-pymvpa
>

-- 
                                  .-.
=------------------------------   /v\  ----------------------------=
Keep in touch                    // \\     (yoh@|www.)onerussian.com
Yaroslav Halchenko              /(   )\               ICQ#: 60653192
                   Linux User    ^^-^^    [175555]





More information about the Pkg-ExpPsy-PyMVPA mailing list