ModuleNotFoundError: No module named 'xgboost.sklearn'

こ雲淡風輕ζ 提交于 2021-01-28 11:54:12

问题


I'm trying to import xgboost into jupyter-notebook but get the following error:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-9-a585b270d0df> in <module>
      1 import pandas as pd
      2 import numpy as np
----> 3 import xgboost

~/.local/lib/python3.6/site-packages/xgboost/__init__.py in <module>
     14 from . import tracker  # noqa
     15 from .tracker import RabitTracker  # noqa
---> 16 from . import dask
     17 try:
     18     from .sklearn import XGBModel, XGBClassifier, XGBRegressor, XGBRanker

~/.local/lib/python3.6/site-packages/xgboost/dask.py in <module>
     31 from .training import train as worker_train
     32 from .tracker import RabitTracker
---> 33 from .sklearn import XGBModel, XGBClassifierBase, xgboost_model_doc
     34 
     35 # Current status is considered as initial support, many features are

ModuleNotFoundError: No module named 'xgboost.sklearn'

I've downloaded sklearn as well as sci-kit learn and they work fine... Any idea what the problem is?


回答1:


You might need to install your packages properly. For best practice, you'll need to use a conda environment. Check out how it works here: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html

Once you have created your environment, activate it and then install all the packages you need. Presumably, you'll have to run the command:

  • conda install -c conda-forge xgboost
  • pip install -U scikit-learn

To install your machine learning packages.



来源:https://stackoverflow.com/questions/61800137/modulenotfounderror-no-module-named-xgboost-sklearn

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!