title: Python xgboost: kernel died
body: <p>My Jupyter notebook's python kernel keeps dying. I have run all of the following code successfully before. Presently, there are issues. First, I will show you the code chunk that I am able to run successfully:</p>
  
  <pre><code>import xgboost as xgb
  xgtrain = xgb.DMatrix(data = X_train_sub.values, label = Y_train.values)       # create dense matrix of training values
  xgtest  = xgb.DMatrix(data = X_test_sub.values,  label = Y_test.values)        # create dense matrix of test values
  param   = {'max_depth':2, 'eta':1, 'silent':1, 'objective':'binary:logistic'}  # specify parameters via map
  </code></pre>
  
  <p>where my data is small:</p>
  
  <pre><code>X_train_imp_sub.shape
  (1365, 18)
  </code></pre>
  
  <p>however, my notebook's kernel keeps dying on this chunk:</p>
  
  <pre><code>xgmodel = xgb.train(param,  xgtrain, num_boost_round = 2)                      # train the model
  predictions = xgmodel.predict(xgtest)                                          # make prediction
  from sklearn.metrics import accuracy_score                                   
  accuracy = accuracy_score(y_true = Y_test, 
                            y_pred = predictions.round(), 
                            normalize = True) # If False, return # of correctly classified samples. Else, return fraction of correctly classified samples
  print("Accuracy: %.2f%%" % (accuracy * 100.0))
  </code></pre>
  
  <p>When I break it apart and run line-by-line, the kernel appears to die on the <code>xgb.train()</code> line.</p>
  
  <p>The data is small. The xgboost parameters should be conservative (i.e. <code>num_boost_round = 2</code>, <code>max_depth:2</code>, <code>eta:1</code> and not computationally expensive. Not sure what is going on.</p>
  
  <p>As stated before, I have been able to run both chunks successfully before. I have shut down all other notebooks and restarted my computer without luck. I am launching <code>jupyter</code> through Anaconda Navigator on a Macbook Pro.</p>
  
  <p>-- UPDATE --
  When I selected a cell beneath my <code>xgboost</code> training cell, then selected: <code>Cells</code> --> <code>Run All Above</code>, the kernel would always die on the <code>xgboost</code> training line. This happened ~40-50 times in a row. I tried that many times because I was making changes to the code, thinking I would resolve the <code>xgboost</code> issue later.</p>
  
  <p>Later on, I ran the same cells one-by-one and the <code>xgboost</code> completed fine on the first time I tried this and every time after. I do not know why this happens but it would be nice to know.</p>