# Where are the predicted results located in this model?

I am new at this and am pretty sure this is a stupid question, but here it goes:

Where can I see the results of a model's prediction?

I did this course about deep learning, followed the tutorial, ran all the code, and trained this artificial neural network to perform customer churn prediction.

In the "Predicting the Test set results". It prints the y_pred as below:

y_pred = ann.predict(X_test)
y_pred = (y_pred > 0.5)
print(np.concatenate((y_pred.reshape(len(y_pred),1), y_test.reshape(len(y_test),1)),1))


Output:

[[0 0]
[1 1]
[1 1]
...
[0 0]
[1 1]
[1 0]]


I thought it was the y_pred data that would show the prediction for each customer, but it only has 756 results and the dataset has more than 3000 customers.

Where can I see the prediction for each customer in the dataset?

Here is the whole code, in case, you guys need to check it:

import numpy as np
import pandas as pd
import tensorflow as tf

tf.__version__

X = dataset.iloc[:, 3:-1].values
y = dataset.iloc[:, -1].values
print(X)
print(y)

print(X)

print(y)

from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 0)

### Initializing the ANN
"""

ann = tf.keras.models.Sequential()

"""### Adding the input layer and the first hidden layer"""

"""### Adding the second hidden layer"""

"""## Part 3 - Training the ANN

### Compiling the ANN
"""

ann.compile(optimizer = 'adam', loss = 'binary_crossentropy', metrics = ['accuracy'])

"""### Training the ANN on the Training set"""

ann.fit(X_train, y_train, batch_size = 32, epochs = 100)

"""## Part 4 - Making the predictions and evaluating the model

### Predicting the Test set results
"""

y_pred = ann.predict(X_test)
y_pred = (y_pred > 0.5)
print(np.concatenate((y_pred.reshape(len(y_pred),1), y_test.reshape(len(y_test),1)),1))

pred=np.concatenate((y_pred.reshape(len(y_pred),1), y_test.reshape(len(y_test),1)),1)
np.savetxt("predicitons.csv", pred, delimiter=",")

"""### Making the Confusion Matrix"""

from sklearn.metrics import confusion_matrix, accuracy_score
cm = confusion_matrix(y_test, y_pred)
print(cm)
accuracy_score(y_test, y_pred)


The y_pred vector should hold all predictions for your observations present in the X_test dataset, which should be 756 observations. If you want to use your model on the whole dataset you can simply use the .predict() method on your X_train dataset:
# predict on your training dataset

• There are probably several ways, but I personally would find it easiest to convert the numpy array to a pandas dataframe and save that to a csv file (or excel file). Have a look at the pandas library and the .to_csv() method. Commented Sep 18, 2021 at 20:28