3

I am using the data from the following Kaggle competition to train Random Forest on Tensorflow - https://www.kaggle.com/c/santander-product-recommendation

The code was working fine a day ago but now whenever I run the training code for the Random Forest: I get the following message (This is not an error message on the code but for the jupyter kernel):

The kernel appears to have died. It will restart automatically.

I am using the following code:

import tensorflow as tf
import numpy as np
import pandas as pd
import math
import os
from glob import glob
import google.datalab.bigquery as bq
print('Libraries Imported')

trainingdata = bq.Query('SELECT * FROM `kagglesantander.training`')
train_dataset = trainingdata.execute(output_options=bq.QueryOutput.dataframe()).result()
print('Train Data Fetched')

X = train_dataset.iloc[:,1:-1]
y = train_dataset.iloc[:,-1]
x_train = X.astype(np.float32).values
y_train = y.astype(np.float32).values
print('Data Prepared')

params = tf.contrib.tensor_forest.python.tensor_forest.ForestHParams(
  num_classes=1, num_features=369, num_trees = 10).fill()    
print("Params =")
print(vars(params))

# Remove previous checkpoints so that we can re-run this step if necessary.
for f in glob("./ModelTrain/*"):
    os.remove(f)
classifier = tf.contrib.tensor_forest.client.random_forest.TensorForestEstimator(
    params, model_dir="./ModelTrain/")
classifier.fit(x=x_train, y=y_train)
print('Forest Trained')

The error is happening due to the line:

classifier.fit(x=x_train, y=y_train)

As I tried the code without the line and it was working fine

0 Answers0