简体   繁体   中英

Why does my LightGBM model fail with an OSError?

I am working with a large dataset (44,486,280 rows, 9 columns).

I wanted to run a base LightGBM model to test what sort of predictions it makes. It is my first time participating in a Kaggle competition, and I was unsure of where to proceed from here so I decided to just fit one model to see what happens.

This is the command I ran:

import lightgbm as lbm
model = lbm.LGBMClassifier(learning_rate=0.2,max_depth=-5,random_state=42)
model.fit(X, y, verbose=1)

And this is the error that I get.

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-24-b84ba76ebc07> in <module>
----> 1 model.fit(X, y, verbose=1)

~\anaconda3\lib\site-packages\lightgbm\sklearn.py in fit(self, X, y, sample_weight, init_score, eval_set, eval_names, eval_sample_weight, eval_class_weight, eval_init_score, eval_metric, early_stopping_rounds, verbose, feature_name, categorical_feature, callbacks, init_model)
    965                     valid_sets[i] = (valid_x, self._le.transform(valid_y))
    966 
--> 967         super().fit(X, _y, sample_weight=sample_weight, init_score=init_score, eval_set=valid_sets,
    968                     eval_names=eval_names, eval_sample_weight=eval_sample_weight,
    969                     eval_class_weight=eval_class_weight, eval_init_score=eval_init_score,

~\anaconda3\lib\site-packages\lightgbm\sklearn.py in fit(self, X, y, sample_weight, init_score, group, eval_set, eval_names, eval_sample_weight, eval_class_weight, eval_init_score, eval_group, eval_metric, early_stopping_rounds, verbose, feature_name, categorical_feature, callbacks, init_model)
    746         callbacks.append(record_evaluation(evals_result))
    747 
--> 748         self._Booster = train(
    749             params=params,
    750             train_set=train_set,

~\anaconda3\lib\site-packages\lightgbm\engine.py in train(params, train_set, num_boost_round, valid_sets, valid_names, fobj, feval, init_model, feature_name, categorical_feature, early_stopping_rounds, evals_result, verbose_eval, learning_rates, keep_training_booster, callbacks)
    269     # construct booster
    270     try:
--> 271         booster = Booster(params=params, train_set=train_set)
    272         if is_valid_contain_train:
    273             booster.set_train_data_name(train_data_name)

~\anaconda3\lib\site-packages\lightgbm\basic.py in __init__(self, params, train_set, model_file, model_str, silent)
   2608             params_str = param_dict_to_str(params)
   2609             self.handle = ctypes.c_void_p()
-> 2610             _safe_call(_LIB.LGBM_BoosterCreate(
   2611                 train_set.handle,
   2612                 c_str(params_str),

OSError: exception: access violation writing 0x0000000000000000

I am honestly clueless and would appreciate some help. I apologise if this is a repeat question, I did my best to search around and could not find anything that addressed my issue.

Thank you!

Try to uninstall and re-install LightGBM and update numpy,scipy and scikit-learn packages. I hope this link could help you.

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