尝试使用安装 Shapley 包(在 R 中可用)
install shap
但出现错误:
Building wheels for collected packages: shap, iml
Running setup.py bdist_wheel for shap ... error
Complete output from command C:\Users\Toly_Novik\Anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\TOLY_N~1\\AppData\\Local\\Temp \\pip-install-o0p96nl3\\shap\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\TOLY_N~1\AppData\Local\Temp\pip-wheel-538qnmm2 --python-tag cp36:
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-3.6
creating build\lib.win-amd64-3.6\shap
copying shap\datasets.py -> build\lib.win-amd64-3.6\shap
copying shap\plots.py -> build\lib.win-amd64-3.6\shap
copying shap__init__.py -> build\lib.win-amd64-3.6\shap
creating build\lib.win-amd64-3.6\shap\explainers
copying shap\explainers\ime.py -> build\lib.win-amd64-3.6\shap\explainers
copying shap\explainers\kernel.py -> build\lib.win-amd64-3.6\shap\explainers
copying shap\explainers\mimic.py -> build\lib.win-amd64-3.6\shap\explainers
copying shap\explainers\pytree.py -> build\lib.win-amd64-3.6\shap\explainers
copying shap\explainers\tree.py -> build\lib.win-amd64-3.6\shap\explainers
copying shap\explainers__init__.py -> build\lib.win-amd64-3.6 \shap\explainers
running build_ext
numpy.get_include() C:\Users\Toly_Novik\Anaconda3\lib\site-packages\numpy\core\include
building 'shap._cext' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools
安装 xgboost 同样的故事
原文由 Toly 发布,翻译遵循 CC BY-SA 4.0 许可协议
您是否打算安装 shapely ( https://pypi.org/project/Shapely/ )?在 python 中,你可以通过执行
pip install shapely
来安装 shapely对于 Windows,可以通过从 http://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely 下载 .whl 来安装 shapley,然后执行
pip install <name of whl file>
或者,如果您使用的是 anaconda,则可以使用 conda-forge 来保持身材
conda config --add channels conda-forge conda install shapely
要安装 xgboost,请参阅 http://xgboost.readthedocs.io/en/latest/python/python_intro.html 为此,您可能需要 gcc(c/c++ 编译器)或等效的 Microsoft 替代方案。
对于带有 conda 的 xgboost,您可以看到这个 stackoverflow.com/questions/35139108/… 或者简单地做
conda install py-xgboost