Skip to Main Content
Ensemble Machine Learning Cookbook
book

Ensemble Machine Learning Cookbook

by Dipayan Sarkar, Vijayalakshmi Natarajan
January 2019
Beginner to intermediate content levelBeginner to intermediate
336 pages
7h 58m
English
Packt Publishing
Content preview from Ensemble Machine Learning Cookbook

How to do it...

We'll now build a single model with the Keras library:

  1. Build a linear stack of layers with the sequential model:
# building a linear stack of layers with the sequential modelmodel = Sequential()model.add(Dense(512, input_shape=(1024,)))model.add(Activation('relu')) model.add(Dense(512))model.add(Activation('relu'))model.add(Dense(10))model.add(Activation('softmax'))
  1. Compile the model:
# compiling the sequential modelmodel.compile(loss='categorical_crossentropy', metrics=['accuracy'], optimizer='adam')
  1. Fit the model to the train data and validate it with the test data:
# training the model and saving metrics in historysvhn_model = model.fit(x_train, y_train,          batch_size=128, epochs=100,          verbose=2, validation_data=(x_test, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Productive and Efficient Data Science with Python: With Modularizing, Memory profiles, and Parallel/GPU Processing

Productive and Efficient Data Science with Python: With Modularizing, Memory profiles, and Parallel/GPU Processing

Tirthajyoti Sarkar
Hands-On Automated Machine Learning

Hands-On Automated Machine Learning

Sibanjan Das, Umit Mert Cakmak

Publisher Resources

ISBN: 9781789136609Supplemental Content