Book Image

Java Data Analysis

By : John R. Hubbard
Book Image

Java Data Analysis

By: John R. Hubbard

Overview of this book

Data analysis is a process of inspecting, cleansing, transforming, and modeling data with the aim of discovering useful information. Java is one of the most popular languages to perform your data analysis tasks. This book will help you learn the tools and techniques in Java to conduct data analysis without any hassle. After getting a quick overview of what data science is and the steps involved in the process, you’ll learn the statistical data analysis techniques and implement them using the popular Java APIs and libraries. Through practical examples, you will also learn the machine learning concepts such as classification and regression. In the process, you’ll familiarize yourself with tools such as Rapidminer and WEKA and see how these Java-based tools can be used effectively for analysis. You will also learn how to analyze text and other types of multimedia. Learn to work with relational, NoSQL, and time-series data. This book will also show you how you can utilize different Java-based libraries to create insightful and easy to understand plots and graphs. By the end of this book, you will have a solid understanding of the various data analysis techniques, and how to implement them using Java.
Table of Contents (20 chapters)
Java Data Analysis
Credits
About the Author
About the Reviewers
www.PacktPub.com
Customer Feedback
Preface
Index

NetBeans


NetBeans is the IDE that we have used throughout this book. As mentioned in Chapter 1, Introduction to Data Analysis, it is comparable to the other popular IDEs, such as Eclipse, JDeveloper, and JCreator, and it functions mostly the same way.

Download NetBeans from https://netbeans.org/downloads/. Select your language, your OS platform, and one of the Download buttons. Unless your machine is short of storage space, you might as well select the All (right most Download button) version. It includes the Java Enterprise Edition (Java EE) along with support for HTML5 and C++.

The installation is straightforward: just follow the directions. Note that NetBeans includes Java, so you do not have to install Java separately.

The main window for NetBeans is shown in Figure A-8:

Figure A-8. The NetBeans IDE

It shows five main panels: Projects, Files, Services, Output, and the editing window. The Projects, Files, and Services panels are combined in the sub-window on the left. This configuration can easily be rearranged.

NetBeans wants you to compartmentalize all your Java work within the context of NetBeans projects. Although it may seem like an unnecessary extra step, it makes it much easier in the long run to keep track of all your work.

To create a project, just click on the New Project button () on the toolbar (or select New Project… from the File menu). Then, in the New Project dialogue, select Java | Java Application, choose your Project Name, Project Location, and Main Class (for example, AppendixA, nbp/, and dawj.appA.Echo), and click Finish. Note that the Main Class name includes a package specification (dawj.appA).

After pasting in our Echo program, the setup looks like Figure A-9:

Figure A-9. The Echo program in NetBeans

We've added a header ID comment and moved some things around a bit. But it's the same program that we ran before on the command line.

Notice the project organization depicted graphically in the Projects tab and the logical structure of the Echo class shown in the Navigator tab (lower left). Also note the varied iconography: the golden coffee cup for a NetBeans project, the tan bundle cube for the package folder, the icon with the tiny green triangle indicating an executable (main) class, and the orange disk with a vertical bar indicating a static method. These clues can be quite helpful when the project grows to include many classes and methods.

To run the program, click on the green triangle button () on the Toolbar (or press the F6 key, or select Run Project from the Run menu).

Note

Note that selecting the button will run the project. If your project has more than one class with a main() method, it will have designated one of them as its main class and will run that one. To run a program that is not so designated, select Run File from the Run menu, or press Shift+F6. To re-designate the main class for a project, right-click on the project's icon, and select Properties | Run.

Notice that this Echo program gets all its input from the command line. Without that input, it will produce no output. To provide command line arguments, right-click on the project's icon in the Projects panel, select Properties | Run, and then insert them in the Arguments: field, just as you would on the command line (without any punctuation). See Figure A-10.

Figure A-10. The NetBeans project properties Run dialogue

Then, when you run it, you will get the expected output.

The NetBeans editor is very powerful. It uses different colors to distinguish reserved words (blue), class fields (green), and strings (orange) from other code. Syntax errors are caught immediately and marked with red tags. Recommendations are provided for correcting most errors. If you use a class, the IDE will give you a list of import statements from which to choose. If you right-click on a class or class member (field or method) name, you can select Show Javadoc from the pop-up menu and it will appear in your browser. You can select any part of your code and have it properly formatted with Ctrl+Shift+F (or right-click and choose Format).

The built-in debugger is also very powerful and very easy to use.

NetBeans comes with its own relational database system, which is illustrated in Chapter 5, Relational Databases.

NetBeans is excellent for developing Java software. It is also supports C, C++, Fortran, HTML5, PHP, JSP, SQL, JavaScript, JSON, and XML.