How to do it...

We'll now move on to training our models:

  1. In the following code block, we'll create multiple homogeneous models over a few iterations using tf.keras:
accuracy = pd.DataFrame( columns=["Accuracy","Precision","Recall"])predictions = np.zeros(shape=(10000,7))row_index = 0for i in range(7):        # bootstrap sampling         boot_train = resample(x_train,y_train,replace=True, n_samples=40000, random_state=None)        model = tf.keras.Sequential([            tf.keras.layers.Flatten(input_shape=(28, 28)),            tf.keras.layers.Dense(256, activation=tf.nn.relu),            tf.keras.layers.Dense(128, activation=tf.nn.relu),            tf.keras.layers.Dense(128, activation=tf.nn.relu),            tf.keras.layers.Dense(128, activation=tf.nn.relu), tf.keras.layers.Dense(128, activation=tf.nn.relu), ...

Get Ensemble Machine Learning Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.