MulaiMulai sekarang secara gratis

Making predictions

The trained network from your previous coding exercise is now stored as model. New data to make predictions is stored in a NumPy array as pred_data. Use model to make predictions on your new data.

In this exercise, your predictions will be probabilities, which is the most common way for data scientists to communicate their predictions to colleagues.

Latihan ini adalah bagian dari kursus

Introduction to Deep Learning in Python

Lihat Kursus

Petunjuk latihan

  • Create your predictions using the model's .predict() method on pred_data.
  • Use NumPy indexing to find the column corresponding to predicted probabilities of survival being True. This is the second column (index 1) of predictions. Store the result in predicted_prob_true and print it.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Specify, compile, and fit the model
model = Sequential()
model.add(Dense(32, activation='relu', input_shape = (n_cols,)))
model.add(Dense(2, activation='softmax'))
model.compile(optimizer='sgd', 
              loss='categorical_crossentropy', 
              metrics=['accuracy'])
model.fit(predictors, target)

# Calculate predictions: predictions
predictions = ____

# Calculate predicted probability of survival: predicted_prob_true
predicted_prob_true = ____

# Print predicted_prob_true
print(predicted_prob_true)
Edit dan Jalankan Kode