2. MACHINE LEARNING
Machine Learning is great for:
• Problems for which existing solutions require a long lists of rules: ML algorithm can simplify code & perform better.
• Complex problems for which there is no good solution at all using a traditional approach
• Fluctuating environments: a Machine Learning system can adapt to new data.
• Getting insights about complex problems and large amounts of data.
Machine Learning is the field of study that gives computers the ability to learn
without being explicitly programmed.
—Arthur Samuel, 1959
3. In supervised
learning, the training
data you feed to the
algorithm includes
the desired solutions,
called labels. Typical
supervised learning
task are Regression &
Classification
Classification task
Regression task
(Classify email into spam/
not spam). Algorithm:
Decision Tree, etc
(Predict a target numeric
value, such as the price of a
car). Algorithm: Linear
Regression, etc
TYPE OF MACHINE LEARNING
In unsupervised learning,
the training data is
unlabeled. The system tries
to learn without a teacher.
Ex1: run a clustering
algorithm to try to detect
groups of similar visitors in
your blog. Ex2: detecting
unusual credit card
transactions to prevent
fraud (anomaly detection)
Some task & algorithm
• Clustering (k-Means)
• Visualization &
dimensionality
reduction (Principal
Component Analysis
(PCA))
• Association rule
learning (Apriori,
Eclat)
Supervised Learning
Unsupervised Learning
6. Rewriting the
whole code in the
language that the
software
engineering folks
work.
OPTIONS TO DEPLOY ML MODEL
API-first approach
which has made it
easy for cross-
language applications
to work well & need
only the URL Endpoint
from where the API is
being served.
7. WHAT IS API?
When people speak of “an API”, they sometimes
generalize and actually mean “a publicly available
web-based API that returns data, likely in JSON or
XML”. The API is not the database or even the
server, it is the code that governs the access
point(s) for the server.
In basic terms, Application Programming
Interface (API) just allow applications to
communicate with one another.
8. CREATE MACHINE LEARNING
API USING FLASK,
A WEB FRAMEWORK IN PYTHON
Flask isn’t the only web-framework
available. There is Django, Falcon, Hug
and many more. For R, we have a
package called plumber.
9. STEP BY STEP
Python
Environment
Setup & Flask
Creating a ML
Model
Saving Model
(Serialization)
Creating a virtual
environment using
Anaconda
Using Flask, we
can wrap our
Machine Learning
models and serve
them as Web APIs
easily
Create a pipeline
to make sure that
all the pre-
processing steps
are just a single
sklearn estimator.
In Python, pickling is
a standard way to
store objects and
retrieve them as their
original state. Other
alternative is h5py
10. STEP BY STEP
Creating an API
using Flask
Test the API
using Postman
Coding example can be
learn here:
https://github.com/prato
s/flask_api/tree/master/
notebooks
(Owned by
analyticsvidhya.com)
Getting the request
data (for which
predictions are to be
made)
Loading our pickled
estimator
jsonify our predictions
and send the
response back
with status code: 200
Change the method
to POST
Copy and paste the
endpoint into URL
section
Inside the Body tab
choose JSON
Enter some JSON for
prediction
Hit Send and it will
show the prediction
1.
2.
3.
4.
5.
11. Hands-On Machine Learning with
Scikit-Learn and TensorFlow: Concepts,
Tools, and Techniques to Build
Intelligent Systems by Aurélien Géron
SOURCES
https://www.analyticsvidhya.com/blog/
2017/09/machine-learning-models-as-
apis-using-flask/
https://towardsdatascience.com/deploy
ment-of-machine-learning-model-
demystified-part-1-1181d91815d2
https://medium.com/@opeyemibami/de
ployment-of-machine-learning-models-
demystified-part-2-63eadaca1571