Diving Deeper into Machine Learning#
We’ve focused on neural networks, using labeled data that we can use to learn the trends in our data. This is an example of supervised learning.
Broadly speaking there are 3 main approaches to machine learning
-
This uses labeled pairs (input and output) to train the model to learn how to predict the outputs from the inputs.
-
No labeled data is provided. Instead the machine learning algorithm seeks to find the structure on its own. The goal is to learn patterns and features to be able to produce new data.
-
As with unsupervised learning, no labeled data is used, but the model is “rewarded” when it does something right, and the model tries to maximize rewards (think: self-driving cars).
Libraries#
There are a number of popular libraries that implement machine learning algorithms. Their features and performance vary quite a bit. An comparison of their features is provided by Wikipedia: Comparison of deep learning software.
Some additional comparisons are provided here: https://ritza.co/articles/scikit-learn-vs-tensorflow-vs-pytorch-vs-keras/
-
This is an open source machine learning library released by Google. It has support for CPUs, GPUs, and TPUs, and provides all the features you need to build deep learning workflows: TensorFlow feactures.
You can install tensorflow via:
pip install tensorflow
Note
At the moment, tensorflow only supports python <= 3.12. So I’ll be using pytorch instead (since I am running python 3.13).
-
This is a machine learning library build off of the Torch library, originally developed by Facebook.
You can install pytorch via:
pip install torch
-
This is a python library developed for machine learning. It has a lot of sample datasets that provide a nice means to learn how different methods work. It is designed to work with NumPy and SciPy.
General recommendations on the web seem to be to use Scikit-learn to get started with machine learning and to explore ideas, but to switch to one of the other packages for computationally-intensive work.
You can install scikit-learn via:
pip install scikit-learn
Scikit-learn provides some nice sample datasets:
https://scikit-learn.org/stable/datasets/toy_dataset.html
as well as generators for datasets:
https://scikit-learn.org/stable/datasets/sample_generators.html
There are also tools that provide higher-level interfaces to these
-
Keras provides a common python interface to several different machine learning libraries, including tensorflow and torch. This hides a lot of the implementation details and makes it easy to get started using these libraries.
Keras#
We’ll focus on Keras.
There are a large number of examples provided by Keras: