deprecation error in sklearn about empty array without any empty array in my code

前端 未结 2 1252
失恋的感觉
失恋的感觉 2021-02-04 07:57

I am just playing around encoding and decoding but I get this error from sklearn:

Warning (from warnings module): File \"C:\\Python36\\lib\\site-packa

相关标签:
2条回答
  • 2021-02-04 08:00

    TLDR: You can ignore the warning. It is caused by sklearn doing something internally that is not quite ideal.


    The warning is actually caused by numpy, which deprecated truth testing on empty arrays:

    The long and short is that truth-testing on empty arrays is dangerous, misleading, and not in any way useful, and should be deprecated.

    This means one is not supposed to do something like if array: to check if array is empty. However, sklearn does this in the 0.19.1 release:

        diff = np.setdiff1d(y, np.arange(len(self.classes_)))
        if diff:
            raise ValueError("y contains new labels: %s" % str(diff))
    

    Because your version of numpy is recent enough it complains and issues a warning.

    The problem has been fixed in sklearn's current master branch, so I'd expect the fix to be included in the next release.

    0 讨论(0)
  • 2021-02-04 08:07

    After updated numpy, the warning was cleared away:

    conda update numpy
    

    You can also update it by pip or something else.

    0 讨论(0)
提交回复
热议问题