This week's book giveaway is in the Beginning Java forum.
We're giving away four copies of Get Programming with Java (MEAP only) and have Peggy Fisher on-line!
See this thread for details.
Win a copy of Get Programming with Java (MEAP only) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Java or Python Better for Machine Learning?  RSS feed

 
Ranch Hand
Posts: 1616
13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As a long-time Java developer (and dreading having to learn yet another language), my client is convinced that Python has the better, more complete, libraries for machine learning.

Browsing Amazon, he seems to be correct as the Python machine learning books vastly outnumber the Java books. And, the Java books (mostly by Packt) don't let you really see what's in them (on the Amazon site) making it difficult to judge them.

My goal is to stick with Java, if possible, but I need a good Java ML Library that can do things like:

Support Vector Machines
Discriminant Analysis
Logistic Regression
and related.

To date, I cannot find a hands-on book, with a corresponding (approachable) library (or book) for Java that shows you step by step how to load data, train data, predict, etc..

There is a Java library called WEKA, but it's extremely complex and it doesn't handle things like box's M test so I'd have to code that externally somehow.

So, just wondering if anyone here is into ML and if you've found a good Java (or Python) library and would be willing to share your thoughts?

Is Python the better way to go due to existing libraries?

Thanks in advance,

- mike
 
Ranch Foreman
Posts: 1066
24
IBM DB2 Java Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's an interesting question, Mike. Recently I wanted to refresh my knowledge on AI and machine learning, topics I left behind other interests after my CS degree - achieved quite a few years ago, with a thesis on genetic algorithms. I rember that, at the time, C++ and C were widely adopted and a "must" to learn for anyone willing to work in AI / Machine learning - at least at the University I attended to. I was quite surprised that nowadays Python seems to be the new King of the Hill.
Honestly, I think that my surprise is amiss, and a clear symptom of a worse pathology - the habit of thinking exclusively in Java.
Python rules for a number of reasons: the very first that comes to my mind is the simplicity in dealing with vector, matrices, tensors and, generally speaking, with all maths artifacts via numpy library.
As Java is my everyday programming language, I made  a search similar as yours, but at the very end I realized that learning Python would have been a more useful approach.
Nevertheless, besides Weka library (I used it for my thesis, and found it very complete), let me suggest you DeepLearning4J. It's a wide library focused on deep learning - neural nets, in a nutshell.

All the best for your work and study.
 
Ranch Hand
Posts: 151
3
C++ Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that google and amazon both have an api for ai, but your program would have to connect to their server at runtime in order to use it. I didn't look into it beyond that because I have seen how in the past they allow free access to an api then shut it off to everyone until you pay a subscription fee, such as googles translate api. Also there's the question of them having access to your data... stealing your research is part of why it's "free". If there are any good self contained apis for AI in any language I would love to look into it.
 
S Fox
Ranch Hand
Posts: 151
3
C++ Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
forgot to say, facebook also has an api.
 
Mike London
Ranch Hand
Posts: 1616
13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

S Fox wrote:I think that google and amazon both have an api for ai, but your program would have to connect to their server at runtime in order to use it. I didn't look into it beyond that because I have seen how in the past they allow free access to an api then shut it off to everyone until you pay a subscription fee, such as googles translate api. Also there's the question of them having access to your data... stealing your research is part of why it's "free". If there are any good self contained apis for AI in any language I would love to look into it.



Very good info, thanks!

We had looked at WEKA but found it mostly unapproachable. To really use it, you need to dive in and learn the vast API. For simple things it might be OK, but I'm now finding that Python with Pandas and other libraries is much better and support is widely available (as opposed to the odd email-only list WEKA has). Python also excels with statistics.

Having been a Java dev for more than 15 years, I was dumbfounded that Java lacked these libraries.

The challenge I have learning ML is that all the Python books seem to use this (IMHO) weird Jupiter Notebook format. That format is OK for explaining something, but it's often difficult (I have given up more than once) to try to see where they populated X_train and y_train or to follow along typing in code. Other training courses like Coursera use the same notebook format making their courses also very difficult to follow along with (where are all the source code 'py' files for us IDE types?).

Although I realize I'm not really "late to the party" with ML, I do feel like a fish out of water.

Python itself is nice, but there are strange (to me) things like the zip command to combine tuples, and Python's ideas about "encapsulation" (not any, really).

Other concepts like Lambdas seem much simpler in Python than Java. No need to learn all the Consumer and other interfaces and how to apply them just to use a Lambda.

Sorry for the rambling. I really appreciate your posting.

- mike
 
Mike London
Ranch Hand
Posts: 1616
13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

