Am 17.10.2012 20:57, schrieb Kenneth C. Arnold:

>
> import cPickle as pickle # faster on Py2.x, default on Py3.
> with open(filename, 'wb') as f:
>    pickle.dump(obj, f, -1)
>
> The -1 at the end chooses the latest file format version, which is more
> compact.

What exactly does "-1" do? I guess that's the protocol. I have always 
used 2 in this case. Didn't know about -1.

Regards,
Philipp

>
> -Ken
>
>
> On Wed, Oct 17, 2012 at 1:31 PM, Niall Twomey <[email protected]
> <mailto:[email protected]>> wrote:
>
>     Hi all.
>
>     I want to save an array of models trained on lots of data to file. I
>     have tried the following code (roughly speaking anyway)
>
>         models = []
>         # Populate the list of models with dict items containing one
>         number and PCA and GMM models
>         import pickle
>         pickle.dump( "models.pickle", models )
>
>
>     but I get errors saying:
>
>         AttributeError: 'list' object has no attribute 'write'.
>
>     which presumably referrs to the models list.
>
>     Saving them to file is crucial for me, but I have no idea how to
>     proceed from here. Any advice will be appreciated.
>
>     Thanks.
>
>
>     
> ------------------------------------------------------------------------------
>     Everyone hates slow websites. So do we.
>     Make your web apps faster with AppDynamics
>     Download AppDynamics Lite for free today:
>     http://p.sf.net/sfu/appdyn_sfd2d_oct
>     _______________________________________________
>     Scikit-learn-general mailing list
>     [email protected]
>     <mailto:[email protected]>
>     https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>
>
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_sfd2d_oct
>
>
>
> _______________________________________________
> Scikit-learn-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to