gpt4 book ai didi

python - 属性错误: Module "lightgbm" has no attribute "LGBMClassifier" and "Dataset"

转载 作者:行者123 更新时间:2023-12-01 01:06:22 26 4
gpt4 key购买 nike

我使用pip版本16.0.0安装了lightgbm(2.2.3),但在上传数据集时出错。代码如下:

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'

最佳答案

我认为属性Attribute Error in Python有这个错误,参见:

Python 中的属性表示与特定类型的对象关联的某些属性。换句话说,给定对象的属性是每种对象类型固有地拥有的数据和能力。

也许您创建了一个类似的 python 脚本,并且像默认的 python 模块 lightgbm 一样。

尝试使用开始步骤开始开发,这对我来说效果很好,请参阅类似的错误示例:

>>> import lightgbm 
>>> from lightgbm import *

这是sintax导入的错误(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

未定义的错误:

>>> 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']

关于python - 属性错误: Module "lightgbm" has no attribute "LGBMClassifier" and "Dataset",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55312601/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com