You are on page 1of 20

101 Machine Learning

Jupyterhub + MNIST

Confidential │ © VMware, Inc.


Engineer at the Content team since 2018

Create and Maintain assets for the Bitnami


Application Catalog

Passionate about Kubernetes and 3D


Rafael Rios Saavedra Graphics (and 3D printing, electronics, retrogames…. :) )
Software Engineer @ VMware

rrios@vmware.com

Confidential │ © VMware, Inc. 2


AI / Machine Learning / Deep Learning
What is this ?

Artificial Intelligence (AI): the ability of a digital computer or


computer-controlled robot to perform tasks commonly associated
with intelligent beings.

Machine Learning (ML): Method of data analysis that automates


analytical model building. Using algorithms that “learn” iteratively
from data. Allows computer to find hidden insights with being
explicitly programmed where to look.

Deep Learning (DL): is part of a broader family of machine


learning methods, which is based on artificial neural networks with
representation learning. The adjective "deep" in deep learning
refers to the use of multiple layers in the network. Methods used
can be either supervised, semi-supervised or unsupervised

Confidential │ © VMware, Inc. 3


AI / Machine Learning / Deep Learning
ML Algorithms

Instance-based Algorithms: These algorithms learn from individual training examples. They store the training data
and classify new instances based on the similarity to the stored instances. Examples of instance-based algorithms
include k-Nearest Neighbors (k-NN), Learning Vector Quantization (LVQ), and Radial Basis Functions (RBF)

Bayesian Algorithms: These algorithms apply Bayes' Theorem for problems such as classification and regression.
They are probabilistic models that are used to predict the probability of an event. Examples of Bayesian algorithms
include Naive Bayes and Bayesian Networks

Ensemble Algorithms: These algorithms combine multiple weaker models to make a final decision. They are used
to improve the predictive accuracy and control overfitting. Examples of ensemble algorithms include Bagging,
Boosting, and Random Forests

Confidential │ © VMware, Inc. 4


AI / Machine Learning / Deep Learning
ML Algorithms

Decomposition Algorithms: These algorithms decompose the data into different components and use these
components to make predictions. Examples include Principal Component Analysis (PCA) and Factor Analysis
Regression Algorithms: These algorithms are used for predicting continuous outcomes. Examples include Linear
Regression, Logistic Regression, and Support Vector Regression

Decision Tree Algorithms: These algorithms are used for both classification and regression tasks. They split the
data into subsets based on the values of the input variables. Examples include Classification and Regression Trees
(CART), Decision Stump, and Iterative Dichotomiser 3 (ID3)

Clustering Algorithms: These algorithms are used for unsupervised learning tasks where the goal is to group
instances into clusters. Examples include K-Means, Hierarchical Clustering, and DBSCAN

Confidential │ © VMware, Inc. 5


AI / Machine Learning / Deep Learning
Deep Learning

Try to simulate how our neurons work

The perceptron was invented in 1943 by Warren McCulloch and


Walter Pitts.

In 1969, Marvin Minsky and Seymour Papert published


“Perceptrons” and showed that it was impossible for these classes
of network to learn an XOR function

Started what is called the “AI winter”. Research continued later at


the end of the 80s.
Confidential │ © VMware, Inc. 6
AI / Machine Learning / Deep Learning
Deep Learning

Confidential │ © VMware, Inc. 7


AI / Machine Learning / Deep Learning
Deep Learning - key concepts

Forward Propagation: Calculation and storage of intermediate


variables for a neural network. Occurs in order from the input
layer to the output layer of the network

Loss (cost) function: Loss function is a method that quantifies


how well a model is performing. It measures the discrepancy
between the model's predictions and the actual values. e.g.
Mean Squared Error (MSE)

Confidential │ © VMware, Inc. 8


AI / Machine Learning / Deep Learning
Deep Learning - key concepts

Back propagation: Algorithm used to get the new model’s


weights in such way that it reduces the loss function.

Gradient descent: The goal of gradient descent is to minimize


the loss function, which measures the error between the actual
and predicted outputs. It does this by iteratively adjusting the
weights or parameters of the model in the direction of the
negative gradient of the cost function until the minimum of the
cost function is reached

Confidential │ © VMware, Inc. 9


AI / Machine Learning / Deep Learning
Deep Learning - Key concepts

Good Model Overfitting Underfitting

Confidential │ © VMware, Inc. 10


AI / Machine Learning / Deep Learning
Deep Learning

Confidential │ © VMware, Inc. 11


AI / Machine Learning / Deep Learning
Deep Learning - Key concepts
Supervised Learning: Use labeled data sets in order to train
algorithms. By labeling outputs and matching inputs to
corresponding outputs fed into the algorithm, machine learning
models are able to weigh accuracy and improve with additional
data repetition over time.

Unsupervised Learning: Does not make use of labeled data sets,


meaning the models work on their own to uncover the inherent
structure of the unlabeled data. Typically used to uncover insights
from massive volumes of data, detect anomalies or make
recommendations and may have inaccurate results without human
validation.

Confidential │ © VMware, Inc. 12


AI / Machine Learning / Deep Learning
Deep Learning - Key concepts
Supervised Learning: Use labeled data sets in order to train
algorithms. By labeling outputs and matching inputs to
corresponding outputs fed into the algorithm, machine learning
models are able to weigh accuracy and improve with additional
data repetition over time.

Unsupervised Learning: Does not make use of labeled data sets,


