Home > Software design >  name 'train' is not defined
name 'train' is not defined

Time:10-05

I'm trying to train Titanic's data with google colaboratory but i can't train with preprocess command. It gives me name 'train' is not defined error. How can i figure with this problem ?

  import numpy as np
seed = 7
np.random.seed(seed)

import pandas as pd
train_df = pd.read_csv('/content/drive/MyDrive/Colab Notebooks/train.csv' , header=0)
 

preprocess(train)
group_titles(train)


num_epochs = 100
batch_size = 32



traindata, lengh_features = data_subset(train)

Y_train = np.array(train['Survived']).astype(int)
X_train = np.array(traindata).astype(float)


train_set_size = int(.67 * len(X_train))


model, history_model = create_model(train_set_size, lengh_features, num_epochs, batch_size)

plots(history_model)


X_validation = X_train[train_set_size:]
Y_validation = Y_train[train_set_size:]


loss_and_metrics = model.evaluate(X_validation, Y_validation, batch_size=batch_size)
print ("loss_and_metrics")

test(batch_size)

but i'm getting -> name 'train' is not defined error can you help me with this ? (I'm using google colab)

CodePudding user response:

It looks like you defined your variable with train_df

Exact excerpt:

train_df = pd.read_csv('/content/drive/MyDrive/Colab Notebooks/train.csv' , header=0)

Maybe you need to use train_df rather than train.

  • Related