Okay then, I'll put together a PR to do that, in the days to come.

On Thursday, 29 November 2012,  <amuel...@ais.uni-bonn.de> wrote:
> +1
>
>
>
> Doug Coleman <doug.cole...@gmail.com> schrieb:
>
> I guess transforming it would be more in line with other classifiers. The
design decision could be "You should only have to know about multi-output
if you want to use it."
>
> On Thu, Nov 29, 2012 at 10:07 AM, Doug Coleman <doug.cole...@gmail.com>
wrote:
>
> Going off of my unit tests in my branch for classes= in init:
> Single output:
> clf = tree.DecisionTreeClassifier(classes=[1,2,3,4])
> clf.fit([[10]], [0])
> In [13]: clf.classes_
> Out[13]: [array([0, 1, 2, 3, 4])]
> Multi-output:
> clf = tree.DecisionTreeClassifier(classes=[[-1,1],[0,1,2,3,4]])
> y_hat = clf.fit(X_multi, y_multi).predict(T)
> In [9]: clf.classes_
> Out[9]: [array([-1,  1]), array([0, 1, 2, 3, 4])]
>
> So it's as you say and I understand why. Maybe we could have a method
``supports_multi_output`` that returns a boolean so we know what shape the
classes_ are given some arbitrary clf? Or just introspect it?
> Doug
>
> On Thu, Nov 29, 2012 at 9:57 AM, Gilles Louppe <g.lou...@gmail.com> wrote:
>
> Hi,
>
> Yes, since decision trees handle multi-output problems, classes_[i] is
> an array containing the classes for the i-th output. Hence classes_[0]
> is the array you are looking for when `y` is 1D.
>
> I guess we could transform classes_ directly into that array if the
> decision tree is trained on a 1D-output, actually just like we already
> do at the prediction time.
>
> What do you think?
>
> Gilles
>
> On 29 November 2012 18:48,  <amuel...@ais.uni-bonn.de> wrote:
>> the classes_ attribute is not present in all classifiers and not
consistent,
>> as you noticed.
>> this is a known issue (see the issue tracker) and it would be great to
>> address this.
>> I am not sure about the decision trees in particular.
>>
>>
>>
>> Doug Coleman <doug.cole...@gmail.com> schrieb:
>>>
>>> Decision trees' classes are wrapped in another array for some reason. I
>>> was under the impression that I could just get ``clf.classes_`` from
any old
>>> classifier and it would be a nice list, but I guess I'm mistaken. It
makes
>>> it hard to write utilities...is this an oversight or a bug, or by
design? I
>>> haven't checked other classifiers.
>>>
>>> from sklearn.tree import DecisionTreeClassifier
>>> clf1 = DecisionTreeClassifier()
>>>
>>> In [104]: clf1.classes_
>>> Out[104]: [array([1, 2, 3])]
>>>
>>>
>>> from sklearn.linear_model import SGDClassifier
>>> clf2 = SGDClassifier()
>>> clf2.fit([[1],[2],[3]], [1,2,3])
>>>
>>> In [100]: clf2.classes_
>>> Out[100]: array([1, 2, 3])
>>>
>>>
>>>
>>>
>>> Thanks,
>>> Doug
>>>
>>> ________________________________
>>>
>>> Keep yourself connected to Go Parallel:
>>> VERIFY Test and improve your parallel project with help from experts
>>> and peers. http://goparallel.sourceforge.net
>>>
>>> ________________________________
>>>
>>> Scikit-learn-general mailing list
>>> Scikit-learn-general@lists.sourceforge.net
>>> https://lists.sourceforge.ne
------------------------------------------------------------------------------
Keep yourself connected to Go Parallel: 
VERIFY Test and improve your parallel project with help from experts 
and peers. http://goparallel.sourceforge.net
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to