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

Generating logistic regression models


Weka has a class named Logistic, which can be used for building and using a multinomial logistic regression model with a ridge estimator. Although the original logistic regression does not deal with instance weights, the algorithm in Weka has been modified to handle the instance weights.

In this recipe, we will use Weka to generate a logistic regression model on the iris dataset.

How to do it...

  1. We will be generating a logistic regression model from the iris dataset, which can be found in the data directory in the installed folder of Weka.

    Our code will have two instance variables: one will be containing the data instances of the iris dataset, and the other will be the logistic regression classifier:

            Instances iris = null; 
            Logistic logReg ; 
    
  2. We will be using a method to load and read the dataset, as well as to assign its class attribute (the last attribute of the iris.arff file):

            public void loadArff(String arffInput){ &...