Topic 2
Topic 2
LEARNING ALGORITHMS
TRIZA ABUYA
TOPIC 2
Now you may wonder, how is it different from traditional programming? Well, in traditional
programming, we would feed the input data and a well written and tested program into a
machine to generate output. When it comes to machine learning, input data along with the output
is fed into the machine during the learning phase, and it works out a program for itself. To
understand this better, refer to the illustration below:
INTRODUCTION TO ML
TRIZA KWAMBOKA ABUYA
With the help of Machine Learning, businesses can automate routine tasks. It also helps in
automating and quickly create models for data analysis. Various industries depend on vast
quantities of data to optimize their operations and make intelligent decisions. Machine Learning
helps in creating models that can process and analyze large amounts of complex data to deliver
accurate results. These models are precise and scalable and function with less turnaround time.
By building such precise Machine Learning models, businesses can leverage profitable
opportunities and avoid unknown risks.
Image recognition, text generation, and many other use-cases are finding applications in the real
world. This is increasing the scope for machine learning experts to shine as a sought after
professionals.
It is mandatory to learn a programming language, preferably Python, along with the required
analytical and mathematical knowledge. Here are the three mathematical areas that you need to
brush up before jumping into solving Machine Learning problems:
INTRODUCTION TO ML
TRIZA KWAMBOKA ABUYA
1. Linear algebra for data analysis: Scalars, Vectors, Matrices, and Tensors
2. Mathematical Analysis: Derivatives and Gradients
3. Probability theory and statistics
4. Multivariate Calculus
5. Algorithms and Complex Optimizations
Let us build on the beer and wine example to understand how machine learning works. A
machine learning model here has to predict if a drink is a beer or wine. The parameters selected
are the colour of the drink and the alcohol percentage. The first step is:
This involves taking a sample data set of several drinks for which the colour and alcohol
percentage is specified. Now, we have to define the description of each classification, that is
wine and beer, in terms of the value of parameters for each type. The model can use the
description to decide if a new drink is a wine or beer.
You can represent the values of the parameters, ‘colour’ and ‘alcohol percentages’ as ‘x’ and ‘y’
respectively. Then (x,y) defines the parameters of each drink in the training data. This set of data
is called a training set. These values, when plotted on a graph, present a hypothesis in the form of
a line, a rectangle, or a polynomial that fits best to the desired results.
Once the model is trained on a defined training set, it needs to be checked for discrepancies and
errors. We use a fresh set of data to accomplish this task. The outcome of this test would be one
of these four:
• True Positive: When the model predicts the condition when it is present
• True Negative: When the model does not predict a condition when it is absent
• False Positive: When the model predicts a condition when it is absent
• False Negative: When the model does not predict a condition when it is present
INTRODUCTION TO ML
TRIZA KWAMBOKA ABUYA
Manage Noise
For the sake of simplicity, we have considered only two parameters to approach a machine
learning problem here that is the colour and alcohol percentage. But in reality, you will have to
consider hundreds of parameters and a broad set of learning data to solve a machine learning
problem.
• The hypothesis then created will have a lot more errors because of the noise. Noise is the
unwanted anomalies that disguise the underlying relationship in the data set and weakens
the learning process. Various reasons for this noise to occur are:
• Large training data set
• Errors in input data
• Data labelling errors
• Unobservable attributes that might affect the classification but are not considered in the
training set due to lack of data
You can accept a certain degree of training error due to noise to keep the hypothesis as simple as
possible.
While it is possible for an algorithm or hypothesis to fit well to a training set, it might fail when
applied to another set of data outside of the training set. Therefore, It is essential to figure out if
the algorithm is fit for new data. Testing it with a set of new data is the way to judge this. Also,
generalization refers to how well the model predicts outcomes for a new set of data.
When we fit a hypothesis algorithm for maximum possible simplicity, it might have less error for
the training data, but might have more significant error while processing new data. We call this is
under-fitting. On the other hand, if the hypothesis is too complicated to accommodate the best
fit to the training result, it might not generalize well. This is the case of over-fitting. In either
case, the results are fed back to train the model further.
INTRODUCTION TO ML
TRIZA KWAMBOKA ABUYA
Which Language is Best for Machine Learning?
Python is hands down the best programming language for Machine Learning applications due to
the various benefits mentioned in the section below. Other programming languages that could to
use for Machine Learning Applications are R, C++, JavaScript, Java, C#, Julia, Shell,
TypeScript, and Scala.
Python is famous for its readability and relatively lower complexity as compared to other
programming languages. Machine Learning applications involve complex concepts like calculus
and linear algebra which take a lot of effort and time to implement. Python helps in reducing this
burden with quick implementation for the ML engineer to validate an idea. You can check out
the Python Tutorial to get a basic understanding of the language. Another benefit of using Python
in Machine Learning is the pre-built libraries. There are different packages for a different type of
applications, as mentioned below:
• Numpy, OpenCV, and Scikit are used when working with images
• NLTK along with Numpy and Scikit again when working with text
• Librosa for audio applications
• Matplotlib, Seaborn, and Scikit for data representation
• TensorFlow and Pytorch for Deep Learning applications
• Scipy for Scientific Computing
• Django for integrating web applications
• Pandas for high-level data structures and analysis
Python is a versatile programming language and can run on any platform, including Windows,
MacOS, Linux, Unix, and others. While migrating from one platform to another, the code needs
some minor adaptations and changes, and it is ready to work on the new platform.
Also, artificial intelligence enables machines and frameworks to think and do the tasks as
humans do. While machine learning depends on the inputs provided or queries requested by
INTRODUCTION TO ML
TRIZA KWAMBOKA ABUYA
users. The framework acts on the input by screening if it is available in the knowledge base and
then provides output.
The supervised learning model has a set of input variables (x), and an output variable (y). An
algorithm identifies the mapping function between the input and output variables. The
relationship is y = f(x).
The learning is monitored or supervised in the sense that we already know the output and the
algorithm are corrected each time to optimise its results. The algorithm is trained over the data
set and amended until it achieves an acceptable level of performance.
We can group the supervised learning problems as:
1. Regression problems – Used to predict future values and the model is trained with the
historical data. E.g., Predicting the future price of a product.
2. Classification problems – Various labels train the algorithm to identify items within a
specific category. E.g., Disease or no disease, Apple or an orange, Beer or wine.
This approach is the one where the output is unknown, and we have only the input variable at
hand. The algorithm learns by itself and discovers an impressive structure in the data.
The goal is to decipher the underlying distribution in the data to gain more knowledge about the
data.
We can group the unsupervised learning problems as:
1. Clustering: This means bundling the input variables with the same characteristics
together. E.g., grouping users based on search history
2. Association: Here, we discover the rules that govern meaningful associations among the
data set. E.g., People who watch ‘X’ will also watch ‘Y.’
In semi-supervised learning, data scientists train model with a minimal amount of labelled data
and a large amount of unlabelled data. Usually, the first step is to cluster similar data with the
help of an unsupervised machine learning algorithm. The next step is to label the unlabelled data
using the characteristics of the limited labelled data available. After labelling the complete data,
one can use supervised learning algorithms to solve the problem.
INTRODUCTION TO ML
TRIZA KWAMBOKA ABUYA
What is Reinforcement Learning?
In this approach, machine learning models are trained to make a series of decisions based on the
rewards and feedback they receive for their actions. The machine learns to achieve a goal in
complex and uncertain situations and is rewarded each time it achieves it during the learning
period.
Reinforcement learning is different from supervised learning in the sense that there is no answer
available, so the reinforcement agent decides the steps to perform a task. The machine learns
from its own experiences when there is no training data set present.
Machine Learning algorithms help in building intelligent systems that can learn from their past
experiences and historical data to give accurate results. Many industries are thus applying
machine learning solutions to their business problems, or to create new and better products and
services. Healthcare, defence, financial services, marketing, and security services, among others,
use Machine Learning in their applications and processes.
The most common application of machine learning is Facial Recognition, and the simplest
example of this application is the iPhone X. There are a lot of use-cases of facial recognition,
mostly for security purposes like identifying criminals, searching for missing individuals, aid
forensic investigations, etc. Intelligent marketing, diagnose diseases, track attendance in schools,
are some other uses.
Abbreviated as ASR, automatic speech recognition is used to convert speech into digital text. Its
applications lie in authenticating users based on their voice and performing tasks based on the
human voice inputs. Speech patterns and vocabulary are fed into the system to train the model.
Presently ASR systems find a wide variety of applications in the following domains:
• Medical Assistance
• Industrial Robotics
• Forensic and Law enforcement
• Defence & Aviation
• Telecommunications Industry
• Home Automation and Security Access Control
• I.T. and Consumer Electronics
Financial Services
Machine learning has many use cases in Financial Services. Machine Learning algorithms prove
to be excellent at detecting frauds by monitoring activities of each user and assess that if an
INTRODUCTION TO ML
TRIZA KWAMBOKA ABUYA
attempted activity is typical of that user or not.
Financial monitoring to detect money laundering activities is also a critical security use case of
machine learning.
Machine Learning also helps in making better trading decisions with the help of algorithms that
can analyse thousands of data sources simultaneously. Credit scoring and underwriting are some
of the other applications.
The most common application in our day to day activities is the virtual personal assistants like
Siri and Alexa.
Machine Learning is improving lead scoring algorithms by including various parameters such as
website visits, emails opened, downloads, and clicks to score each lead. It also helps businesses
to improve their dynamic pricing models by using regression techniques to make predictions.
Healthcare
A vital application of Machine Learning is in the diagnosis of diseases and ailments, which are
otherwise difficult to diagnose. Radiotherapy is also becoming better with Machine Learning
taking over.
Early-stage drug discovery is another crucial application which involves technologies such as
precision medicine and next-generation sequencing. Clinical trials cost a lot of time and money
to complete and deliver results. Applying Machine Learning based predictive analytics could
improve on these factors and give better results.
Machine Learning technologies are also critical to make outbreak predictions. Scientists around
the world are using these technologies to predict epidemic outbreaks.
Recommendation Systems
Many businesses today use recommendation systems to effectively communicate with the users
on their site. It can recommend relevant products, movies, web-series, songs, and much more.
Most prominent use-cases of recommendation systems are e-commerce sites like Amazon,
Flipkart, and many others, along with Spotify, Netflix, and other web-streaming channels.
Arthur Samuel coined the term Machine Learning in 1959. He defined it as “The field of study
that gives computers the capability to learn without being explicitly programmed”. Machine
Learning is a subset of Artificial Intelligence and it allows machines to learn from their
experiences without any coding.
Machine Learning is used in our daily lives much more than we know it. These are areas where
machine learning is used:
• Facial Recognition
• Self-driving cars
• Virtual assistants
• Traffic Predictions
• Speech Recognition
• Online Fraud Detection
• Email Spam Filtering
• Product Recommendations
A technology that enables a machine to stimulate human behavior to help in solving complex
problems is known as Artificial Intelligence. Machine Learning is a subset of AI and allows
machines to learn from past data and provide an accurate output. AI deals with unstructured as
well as structured data. Whereas, Machine Learning deals with structured and semi-structured
data.
The typical machine learning process involves three steps: Training, Validation, and Testing.
The first step is to learn from the training set provided, the second step is to measure error, the
third step involves managing noise and testing all the parameters. These are the basic steps
followed and a very broad description on how machine learning works.
Alexa is a virtual assistant that is created by Amazon and is also known as Amazon Alexa. This
virtual assistant was created using machine learning and artificial intelligence technologies.
Similar to Alexa, Siri is also a virtual or a personal assistant. Siri was created by Apple and
makes use of voice technology to perform certain actions. Siri also makes use of machine
learning and deep learning to function.
The amount of data available to us is constantly increasing. Machines make use of this data to
learn and improve the results and outcomes provided to us. These outcomes can be extremely
helpful in providing valuable insights and taking informed business decisions as well. Machine
Learning is constantly growing, and with that, the applications of machine learning are growing
as well. We make use of machine learning in our day-to-day life more than we know it. In the
future, machine learning is only said to grow further and help us. Thus, it is popular.
INTRODUCTION TO ML
TRIZA KWAMBOKA ABUYA
Now you may wonder, how is it different from traditional programming? Well, in traditional
programming, we would feed the input data and a well written and tested program into a
machine to generate output. When it comes to machine learning, input data along with the output
is fed into the machine during the learning phase, and it works out a program for itself. To
understand this better, refer to the illustration below:
INTRODUCTION TO ML
TRIZA KWAMBOKA ABUYA
With the help of Machine Learning, businesses can automate routine tasks. It also helps in
automating and quickly create models for data analysis. Various industries depend on vast
quantities of data to optimize their operations and make intelligent decisions. Machine Learning
helps in creating models that can process and analyze large amounts of complex data to deliver
accurate results. These models are precise and scalable and function with less turnaround time.
By building such precise Machine Learning models, businesses can leverage profitable
opportunities and avoid unknown risks.
Image recognition, text generation, and many other use-cases are finding applications in the real
world. This is increasing the scope for machine learning experts to shine as a sought after
professionals.
It is mandatory to learn a programming language, preferably Python, along with the required
analytical and mathematical knowledge. Here are the three mathematical areas that you need to
brush up before jumping into solving Machine Learning problems:
INTRODUCTION TO ML
TRIZA KWAMBOKA ABUYA
1. Linear algebra for data analysis: Scalars, Vectors, Matrices, and Tensors
2. Mathematical Analysis: Derivatives and Gradients
3. Probability theory and statistics
4. Multivariate Calculus
5. Algorithms and Complex Optimizations
Let us build on the beer and wine example to understand how machine learning works. A
machine learning model here has to predict if a drink is a beer or wine. The parameters selected
are the colour of the drink and the alcohol percentage. The first step is:
This involves taking a sample data set of several drinks for which the colour and alcohol
percentage is specified. Now, we have to define the description of each classification, that is
wine and beer, in terms of the value of parameters for each type. The model can use the
description to decide if a new drink is a wine or beer.
You can represent the values of the parameters, ‘colour’ and ‘alcohol percentages’ as ‘x’ and ‘y’
respectively. Then (x,y) defines the parameters of each drink in the training data. This set of data
is called a training set. These values, when plotted on a graph, present a hypothesis in the form of
a line, a rectangle, or a polynomial that fits best to the desired results.
Once the model is trained on a defined training set, it needs to be checked for discrepancies and
errors. We use a fresh set of data to accomplish this task. The outcome of this test would be one
of these four:
• True Positive: When the model predicts the condition when it is present
• True Negative: When the model does not predict a condition when it is absent
• False Positive: When the model predicts a condition when it is absent
• False Negative: When the model does not predict a condition when it is present
INTRODUCTION TO ML
TRIZA KWAMBOKA ABUYA
Manage Noise
For the sake of simplicity, we have considered only two parameters to approach a machine
learning problem here that is the colour and alcohol percentage. But in reality, you will have to
consider hundreds of parameters and a broad set of learning data to solve a machine learning
problem.
• The hypothesis then created will have a lot more errors because of the noise. Noise is the
unwanted anomalies that disguise the underlying relationship in the data set and weakens
the learning process. Various reasons for this noise to occur are:
• Large training data set
• Errors in input data
• Data labelling errors
• Unobservable attributes that might affect the classification but are not considered in the
training set due to lack of data
You can accept a certain degree of training error due to noise to keep the hypothesis as simple as
possible.
While it is possible for an algorithm or hypothesis to fit well to a training set, it might fail when
applied to another set of data outside of the training set. Therefore, It is essential to figure out if
the algorithm is fit for new data. Testing it with a set of new data is the way to judge this. Also,
generalization refers to how well the model predicts outcomes for a new set of data.
When we fit a hypothesis algorithm for maximum possible simplicity, it might have less error for
the training data, but might have more significant error while processing new data. We call this is
under-fitting. On the other hand, if the hypothesis is too complicated to accommodate the best
fit to the training result, it might not generalize well. This is the case of over-fitting. In either
case, the results are fed back to train the model further.
INTRODUCTION TO ML
TRIZA KWAMBOKA ABUYA
Which Language is Best for Machine Learning?
Python is hands down the best programming language for Machine Learning applications due to
the various benefits mentioned in the section below. Other programming languages that could to
use for Machine Learning Applications are R, C++, JavaScript, Java, C#, Julia, Shell,
TypeScript, and Scala.
Python is famous for its readability and relatively lower complexity as compared to other
programming languages. Machine Learning applications involve complex concepts like calculus
and linear algebra which take a lot of effort and time to implement. Python helps in reducing this
burden with quick implementation for the ML engineer to validate an idea. You can check out
the Python Tutorial to get a basic understanding of the language. Another benefit of using Python
in Machine Learning is the pre-built libraries. There are different packages for a different type of
applications, as mentioned below:
• Numpy, OpenCV, and Scikit are used when working with images
• NLTK along with Numpy and Scikit again when working with text
• Librosa for audio applications
• Matplotlib, Seaborn, and Scikit for data representation
• TensorFlow and Pytorch for Deep Learning applications
• Scipy for Scientific Computing
• Django for integrating web applications
• Pandas for high-level data structures and analysis
Python is a versatile programming language and can run on any platform, including Windows,
MacOS, Linux, Unix, and others. While migrating from one platform to another, the code needs
some minor adaptations and changes, and it is ready to work on the new platform.
Also, artificial intelligence enables machines and frameworks to think and do the tasks as
humans do. While machine learning depends on the inputs provided or queries requested by
INTRODUCTION TO ML
TRIZA KWAMBOKA ABUYA
users. The framework acts on the input by screening if it is available in the knowledge base and
then provides output.
The supervised learning model has a set of input variables (x), and an output variable (y). An
algorithm identifies the mapping function between the input and output variables. The
relationship is y = f(x).
The learning is monitored or supervised in the sense that we already know the output and the
algorithm are corrected each time to optimise its results. The algorithm is trained over the data
set and amended until it achieves an acceptable level of performance.
We can group the supervised learning problems as:
1. Regression problems – Used to predict future values and the model is trained with the
historical data. E.g., Predicting the future price of a product.
2. Classification problems – Various labels train the algorithm to identify items within a
specific category. E.g., Disease or no disease, Apple or an orange, Beer or wine.
This approach is the one where the output is unknown, and we have only the input variable at
hand. The algorithm learns by itself and discovers an impressive structure in the data.
The goal is to decipher the underlying distribution in the data to gain more knowledge about the
data.
We can group the unsupervised learning problems as:
1. Clustering: This means bundling the input variables with the same characteristics
together. E.g., grouping users based on search history
2. Association: Here, we discover the rules that govern meaningful associations among the
data set. E.g., People who watch ‘X’ will also watch ‘Y.’
In semi-supervised learning, data scientists train model with a minimal amount of labelled data
and a large amount of unlabelled data. Usually, the first step is to cluster similar data with the
help of an unsupervised machine learning algorithm. The next step is to label the unlabelled data
using the characteristics of the limited labelled data available. After labelling the complete data,
one can use supervised learning algorithms to solve the problem.
INTRODUCTION TO ML
TRIZA KWAMBOKA ABUYA
What is Reinforcement Learning?
In this approach, machine learning models are trained to make a series of decisions based on the
rewards and feedback they receive for their actions. The machine learns to achieve a goal in
complex and uncertain situations and is rewarded each time it achieves it during the learning
period.
Reinforcement learning is different from supervised learning in the sense that there is no answer
available, so the reinforcement agent decides the steps to perform a task. The machine learns
from its own experiences when there is no training data set present.
Machine Learning algorithms help in building intelligent systems that can learn from their past
experiences and historical data to give accurate results. Many industries are thus applying
machine learning solutions to their business problems, or to create new and better products and
services. Healthcare, defence, financial services, marketing, and security services, among others,
use Machine Learning in their applications and processes.
The most common application of machine learning is Facial Recognition, and the simplest
example of this application is the iPhone X. There are a lot of use-cases of facial recognition,
mostly for security purposes like identifying criminals, searching for missing individuals, aid
forensic investigations, etc. Intelligent marketing, diagnose diseases, track attendance in schools,
are some other uses.
Abbreviated as ASR, automatic speech recognition is used to convert speech into digital text. Its
applications lie in authenticating users based on their voice and performing tasks based on the
human voice inputs. Speech patterns and vocabulary are fed into the system to train the model.
Presently ASR systems find a wide variety of applications in the following domains:
• Medical Assistance
• Industrial Robotics
• Forensic and Law enforcement
• Defence & Aviation
• Telecommunications Industry
• Home Automation and Security Access Control
• I.T. and Consumer Electronics
Financial Services
Machine learning has many use cases in Financial Services. Machine Learning algorithms prove
to be excellent at detecting frauds by monitoring activities of each user and assess that if an
INTRODUCTION TO ML
TRIZA KWAMBOKA ABUYA
attempted activity is typical of that user or not.
Financial monitoring to detect money laundering activities is also a critical security use case of
machine learning.
Machine Learning also helps in making better trading decisions with the help of algorithms that
can analyse thousands of data sources simultaneously. Credit scoring and underwriting are some
of the other applications.
The most common application in our day to day activities is the virtual personal assistants like
Siri and Alexa.
Machine Learning is improving lead scoring algorithms by including various parameters such as
website visits, emails opened, downloads, and clicks to score each lead. It also helps businesses
to improve their dynamic pricing models by using regression techniques to make predictions.
Healthcare
A vital application of Machine Learning is in the diagnosis of diseases and ailments, which are
otherwise difficult to diagnose. Radiotherapy is also becoming better with Machine Learning
taking over.
Early-stage drug discovery is another crucial application which involves technologies such as
precision medicine and next-generation sequencing. Clinical trials cost a lot of time and money
to complete and deliver results. Applying Machine Learning based predictive analytics could
improve on these factors and give better results.
Machine Learning technologies are also critical to make outbreak predictions. Scientists around
the world are using these technologies to predict epidemic outbreaks.
Recommendation Systems
Many businesses today use recommendation systems to effectively communicate with the users
on their site. It can recommend relevant products, movies, web-series, songs, and much more.
Most prominent use-cases of recommendation systems are e-commerce sites like Amazon,
Flipkart, and many others, along with Spotify, Netflix, and other web-streaming channels.
Arthur Samuel coined the term Machine Learning in 1959. He defined it as “The field of study
that gives computers the capability to learn without being explicitly programmed”. Machine
Learning is a subset of Artificial Intelligence and it allows machines to learn from their
experiences without any coding.
Machine Learning is used in our daily lives much more than we know it. These are areas where
machine learning is used:
• Facial Recognition
• Self-driving cars
• Virtual assistants
• Traffic Predictions
• Speech Recognition
• Online Fraud Detection
• Email Spam Filtering
• Product Recommendations
A technology that enables a machine to stimulate human behavior to help in solving complex
problems is known as Artificial Intelligence. Machine Learning is a subset of AI and allows
machines to learn from past data and provide an accurate output. AI deals with unstructured as
well as structured data. Whereas, Machine Learning deals with structured and semi-structured
data.
The typical machine learning process involves three steps: Training, Validation, and Testing.
The first step is to learn from the training set provided, the second step is to measure error, the
third step involves managing noise and testing all the parameters. These are the basic steps
followed and a very broad description on how machine learning works.
Alexa is a virtual assistant that is created by Amazon and is also known as Amazon Alexa. This
virtual assistant was created using machine learning and artificial intelligence technologies.
Similar to Alexa, Siri is also a virtual or a personal assistant. Siri was created by Apple and
makes use of voice technology to perform certain actions. Siri also makes use of machine
learning and deep learning to function.
The amount of data available to us is constantly increasing. Machines make use of this data to
learn and improve the results and outcomes provided to us. These outcomes can be extremely
helpful in providing valuable insights and taking informed business decisions as well. Machine
Learning is constantly growing, and with that, the applications of machine learning are growing
as well. We make use of machine learning in our day-to-day life more than we know it. In the
future, machine learning is only said to grow further and help us. Thus, it is popular.