%%html
<!-- The customized css for the slides -->
<link rel="stylesheet" type="text/css" href="../styles/python-programming-introduction.css"/>
<link rel="stylesheet" type="text/css" href="../styles/basic.css"/>

43.11. Machine Learning overview#

43.11.1. Table of Content#

  • What is machine learning?

  • Difference between AI, data science, ML and DL

  • Difference between ML and ordinary programming

  • Key terminology

  • Applications of machine learning

  • Types of machine learning

  • A typical machine learning project workflow

43.11.2. What is Machine Learning#

  • Machine learning is a new programming paradigm in which instead of explicitly programming computers to perform some tasks, we let them learn from data in order to find the underlying patterns in the data

  • In few words, machine learning is the science of giving the machine the ability to reason about the data

43.11.3. What is Machine Learning#

  • The term machine learning was coined by Arthur Samuel in 1959. At that time, Arthur defined machine learning as a:

Field of study that gives computers the ability to learn without being explicitly programmed.

43.11.4. What is Machine Learning#

  • A more technical definition of machine learning was provided by Tom M. Mitchell in 1997. Here is how Tom defined machine learning:

A computer program is said to learn from experience E with respect to some task T and some performance measure P, if its performance on T, as measured by P, improves with experience E.

43.11.5. What is Machine Learning#

  • Wikipedia provides a much clearer definition of machine learning:

Machine learning (ML) is the study of computer algorithms that improve automatically through experience and by the use of data. It is seen as a part of artificial intelligence. Machine learning algorithms build a model based on sample data, known as “training data”, in order to make predictions or decisions without being explicitly programmed to do so. - Wikipedia.

  • In simple words, machine learning algorithms are trained on data rather than being programmed explicitly

43.11.6. Artificial Intelligence, Data Science, Machine Learning, and Deep Learning#

  • AI is a branch of computer science concerned with building intelligent machines capable of performing tasks at the level of human. AI seeks to mimic human. AI is an interdisciplinary field that involves machine learning, programming, robotics, data science, etc…

43.11.7. Artificial Intelligence, Data Science, Machine Learning, and Deep Learning#

  • Machine learning on the other hand is the branch of AI and as we saw, it is concerned with giving the machine the ability to learn from data. Machine learning algorithms consists of shallow or classical algorithms such as decision trees and deep learning algorithms such as convolutional neural networks

43.11.8. Artificial Intelligence, Data Science, Machine Learning, and Deep Learning#

  • Deep learning is a branch of machine learning that deals with the study of artificial neural networks and it was inspired by the human brain. Classical machine learning algorithms needs a lot of feature engineering, but deep learning algorithms can extract features in huge amount of data such as images themselves

43.11.9. Artificial Intelligence, Data Science, Machine Learning, and Deep Learning#

  • The difference between AI, machine learning and deep learning

43.11.10. Ordinary Programming vs Machine Learning#

43.11.10.1. Ordinary Programming#

  • In ordinary programming, the job of the programmer is to clearly write every single rule that makes up the task he/she is trying to accomplish

  • In order to get the results, she/he must write all rules that acts up on the data

43.11.11. Ordinary Programming vs Machine Learning#

43.11.11.1. Machine Learning#

  • Machine learning flips that. Instead of having to write the rules that makes up a particular application, we can feed data and results(or labels) to the machine learning model, and its job can be to determine the set of rules that map the data and labels

43.11.12. Ordinary Programming vs Machine Learning#

  • Traditional Programming vs Deep Learning

43.11.13. Ordinary Programming vs Machine Learning#

  • Let’s take a real world example. If you wanted to build an application that given a picture of person can determine if he/she is wearing or not wearing a facemask, you can just feed a bunch of images of people with and without facemasks to the machine learning model, and the model can learn the rules or patterns that map the images to whether they have a facemask or not

  • You can even extend that further and use those learned rules to recognize facemasks in the images that were never seen by the that model

43.11.14. Ordinary Programming vs Machine Learning#

  • Approaching a facemask recognition problem with rule based programming would really be a hard problem. You would have to write lots of code that would later turn out to not work typically because your program will be tested on different kinds of facemasks and people in various scenarios and it’s almost impossible to express that in rules

  • Whereas with machine learning, all you need is a bunch of images of people with and without facemasks, and there you are few steps away from getting an effective facemask recognizer

43.11.15. Applications of Machine Learning#

  • Machine learning has transformed many industries, from banking, manufacturing, streaming, autonomous vehicles, agriculture, etc…In fact, most of the tech products and services we use daily possess some sorts of machine learning algorithms running in their backgrounds

  • Fraud detection, Loan repayment prediction, Diagnozing diseases and predicting the survival rate, Detecting defects in industry, Churn prediction, Spam detection, Autonomous vehicles, etc.

43.11.16. Key terminology#

43.11.16.1. Labels#

  • A label is the thing we’re predicting—the y variable in simple linear regression. The label could be the future price of wheat, the kind of animal shown in a picture, the meaning of an audio clip, or just about anything.

43.11.17. Key terminology#

43.11.17.1. Features#

  • A feature is an input variable—the x variable in simple linear regression. A simple machine learning project might use a single feature, while a more sophisticated machine learning project could use millions of features, specified as:

\[x_1, x_2, ..., x_N\]

43.11.18. Key terminology#

43.11.18.1. Examples#

  • An example is a particular instance of data, x. (We put x in boldface to indicate that it is a vector.) We break examples into two categories:

    • labeled examples

    • unlabeled examples

43.11.19. Key terminology#

43.11.19.1. Examples#

  • A labeled example includes both feature(s) and the label. That is:

