简体   繁体   中英

ModuleNotFoundError: No module named 'xgboost.sklearn'

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?

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.

XGBOOST is in xgboost module: It should be imported as:

`from xgboost import XGBRegressor`

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM