Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XGBoost crashing kernel in jupyter notebook

I don't know how to make the XGBoost classifier work. I am running the code below on Jupyter notebook, and it always generates this message "The kernel appears to have died. It will restart automatically."

from xgboost import XGBClassifier
model = XGBClassifier()
model.fit(X, y)

There is no problem with importing the XGBClassifier, but it crashes upon fitting it to my data. X is a 502 by 33 all-numeric dataframe, y is the set of 0 or 1 labels for each row. Does anyone know what could be the problem here? I downloaded the newest version of XGBoost through pip3 install, and also through Conda install.

Thanks!

like image 548
Zofia Avatar asked Aug 09 '18 13:08

Zofia


People also ask

How do I get Xgboost in Jupyter notebook?

Installing xgboost in Anaconda Step 1: Install the current version of Python3 in Anaconda. Step 2: Check pip3 and python3 are correctly installed in the system. Step 3: To install xgboost library we will run the following commands in conda environment.

Why is my Jupyter notebook crashing?

Check which version of pyzmq is installed. If Jupyter Notebook and the kernel are in different conda envs, check both and make sure they are on the same version and build. Try upgrading or downgrading to different versions. According to Anaconda issue 8932, there are problems with pyzmq on Windows.


2 Answers

I was having similar problem. I solved it by installing an older version 0.80.

pip install xgboost==0.80
like image 79
Евгений Куприков Avatar answered Sep 28 '22 18:09

Евгений Куприков


import os
os.environ['KMP_DUPLICATE_LIB_OK']='True'
from xgboost import XGBClassifier
model = XGBClassifier()
model.fit(X, y)
like image 35
fuwiak Avatar answered Sep 28 '22 19:09

fuwiak