Alternatively you can pickle a tuple:
s = dumps((o1, o2))
and load it in one statement:
o1, o2 = loads(s)
On Fri, Jul 19, 2013 at 2:26 AM, Gilles Louppe <[email protected]> wrote:
> Hi,
>
>
>> I'm well aware I can pickle it, but I would like to avoid having to write
>> 2 files - otherwise I would just write the classes to a text file.
>>
>
> You pickle several Python objects using the same file handler.
>
> Gilles
>
>
>
>>
>> Lars,
>> Well, I'm confused now, sklearn.__version__ says "0.14-git". Did I
>> download the development branch?
>>
>> Your code works, so you're right, they do take string classifiers. My
>> problem appears to arise when trying to use the scorers:
>> If I try:
>> metrics.classification_report(ytest, ypred)
>> My error is:
>> File
>> "/usr/local/lib64/python2.7/site-packages/sklearn/metrics/metrics.py", line
>> 2083, in classification_report
>> target_names = ['%d' % l for l in labels]
>> TypeError: %d format: a number is required, not numpy.string_
>>
>> Can I not use just the scorers with string classes?
>>
>> On Thu, Jul 18, 2013 at 1:02 AM, <
>> [email protected]> wrote:
>>
>>>
>>>
>>> ------------------------------
>>>
>>> Message: 2
>>> Date: Thu, 18 Jul 2013 09:01:57 +0200
>>> From: Lars Buitinck <[email protected]>
>>> Subject: Re: [Scikit-learn-general] Associating a LabelEncoder with a
>>> Classifier?
>>> To: [email protected]
>>> Message-ID:
>>> <CAKz-xUdB=
>>> [email protected]>
>>> Content-Type: text/plain; charset=UTF-8
>>>
>>> 2013/7/18 Wifi Gi <[email protected]>:
>>>
>>> > I am using Gaussian Bayes, Bernoulli Bayes, k-Nearest Neighbors, and
>>> the
>>> > Decision Tree. None of them are taking string classes, hence why I was
>>> using
>>> > the LabelEncoder. Maybe I have an old/broken version? I have
>>> scikit-learn
>>> > version 0.14.
>>>
>>> The Naive Bayes classes support string labels all right:
>>>
>>> In [1]: from sklearn.naive_bayes import BernoulliNB
>>>
>>> In [2]: clf = BernoulliNB().fit([[1,0,0],[0,1,1]], ["no", "yes"])
>>>
>>> In [3]: clf.predict([1,1,1])
>>> Out[3]:
>>> array(['yes'],
>>> dtype='|S3')
>>>
>>> In [4]: from sklearn.naive_bayes import GaussianNB
>>>
>>> In [5]: clf = GaussianNB().fit([[1,0,0],[0,1,1]], ["no", "yes"])
>>>
>>> In [6]: clf.predict([1,1,1])
>>> Out[6]:
>>> array(['yes'],
>>> dtype='|S3')
>>>
>>> In [7]: clf.classes_
>>> Out[7]:
>>> array(['no', 'yes'],
>>> dtype='|S3')
>>>
>>> And no, 0.14 isn't old, it's not even released yet.
>>>
>>> --
>>> Lars Buitinck
>>> Scientific programmer, ILPS
>>> University of Amsterdam
>>>
>>>
>>>
>>>
>>> End of Scikit-learn-general Digest, Vol 42, Issue 62
>>> ****************************************************
>>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> See everything from the browser to the database with AppDynamics
>> Get end-to-end visibility with application monitoring from AppDynamics
>> Isolate bottlenecks and diagnose root cause in seconds.
>> Start your free trial of AppDynamics Pro today!
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Scikit-learn-general mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>>
>>
>
>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
> _______________________________________________
> Scikit-learn-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>
>
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general