ML - 03 - Machine Learning Systems
ML - 03 - Machine Learning Systems
Chapter 03
Machine Learning Systems
Prepared by: Ziad Doughan
Email: [email protected]
IN ML projects, it is best to
experiment with real world
data, not artificial datasets.
There are thousands of open
datasets to choose from.
Example:
The California Housing Prices
dataset is based on data from
the 1990 California bay area.
The census data looks like a great dataset to exploit for this
purpose, since it includes the median housing prices of
thousands of districts, as well as other data.
With all this information, you are now ready to start designing
your system.
First, you need to frame the problem:
• Is it supervised, unsupervised, or Reinforcement Learning?
• Is it a classification, a regression, or something else?
• Should you use batch or online learning techniques?
It is strongly recommended to
work in an isolated environment.
This allows you to work on
different projects without having
conflicting library versions.
In Python you can create an
isolated environment.
Every time you want to use a
specific environment, all you
must do is activate it.
You framed the problem, you got the data and explored it,
you sampled a training set and a test set, and you wrote
transformation pipelines preprocess the data.
You are now ready to select and train a Machine Learning
model. Let’s first train a Linear Regression model:
>>> from sklearn.linear_model import LinearRegression
>>> lin_reg = LinearRegression()
>>> lin_reg.fit(housing_prepared, housing_labels)
Done! You now have a working Linear Regression model.
You can wrap the model within a web service. This makes it
easier to upgrade your model to new versions without
interrupting the main application.
But deployment is not the end of the story. You also need to
write monitoring code to check the performance and trigger
alerts when it drops.
Even a model trained to classify pictures of cats and dogs may
need to be retrained regularly.
Not because cats and dogs will mutate overnight, but because
cameras keep changing, along with image formats, sharpness,
brightness, and size ratios.
Moreover, people may love different breeds next year, or they
may decide to dress their pets with tiny hats—who knows?