meaning the models work on their own to uncover the inherent
structure of the unlabeled data. Typically used to uncover insights
from massive volumes of data, detect anomalies or make
recommendations and may have inaccurate results without human
validation.

Confidential │ © VMware, Inc. 13


AI / Machine Learning / Deep Learning
Deep Learning - MNIST (Hello world example)

MNIST (Modified National Institute of Standards and


Technology): Is a large (60000) database of
handwritten digits that is commonly used for training
various image processing systems.

28x28 pixels in 8 bits gray scale

Confidential │ © VMware, Inc. 14


Jupyterhub

Jupyter Notebook is an open-source web application that


allows you to create and share documents that contain live
code, equations, visualizations, and narrative text. It's designed
to be used in a web browser and provides an interactive
programming environment that allows you to work with data in
a more visual and dynamic way.

The notebook consists of cells, which can contain code, text, or


output. You can run the code in a cell, and the output will be
displayed right below it.

Confidential │ © VMware, Inc. 15


Jupyterhub
Architecture

Confidential │ © VMware, Inc. 16


Demo Time

Confidential │ © VMware, Inc. 17


Demo Time
Minikube start - Install jupyterhub
Start Minikube give extra resources Enable metallb (load balancer external cluster IPs)
$ minikube start --cpus=4 --memory=4G $ minikube ip
192.168.49.2
😄 minikube v1.31.2 on Ubuntu 23.04
✨ Automatically selected the docker driver. Other choices: kvm2,
qemu2, virtualbox, ssh $ minikube addons enable metallb
📌 Using Docker driver with root privileges ❗ metallb is a 3rd party addon and is not maintained
👍 Starting control plane node minikube in cluster minikube or verified by minikube maintainers, enable at your own
🚜 Pulling base image ... risk.
🔥 Creating docker container (CPUs=4, Memory=4096MB) ... ❗ metallb does not currently have an associated
🐳 Preparing Kubernetes v1.28.2 on Docker 24.0.6 ... maintainer.
▪ Generating certificates and keys ... ▪ Using image quay.io/metallb/speaker:v0.9.6
▪ Booting up control plane ... ▪ Using image quay.io/metallb/controller:v0.9.6
▪ Configuring RBAC rules ... 🌟 The 'metallb' addon is enabled
🔗 Configuring bridge CNI (Container Networking Interface) ...
▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🔎 Verifying Kubernetes components... $ minikube addons configure metallb
🌟 Enabled addons: storage-provisioner, default-storageclass -- Enter Load Balancer Start IP: 192.168.49.100
🏄 Done! kubectl is now configured to use "minikube" cluster and -- Enter Load Balancer End IP: 192.168.49.150
"default" namespace by default ▪ Using image quay.io/metallb/speaker:v0.9.6
▪ Using image quay.io/metallb/controller:v0.9.6
✅ metallb was successfully configured

Confidential │ © VMware, Inc. 18


Demo Time
EXTRA - GPU support in minikube
● Install minikube beta from a unlinked repository (but official link)
● Run minikube enabling GPU
$ wget https://storage.googleapis.com/minikube-builds/17314/minikube-linux-amd64

$ minikube start --cpus=4 --memory=4G --gpus all


minikube v1.31.2 on Ubuntu 23.04
✨ Automatically selected the docker driver. Other choices: kvm2, qemu2, virtualbox, ssh
Using Docker driver with root privileges
Starting control plane node minikube in cluster minikube
Pulling base image ...
Creating docker container (CPUs=4, Memory=4096MB) ...
❗ Using GPUs with the Docker driver is experimental, if you experience any issues please
report them at: https://github.com/kubernetes/minikube/issues/
new/choose
Installing the NVIDIA Container Toolkit...
Preparing Kubernetes v1.28.2 on Docker 24.0.6 ...
▪ Generating certificates and keys ...
▪ Booting up control plane ...
WARNING ! ▪ Configuring RBAC rules ...
Here will be dragons Configuring bridge CNI (Container Networking Interface) ...
▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
▪ Using image nvcr.io/nvidia/k8s-device-plugin:v0.14.1
Verifying Kubernetes components...
Enabled addons: storage-provisioner, nvidia-device-plugin, default-storageclass
Done! kubectl is now configured to use "minikube" cluster and "default" namespace by
default
Confidential │ © VMware, Inc. 19
Links
AI winter: https://en.wikipedia.org/wiki/AI_winter
AI / ML / DL: https://www.britannica.com/technology/artificial-intelligence/Alan-Turing-and-the-beginning-of-AI
ML Algorithms: https://machinelearningmastery.com/a-tour-of-machine-learning-algorithms/
Jupyter books hierarchy: https://jupyter-docker-stacks.readthedocs.io/en/latest/using/selecting.html
Minikube + nvidia: https://minikube.sigs.k8s.io/docs/tutorials/nvidia/
Minikube beta: https://storage.googleapis.com/minikube-builds/17314/minikube-linux-amd64
Minikube gpu restart issue: https://github.com/kubernetes/minikube/issues/17405
3Blue1Brown Deep Learning: https://youtu.be/aircAruvnKk?si=6YVdWp7RD627tl6J
MNIST Fashion: https://www.tensorflow.org/tutorials/keras/classification
Article: https://medium.com/geekculture/deep-learning-a-to-z-part-1-1d5bd4e9944c
Article: https://medium.com/geekculture/deep-learning-a-to-z-part-2-mnist-the-hello-world-of-neural-networks-2429c4367086

Confidential │ © VMware, Inc. 20

You might also like