Book Image

Java Data Science Cookbook

By : Rushdi Shams
Book Image

Java Data Science Cookbook

By: Rushdi Shams

Overview of this book

If you are looking to build data science models that are good for production, Java has come to the rescue. With the aid of strong libraries such as MLlib, Weka, DL4j, and more, you can efficiently perform all the data science tasks you need to. This unique book provides modern recipes to solve your common and not-so-common data science-related problems. We start with recipes to help you obtain, clean, index, and search data. Then you will learn a variety of techniques to analyze, learn from, and retrieve information from data. You will also understand how to handle big data, learn deeply from data, and visualize data. Finally, you will work through unique recipes that solve your problems while taking data science to production, writing distributed data science applications, and much more - things that will come in handy at work.
Table of Contents (16 chapters)
Java Data Science Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Creating a Deep Belief neural net using Deep Learning for Java (DL4j)


A deep-belief network can be defined as a stack of restricted Boltzmann machines where each RBM layer communicates with both the previous and subsequent layers. In this recipe, we will see how we can create such a network. For simplicity's sake, in this recipe, we have limited ourselves to a single hidden layer for our neural nets. So the net we develop in this recipe is not strictly speaking a deep belief neural net, but the readers are encouraged to add more hidden layers.

How to do it...

  1. Create a class named DBNIrisExample:

            public class DBNIrisExample { 
    
  2. Create a logger for the class to log messages:

            private static Logger log = 
              LoggerFactory.getLogger(DBNIrisExample.class); 
     
    
  3. Start writing your main method:

            public static void main(String[] args) throws Exception { 
    
  4. First, customize two parameters of the Nd4j class: the maximum number of slices to print and the...