labeled examples: {features, label}: (x, y)
  • Use labeled examples to train the model. In our spam detector example, the labeled examples would be individual emails that users have explicitly marked as “spam” or “not spam.”

43.11.20. Key terminology#

43.11.20.1. Models#

  • A model defines the relationship between features and label. For example, a spam detection model might associate certain features strongly with “spam”. Let’s highlight two phases of a model’s life:

    • Training means creating or learning the model. That is, you show the model labeled examples and enable the model to gradually learn the relationships between features and label.

    • Inference means applying the trained model to unlabeled examples. That is, you use the trained model to make useful predictions (y'). For example, during inference, you can predict if an email is a spam or not for new unlabeled examples.

43.11.21. Types of Machine Learning Systems#

  • In broad, there are 3 main types of machine learning systems that are:

    • Supervised learning

    • Unsupervised learning

    • Reinforcement learning

43.11.22. Types of Machine Learning Systems#

43.11.22.1. Supervised Learning#

  • Most machine learning tasks fall into supervised learning type

  • Trained with input data along with some form of guidance that we can call labels

  • In other words, a supervised learning model maps the input data X to output labels y

  • Labels are also known as targets and they act as a description of the input data.

43.11.23. Types of Machine Learning Systems#

43.11.23.1. Supervised Learning#

  • there are 2 main kinds of supervised learning problems:

    • Classification problems: identify a given category from numerous categories or simply make choice between a number of categories

    • Regression problems: predict a continuous value of something

43.11.24. Types of Machine Learning Systems#

43.11.24.1. Supervised Learning#

43.11.25. Types of Machine Learning Systems#

43.11.25.1. Unsupervised Learning#

  • Unsupervised learning algorithms are trained on unlabelled data

  • Unsupervised learning algorithms are primarily used for:

    • Clustering

    • Dimension reduction and data visualization

43.11.26. Types of Machine Learning Systems#

43.11.26.1. Reinforcement Learning#

  • Mostly applied in robotics and games

  • A learning system called an agent can perceives the environment, performs some actions, and gets rewarded or penalized depending on how it is performing. The main goal of the agent is to accumulate as much as rewards as possible.

  • The agent learns the best strategy(policy) necessary for getting the most reward itself.

43.11.27. Typical Machine Learning Workflow#

  • Overall, a typical machine learning project workflow consists of:

    • Defining and formulating a problem

    • Collecting data

    • Establishing a baseline

    • Exploratory data analysis(EDA)

    • Selecting and training a model

    • Performing error analysis and improving a model

    • Deploying a model

43.11.28. Typical Machine Learning Workflow#

43.11.28.1. Defining and formulating a problem#

  • Understanding the problem is all about diving deep into the details of the problem at hand and asking the right questions

  • First, it’s important to narrow down the problem until you can have a simple and a well-defined goal. Here are examples of simple goals: To classify products into different categories, to predict the price of a used car given its features (such as brand, age, etc…), to recognize if a person is wearing a facemask, to divide customers into different groups that share similar behaviors, etc…

  • As you can see, the goal can tell whether the problem is classification, regression, or clustering…

43.11.29. Typical Machine Learning Workflow#

43.11.29.1. Collecting Data#

  • There are 2 main types of data that are:

    • Structured data that are organized in tabular or spreadsheet format. Example of tabular data includes customer records, car sales, etc…

    • Unstructure data such as images, texts, sounds, and videos. Unstructured data are not organized as the former.

  • There are lots of open-source datasets on platforms like Kaggle, Google datasets, UCL, and government websites

  • There are times that you will have to collect your own data, especially if you are solving a problem that no one solved before

43.11.30. Typical Machine Learning Workflow#

43.11.30.1. Establishing a Baseline#

  • Without a benchmark, you won’t know how to evaluate your results properly

  • The single most purpose of a baseline is to act as a reference point when comparing the actual model with the baseline

  • The ultimate goal is to beat a baseline, and sometime, if you can’t beat it, it might mean the project is not worth pursuing, or the baseline can be all you need

43.11.31. Typical Machine Learning Workflow#

43.11.31.1. Exploratory data analysis(EDA)#

  • Before manipulating the data, it is quite important to learn about the dataset

  • Go through some values, plot some features, and try to understand the correlation between them

  • If the work is vision-related, visualize some images, spot what’s missing in the images

  • Are they diverse enough? What types of image scenarios can you add? Or what are images that can mislead the model?

43.11.32. Typical Machine Learning Workflow#

43.11.32.1. Data Preprocessing#

  • Perhaps the biggest part of any machine learning project

  • Convert the raw data to go in a format that can be accepted by the machine learning algorithms

  • Imputing missing values

  • Encoding categorical features

  • Scaling the numeric features

43.11.33. Typical Machine Learning Workflow#

43.11.33.1. Selecting and Training a Model#

  • Depending on your problem, you can choose different relevant model

  • The scope of the problem

  • The size of the dataset

  • The level of interpretability

  • Training time

43.11.34. Typical Machine Learning Workflow#

43.11.34.1. Performing Error Analysis#

  • Performing error analysis will guide you throughout the process of improving the results of the model

  • The improvement can either be from the data or the model

  • One of the best ways to do error analysis is to plot the learning curve and to try noticing where the model is failing and what might be the reason, and the right actions that you can take to reduce the errors

43.11.35. Typical Machine Learning Workflow#

43.11.35.1. Deploying a Model#

  • Model deployment is the last part in this workflow.

  • When all the previous steps has gone right, and you are happy about the results of the model on the test set, the next step will be to deploy the model so that the users can start to make requests and get predictions or enhanced services

43.11.36. Thank you!#

  • Any questions?