Java for AI and ML
© Ioannis Kostaras
Introduction
When someone wants to learn Artificial Intelligence (AI) and Machine Learning (ML), there is one mainstream language taught everywhere, Python (and maybe R). However, other languages also offer significant libraries for AI/ML development. In this series of articles we will see what Java offers and compare it to Python.
Some Definitions
- Machine learning (ML) is the field of study that gives computers the ability to learn without being explicitly programmed.
- E.g. a model / algorithm that allows, from an image, to recognize/predict if there is a stop sign in it.
- Artificial Intelligence (AI): once we are able to recognize a stop signal, it will be necessary to make the decision to stop or not, when to do it, how to do it, etc.
- Data Science: before building out our model / algorithm, we will have to understand the data we have to train it. Once trained, we will have to be able to evaluate the obtained results and detect in the data any anomaly that may affect model performance.
Java vs Python for AI/ML
Typical Use Case / Notes | Python Library | Java Equivalent(s) |
---|---|---|
Numerical computations, matrix operations | NumPy | ND4J, Apache Commons Math |
Data manipulation and analysis | Pandas | Tablesaw, Apache Arrow, dflib |
Classical machine learning algorithms | scikit-learn, SciPy | Smile, Weka, Tribuo, Deeplearning4j, JavaML |
Deep learning, neural networks | TensorFlow, PyTorch, Keras | TensorFlow Java API, Deeplearning4j, DJL, Tribuo, DeepNets |
Data visualization/charting | Matplotlib/Seaborn | JFreeChart, XChart, Fair-acc/Charts-FX |
Natural language processing | NLTK/spaCy | Apache OpenNLP, Stanford NLP, Mallet |
Documentation | Jupyter | Java plugins for Jupyter: IJava/JJava (more info), JTaccuino; a JavaFX standalone solution |