LightGBM icon indicating copy to clipboard operation
LightGBM copied to clipboard

AttributeError: module 'lightgbm' has no attribute 'Dataset'

Open WuZhuoran opened this issue 9 years ago • 7 comments

Environment info

Operating System: Windows 10 CPU: i7-4710MQ C++/Python/R version: Python 3.5.2

Error Message:

Traceback (most recent call last):
  File "D:/Coding/github/DataFountain/VIPCOM/src/lightgbm.py", line 7, in <module>
    import lightgbm as lgb
  File "D:\Coding\github\DataFountain\VIPCOM\src\lightgbm.py", line 78, in <module>
    train_lgb = lgb.Dataset(dftrain, label=train_label)
AttributeError: module 'lightgbm' has no attribute 'Dataset'

Reproducible examples

RS = 1
ROUNDS = 500
lgb_params = {
    'objective': 'regression',
    'metric': 'rmse',
    'boosting': 'gbdt',
    'learning_rate': 0.01,  # small learn rate, large number of iterations
    'verbose': 0,
    'num_leaves': 2 ** 5,
    'bagging_fraction': 0.95,
    'bagging_freq': 1,
    'bagging_seed': RS,
    'feature_fraction': 0.7,
    'feature_fraction_seed': RS,
    'max_bin': 100,
    'max_depth': 7,
    'num_rounds': ROUNDS,
}

train_lgb = lgb.Dataset(dftrain, label=train_label)

cv_output = lgb.cv(lgb_params, train_lgb, num_boost_round=ROUNDS, verbose_eval=50, show_stdv=False, nfold=5)
print(cv_output[['train-rmse-mean', 'test-rmse-mean']])

WuZhuoran avatar Jul 18 '17 05:07 WuZhuoran

please check https://github.com/Microsoft/LightGBM/issues/683

chivee avatar Jul 18 '17 05:07 chivee

Hi @chivee

I have already checked that issue, but that doesn't work for me.

I am sure that lightgbm is installed well.

Do you have a better idea?

WuZhuoran avatar Jul 18 '17 05:07 WuZhuoran

What is your VC version ?

chivee avatar Jul 18 '17 06:07 chivee

MSVC 2015 14.0.24215

WuZhuoran avatar Jul 18 '17 06:07 WuZhuoran

@WuZhuoran make sure your vc runtime is 64-bit.

another possible reason is your lightgbm installation is not complete. you can try to uninstall it, and re-install again (may need to run as administrator ) .

guolinke avatar Jul 18 '17 06:07 guolinke

@WuZhuoran , Could you please also check your VC Runtime is x64 based version? and make sure your vc runtime was well set in your environments.

and if you are pretty sure you have lightgbm installed. you can try binary version first

chivee avatar Jul 18 '17 06:07 chivee

The issue here is that the name of your Python script is lightgbm.py which confuses Python at the statement from lightgbm import Dataset.

File "D:\Coding\github\DataFountain\VIPCOM\src\lightgbm.py", line 78, in <module>

zouzias avatar Sep 05 '19 23:09 zouzias