Reputation: 49
I installed lightgbm(2.2.3) using pip version 16.0.0 and got error while uploading the dataset .Code shown below:
import lightgbm as gbm
d_train=gbm.Dataset(train_x,label=train_y)
File "lightgbm.py", line 13, in
import lightgbm as gbm
File "S:\MP pillai meet\Minor Project\ml-challenge-6-v1\ml-challenge-6\lightgbm.py", line 104, in d_train=gbm.Dataset(train_x,label=train_y)
AttributeError: module 'lightgbm' has no attribute 'Dataset'
Upvotes: 1
Views: 11851
Reputation: 156
File "lightgbm.py", line 13, in
, this is the thing, your script file name should not have the same name as the module lightgbm
. Change your script file name should solve the problem.
Upvotes: 1
Reputation: 1569
I think this error of attribute Attribute Error in Python, see:
An attribute in Python means some property that is associated with a particular type of object. In other words, the attributes of a given object are the data and abilities that each object type inherently possesses.
Maybe you create a similar python script and is get like the default python module lightgbm.
Try to start developing with start steps, working well for me , see similar examples of errors:
>>> import lightgbm
>>> from lightgbm import *
This is an error of sintax import (bad ligtgbm):
>>> from ligtgbm import Dataset
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named ligtgbm
>>> from lightgbm import Dataset
Error of non defined:
>>> d_train=lightgbm.Dataset(train_x,label=train_y)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'train_x' is not defined
>>> train_x =''
>>> train_y =''
>>> d_train=lightgbm.Dataset(train_x,label=train_y)
>>> dir(d_train)
['_Dataset__init_from_csc', '_Dataset__init_from_csr', '_Dataset__init_from_list_np2d', '_Dataset__init_from_np2d', '__class__', '__del__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_free_handle', '_lazy_init', '_predictor', '_reverse_update_params', '_set_predictor', '_update_params', 'categorical_feature', 'construct', 'create_valid', 'data', 'feature_name', 'free_raw_data', 'get_data', 'get_field', 'get_group', 'get_init_score', 'get_label', 'get_ref_chain', 'get_weight', 'group', 'handle', 'init_score', 'label', 'need_slice', 'num_data', 'num_feature', 'pandas_categorical', 'params', 'params_back_up', 'reference', 'save_binary', 'set_categorical_feature', 'set_feature_name', 'set_field', 'set_group', 'set_init_score', 'set_label', 'set_reference', 'set_weight', 'silent', 'subset', 'used_indices', 'weight']
Upvotes: 3