问题
I am migrating a piece of software from Python 2.7 to Python 3.
One problem that arises is:
The sklearn.neighbors.kde module is deprecated in version 0.22 and will be removed in version 0.24. The corresponding classes / functions should instead be imported from sklearn.neighbors. Anything that cannot be imported from sklearn.neighbors is now part of the private API.
I am not sure which line causes this, and not sure if it is an error or a warning, and what are the implications.
On python 2.7 everything works fine.
How do I get rid of this?
回答1:
It will work until you will update your scikit / sklearn version. Then this package: https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.KernelDensity.html you will not be able to run anymore. You have now time to search for similiar modules if you want to update your version.
But also as a hint, you can also set-up different enviorments with different versions, so if you need this module just start an enviornment and don't upgrade your sklear version in this enviornment.
回答2:
It's just a warning, for now -- until you upgrade sklearn to version 0.24. Then your code will need to be modified before it works. It's giving you a heads-up about this, so you can fix your code ahead of time. The modifications described below should work with your current version; you don't need to wait to upgrade before changing your code (at least, that's how these deprecation warnings usually work).
The corresponding classes / functions should instead be imported from sklearn.neighbors.
If I read this message correctly, it's saying that if you're using a function like sklearn.neighbours.kde.some_function()
in your code now, you need to change it to sklearn.neighbours.some_function()
.
Anything that cannot be imported from sklearn.neighbors is now part of the private API.
This seems to be saying that there may be some functions that will no longer be available to you, even using the modification above.
来源:https://stackoverflow.com/questions/59643694/the-sklearn-module-is-deprecated-in-version-0-22-and-will-be-removed-in-versio