text_plain_output_1.png image_output_1.png
import numpy as np

import pandas as pd

import tensorflow as tf

train_df = pd.read_csv('../input/titanic/train.csv')
test_df = pd.read_csv('../input/titanic/test.csv')

n_train = 700
X_train_class = train_df['Pclass'].values.reshape(-1, 1)
X_train_sex = train_df['Sex'].values.reshape(-1, 1)
X_train_age = train_df['Age'].values.reshape(-1, 1)
X_train_sib = train_df['SibSp'].values.reshape(-1, 1)
X_train_par = train_df['Parch'].values.reshape(-1, 1)
y = train_df['Survived'].values.T

X_train = np.hstack((X_train_sex[:n_train, :], X_train_class[:n_train, :], X_train_sib[:n_train, :], X_train_age[:n_train, :], X_train_par[:n_train, :]))
X_test = np.hstack((X_train_sex[n_train:, :], X_train_class[n_train:, :], X_train_sib[n_train:, :], X_train_age[n_train:, :], X_train_par[n_train:, :]))
X_train, X_test = (tf.convert_to_tensor(X_train.astype(np.float64)), tf.convert_to_tensor(X_test.astype(np.float64)))
y_train, y_test = (y[:n_train], y[n_train:])

X_test_class = test_df['Pclass'].values.reshape(-1, 1)
X_test_sex = test_df['Sex'].values.reshape(-1, 1)
X_test_age = test_df['Age'].values.reshape(-1, 1)
X_test_sib = test_df['SibSp'].values.reshape(-1, 1)
X_test_par = test_df['Parch'].values.reshape(-1, 1)
x_test = np.hstack((X_test_sex, X_test_class, X_test_sib, X_test_age, X_test_par)).astype(np.float64)

print(x_test)