programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Tim Cooke
• Campbell Ritchie
• Paul Clapham
• Ron McLeod
• Liutauras Vilda
Sheriffs:
• Jeanne Boyarsky
• Rob Spoor
• Bear Bibeault
Saloon Keepers:
• Jesse Silverman
• Tim Moores
• Stephan van Hulst
• Tim Holloway
• Carey Brown
Bartenders:
• Piet Souris
• Al Hobbs
• salvin francis

# Java for machine learning?

Ranch Hand
Posts: 73
1
• Number of slices to send:
Optional 'thank-you' note:
I want to get into machine learning.
However, the field currently seems to prefer Python.
While I would very much like to learn a new language, I have to learn so much stuff for work and my other hobbies, that I really prefer to use Java (which I *kinda* know...).

From what I see, there's nothing particularly special about python for ML, only that there are lots of libraries and worked-out examples...
I bet Java might even do better performance!

Question is, is it feasible for me to start a small ML project with Java or it's a dead-end road?

In particular, my half-study-half-useful project is about an approximation pathfinder for mental unit conversion ("APMUC").

For example, KG to Lbs:
KG x 2 + 10% (I found this myself, with pen and paper)
This is two (three actually) steps of simple mental arithmetic and yields a pretty useful result (-0.21% accuracy)

Rules:
1. Approximation should not yield results over a certain accuracy
2. Number of steps in the "found" path may not exceed the required number of steps
3. Only addition, subtraction, multiplication and division allowed (% also allowed)
4. Multiplication only by "easy" factors: 2, 3, 4, 5, 10
5. Division only by "easy divisors": 2, 10
6. Only "easy" percentages like: 1%, 10%...

Input:
Expected accuracy in absolute %
Exact factor (2.20462, in the above example)
Number of steps (should be 1-4, if we want to keep things memorable)

Process:
The ML will try to mix and match the rules to find any paths that cover the accuracy and step-number requriements

Output: a table of formulas (like: "<startingNumber> X 2 + 10%-of<startingNumber>"), with the "stepCount" and "accuracy" for each, for the user to pick the best approximation and use in daily life

I know there are various ML approaches to solving this but I guess anything that works will be fine.
Do you reckon I am likely to find the supporting libraries in Java or "the AI/ML train" has left the "java station"?

(yes, I know I can probably brute force this without ML, but I want to use this project to access ML knowledge a little bit, please!)

Saloon Keeper
Posts: 7174
166
• 1
• Number of slices to send:
Optional 'thank-you' note:
While not as widely used as Python, I think Java is quite a player in the ML area. Check out these libraries:

https://blogs.oracle.com/java/announcing-tribuo%2c-a-java-machine-learning-library

https://deeplearning4j.org/

https://www.infoq.com/articles/java-machine-learning-djl/

Saloon Keeper
Posts: 24557
168
• Number of slices to send:
Optional 'thank-you' note:
I think Java actually has an older claim to ML than Python, actually. Python's recent dominance in that area comes down to two factors, I think:

1. Python has become popular as a scientific programming language. Historically that was Fortran, but Python offers much the same simplicity as Fortran with a lot more power. Scientists don't generally need Object-Oriented programming or complex projects daring from a wide set of general-purpose libraries, so Python is an easier inroad with generally faster code-to-output times.

2. A lot of ML is associated with the Internet of Things (IoT) and one of the things that has emerged from IoT is Edge Computing. Why, for example, should you waste server resources monitoring and analyzing cameras to see if Bob's at the door when for \$10, a Raspberry Pi Zero can do most of the work? Or even simpler devices in some cases - I paid about \$20 for a postage-stamp sized circuit board with TensorFlow LIght built in (plus 2 microphones, a camera interface and a partridge in a pear tree).

Java works OK on the Raspberry Pi, but it wasn't quite fast enough to run my CNC machine, for example. Python has become my primary language for the Pi.

On the other hand, not all ML is IoT-related. When you want to do real-time market analysis for example, you're going to be hooking into enterprise-grade services. And Java is definitely what I'd be considering there.

 You showed up just in time for the waffles! And this tiny ad: Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton