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.
Bu egzersiz
Introduction to Deep Learning in Python
kursunun bir parçasıdırEgzersiz talimatları
- Create your predictions using the model's
.predict()method onpred_data. - Use NumPy indexing to find the column corresponding to predicted probabilities of survival being True. This is the second column (index
1) ofpredictions. Store the result inpredicted_prob_trueand print it.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
# 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)