Model error in titanic dataset using TFLEARN
I am practicing how TF learns using pandas and a titanic dataset. I think I hung it, but when I install my model, it crashes and I don't know why. I'm guessing it has something to do with how I converted inputX and inputY
, but I'm not sure, I thought it was correct.
import numpy as np
import tensorflow as tf
import tflearn
import pandas as pd
# Download the Titanic dataset
from tflearn.datasets import titanic
titanic.download_dataset('titanic_dataset.csv')
from tflearn.data_utils import load_csv
dataframe = pd.read_csv('titanic_dataset.csv')
# okay lets drop the rest of the stuff from the table and keep those.
dataframe = dataframe.drop(["name", "ticket"], axis=1)
#lets change sex female/male to 1 and 0
dataframe['sex'].replace(['female','male'],[1,0],inplace=True)
# lets convert them so the tlearn can use doesnt crash
inputX = dataframe.loc[:, ['pclass', 'sex', 'age', 'sibsp', 'parch', 'fare']].as_matrix()
dataframe.loc[:, ("survived2")] = dataframe["survived"] == 0
dataframe.loc[:, ("survived2")] = dataframe["survived2"].astype(int)
inputY = dataframe.loc[:, ["survived", "survived2"]].as_matrix()
def NN():
net = tflearn.input_data(shape=[None, 6])
net = tflearn.fully_connected(net, 32)
net = tflearn.fully_connected(net, 32)
net = tflearn.fully_connected(net, 2, activation='softmax')
net = tflearn.regression(net)
# This model assumes that your network is named "net"
model = tflearn.DNN(net)
return model
# Define model
model = NN()
# Start training (apply gradient descent algorithm)
# Training
model.fit(inputX, inputY, validation_set=0.1, show_metric=True, batch_size=100, n_epoch=8)
+3
source to share
No one has answered this question yet
Check out similar questions: