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.net/lists/listinfo/scikit-learn-general
>
> --
> Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail
> gesendet.dy>
>
> ------------------------------------------------------------------------------
> 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
>

------------------------------------------------------------------------------
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