Quick Start with Machine Learning in Java

Zoran Sevarac
Zoran Sevarac

Artificial intelligence software developer, entrepreneur, Java Champion, and researcher. Creator of the most popular and award winning educational Java open source neural network software—Neuroph.

So you're a Java developer and you want to do some machine learning. Some of the questions that you might be wondering about are—what can machine learning do for me anyway, which library to use, which algorithms, and is there a common standard API?

Since recently there is a standard API that was created to address exactly these questions. Meet JSR 381, a standard Java API for Visual Recognition using machine learning.

VisRec API was designed to be used for machine learning tasks for Java developers with a minimum background in machine learning and to be intuitive for Java developers getting started with machine learning.

Beside basic visual recognition tasks, such as image classification and object detection, it provides support for common machine learning tasks, such as classification and regression.

Since it is an official Java technology standard, multiple implementations are possible and currently there are two available:

Here is an example of Java code based on the VisRec API to build and use a classifier. Without any explanations, it should be clear to you what is happening:

ImageClassifier<BufferedImage> classifier = 
   .networkArchitecture(new File("mnist.json"))
   .modelFile(new File("mnist.dnet"))

BufferedImage image = ImageIO.read(new File(input.getFile()));
Map<String, Float> results = classifier.classify(image);

For detailed step-by-step instructions and examples, see the getting started guide.


Don’t Forget to Share This Post!

Comments (0)

Your email address will not be published. Required fields are marked *

Related Articles

Subscribe to foojay updates:

Copied to the clipboard