[scikit-learn] Problem found when testing DecisionTreeClassifier within the source folder

Joel Nothman joel.nothman at gmail.com
Mon Sep 4 23:21:01 EDT 2017


I suspect this is due to an intricacy of Cython. Despite using relative
imports, Cython expects the Criterion instance to come from a package
called sklearn, not called sklearn1.

On 5 September 2017 at 12:42, hanzi mao <hzmao at hotmail.com> wrote:

> Hi,
>
> I am researching on the source code of DecisionTree recently. Here are the
> things I tried.
>
>
>    1. Downloaded source code from github.
>    2. run "python setup.py build_ext --inplace" to compile the sources in
>    the unzipped source folder.
>    3. Try the following codes to see whether it works. Here I changed the
>    name of the sklearn folder to sklearn1 to differentiate it from the one
>    installed.
>
>
> >>> from sklearn1 import tree
>
> >>> from sklearn.datasets import load_iris
>
> >>> iris = load_iris()
>
> >>> clf = tree.DecisionTreeClassifier()
>
> >>> clf = clf.fit(iris.data, iris.target)
>
> Traceback (most recent call last):
>
>   File "<stdin>", line 1, in <module>
>
>   File "sklearn1\tree\tree.py", line 790, in fit
>
>     X_idx_sorted=X_idx_sorted)
>
>   File "sklearn1\tree\tree.py", line 341, in fit
>
>     self.presort)
>
> TypeError: Argument 'criterion' has incorrect type (expected
> sklearn.tree._criterion.Criterion, got sklearn.tree._criterion.Gini)
>
> Then a weird error happened. Actually I also tried the newest stable
> version of scikit-learn earlier today. It had the same error. So I was
> thinking maybe try the newest version in github might help. Unlikely, it
> didn't.
>
> I have limited knowledge about the source code of scikit-learn. I am
> wondering if anyone could help me with this.
>
> Thanks!
>
> Best,
> Hanna
>
>
>
> _______________________________________________
> scikit-learn mailing list
> scikit-learn at python.org
> https://mail.python.org/mailman/listinfo/scikit-learn
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-learn/attachments/20170905/f3830d20/attachment.html>


More information about the scikit-learn mailing list