S Fox wrote:I think that google and amazon both have an api for ai, but your program would have to connect to their server at runtime in order to use it. I didn't look into it beyond that because I have seen how in the past they allow free access to an api then shut it off to everyone until you pay a subscription fee, such as googles translate api. Also there's the question of them having access to your data... stealing your research is part of why it's "free". If there are any good self contained apis for AI in any language I would love to look into it.



Don't like those subscription models at all.

Pretty soon, I'll have to rent the fonts for every forum message like this one.

Appreciate your reply.

- mike
 
Mike London
Ranch Hand
Posts: 1616
13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

S Fox wrote:forgot to say, facebook also has an api.



I am very happy to say I've never used Facebook and never plan to.

- mike
 
S Fox
Ranch Hand
Posts: 151
3
C++ Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have rarely used python. I never use facebook either, I used to work for a similar company though, know full well what happens in there! Things nobody would suspect, shady stuff.

Don't laugh off facebook though, they're doing serious R&D now. They hired a former darpa chief to manage their projects. They aren't just doing AI, they are also attempting to create a mind-reading aparatus. They want to wirelessly steal your thoughts and sell them to marketers and various other agencies! It will be a great addition to their occulus rift VR headset which they also develop, how else can you persuade someone to wear a thing so invasive to privacy.
Heres the website, some of their code is on github: Facebook AI Research

I think AI will really go to the next level with quantum computing, intel is working on advancing that right now. They even will give free access for you to play with their quantum computers remotely just sign up on their website. Microsoft is creating a new language for quantum computing which should be ready by next year, thats when quantum will become less of a toy and more of a real world thing. If you want to simulate a quantum computer at home its possible, but takes an incredible amount of ram.

Intel is developing a coprocessor for AI which is supposed to compete with nvidia, supposedly it's going to be faster... and nvidia just the other day came out with a new product which lowers the price for entry level ML hardware, a cheaper version of volta. Titan V
 
S Fox
Ranch Hand
Posts: 151
3
C++ Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The very day after I wrote this, MS released the new language and named it Q#
https://techcrunch.com/2017/12/11/microsoft-releases-quantum-computing-development-kit-preview/
 
Greenhorn
Posts: 22
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My 2cents on this conversation is that at first I felt R and Python were really the two strong choices for ML, but recently Python has essentially dominated the space.  If you want to do cutting edge Machine Learning and Deep Learning, there is a very strong chance you will need to use Python.  The good news if you are more familiar with Java is that Python is a very easy language, especially if you ignore 80% of it and stick with only the parts associated with your tasks.

Also, a decent approach if you are "cloud-native" is to write the parts you must in Python, and then use Java with, say AWS Lambda, then you get the best of both worlds.
 
Bartender
Posts: 20146
103
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A surprise platform for AI has been the Raspberry Pi. It's especially popular for image recognition, thanks to the fact that a Pi plus a camera together retail for about $65USD. There's good Python support for image processing using the Pi's builtin GPU.

Java, alas, has proven to be a bit much for this inexpensive platform. I was using a Java-based gcode program to drive my CNC machine and had to abandon it because it wasn't keeping up with the hardware. The application I use (bCNC) instead is Python-based.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The time consumed is less when compared to languages like C, C++ or Java. As a result, developers can spend more time on their algorithms and heuristics related to AI and ML. ... On the other hand, Java was mostly built for general programming, not number crunching, a field where Python are more preferred.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Mike London wrote:As a long-time Java developer (and dreading having to learn yet another language), my client is convinced that Python has the better, more complete, libraries for machine learning.

Browsing Amazon, he seems to be correct as the Python machine learning books vastly outnumber the Java books. And, the Java books (mostly by Packt) don't let you really see what's in them (on the Amazon site) making it difficult to judge them.

My goal is to stick with Java, if possible, but I need a good Java ML Library that can do things like:

Support Vector Machines
Discriminant Analysis
Logistic Regression
and related.

To date, I cannot find a hands-on book, with a corresponding (approachable) library (or book) for Java that shows you step by step how to load data, train data, predict, etc..

There is a Java library called WEKA, but it's extremely complex and it doesn't handle things like box's M test so I'd have to code that externally somehow.

So, just wondering if anyone here is into ML and if you've found a good Java (or Python) library and would be willing to share your thoughts?

Is Python the better way to go due to existing libraries?

Thanks in advance,

- mike



Java is a good language for Machine Language.

It is modern, powerful and has many libraries/packages that you can your (such as Weka). There are also books on the subject using Java as example, such as Machine Learning in Java by Bostjan Kaluza.

 
Without subsidies, chem-ag food costs four times more than organic. Or this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!