Machine Learning
Machine Learning
Artificial intelligence:
1. "It is a branch of computer science by which we can create intelligent machines
which can behave like a human, think like humans, and able to make decisions."
2. According to the father of Artificial Intelligence, John McCarthy, it is “The science and
engineering of making intelligent machines, especially intelligent computer programs”
3. Artificial Intelligence is a way of making a computer, a computer-controlled
robot, or a software think intelligently, in the similar manner the intelligent
humans think.
4. It is comprised of two words "Artificial" and "intelligence", which
means "a human-made thinking power."
5. Artificial intelligence is a technology using which we can create intelligent systems
that can simulate human intelligence.
6. AI encompasses a range of abilities including learning, reasoning, perception,
problem solving, data analysis and language comprehension.
7. The ultimate goal of AI is to create machines that can emulate capabilities and carry
out diverse tasks, with enhanced efficiency and precision. The field of AI holds
potential to revolutionize aspects of our daily lives.
8. Today, the term “AI” describes a wide range of technologies that power many of the
services and goods we use every day – from apps that recommend tv shows to
chatbots that provide customer support in real time.
9. Strong AI is essentially AI that is capable of human-level, general intelligence. In
other words, it’s just another way to say “artificial general intelligence.”
10. Weak AI, meanwhile, refers to the narrow use of widely available AI technology, like
machine learning or deep learning, to perform very specific tasks, such as playing
chess, recommending songs, or steering cars. Also known as Artificial Narrow
Intelligence (ANI), weak AI is essentially the kind of AI we use daily.
Machine Learning:
1. Machine Learning is the science (and art) of programming computers
so they can learn from data.
2. A subset of artificial intelligence known as machine learning focuses
primarily on the creation of algorithms that enable a computer to
independently learn from data and previous experiences.
3. Arthur Samuel first used the term "machine learning" in 1959.
4. Machine Learning is the field of study that gives computers the ability
to learn without being explicitly programmed. —Arthur Samuel, 1959
5. 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. —Tom Mitchell, 1997
6. Examples
1. Handwriting recognition learning problem
Task T : Recognizing and classifying handwritten words within images
Performance P : Percent of words correctly classified
Training experience E : A dataset of handwritten words with given
classifications
2. A robot driving learning problem
Task T : Driving on highways using vision sensors
Performance P : Average distance traveled before an error
Training experience E : A sequence of images and steering commands
recorded while observing a human driver
7. A machine can learn if it can gain more data to improve its
performance.
o It is a data-driven technology.
1. Supervised learning
2. Unsupervised learning
3. Reinforcement learning
1)Supervised learning:
1. In supervised learning, sample labeled data are provided to the
machine learning system for training, and the system then predicts the
output based on the training data.
2. The system uses labeled data to build a model that understands the
datasets and learns about each one. After the training and processing
are done, we test the model with sample data to see if it can
accurately predict the output.
3. The mapping of the input data to the output data is the objective of
supervised learning. The managed learning depends on oversight, and
it is equivalent to when an understudy learns things in the
management of the educator. Spam filtering is an example of
supervised learning.
o Classification
o Regression
• k-Nearest Neighbors
• Linear Regression
• Logistic Regression
• Support Vector Machines (SVMs)
• Decision Trees and Random Forests
• Neural networks
2) Unsupervised Learning
1. Unsupervised learning is a learning method in which a machine learns
without any supervision.
2. The training is provided to the machine with the set of data that has
not been labeled, classified, or categorized, and the algorithm needs to
act on that data without any supervision. The goal of unsupervised
learning is to restructure the input data into new features or a group of
objects with similar patterns.
o Clustering
o Association
• Clustering
1. —K-Means
2. —DBSCAN
3. —Hierarchical Cluster Analysis (HCA)
1. —One-class SVM
2. —Isolation Forest
Visualization and dimensionality reduction
1. —Principal Component Analysis (PCA)
2. —Kernel PCA
3. —Locally-Linear Embedding (LLE)
4. —t-distributed Stochastic Neighbor Embedding (t-SNE)
• Association rule learning
1. —Apriori
2. —Eclat
Semi-supervised learning:
Where an incomplete training signal is given: a training set with some (often
many) of the target outputs missing. There is a special case of this principle
known as Transduction where the entire set of problem instances is known at
learning time, except that part of the targets are missing. Semi-supervised
learning is an approach to machine learning that combines small labeled
data with a large amount of unlabeled data during training. Semi-supervised
learning falls between unsupervised learning and supervised learning.
3) Reinforcement Learning
1. Reinforcement learning is a feedback-based learning method, in which
a learning agent gets a reward for each right action and gets a penalty
for each wrong action. The agent learns automatically with these
feedbacks and improves its performance. In reinforcement learning,
the agent interacts with the environment and explores it. The goal of
an agent is to get the most reward points, and hence, it improves its
performance.
2. The robotic dog, which automatically learns the movement of his arms,
is an example of Reinforcement learning.
Limitations of Machine Learning-
What is ML pipeline?
ML pipeline expresses the workflow by providing a systematic way on
how to proceed with the machine learning model.
1. Feedforward neural networks (FNNs) are the simplest type of ANN, with
a linear flow of information through the network. FNNs have been
widely used for tasks such as image classification, speech recognition,
and natural language processing.
AI vs ML:
S.No MACHINE
. ARTIFICIAL INTELLIGENCE LEARNING
The terminology
“Machine Learning”
was first used
The terminology “Artificial Intelligence” was in 1952 by IBM
1. originally used by John McCarthy in 1956, who computer scientist
also hosted the first AI conference. Arthur Samuel, a
pioneer in artificial
intelligence and
computer games.
ML stands for
AI stands for Artificial intelligence, Machine Learning
2. where intelligence is defined as the ability to which is defined as
acquire and apply knowledge. the acquisition of
knowledge or skill
Machine Learning is
AI is the broader family consisting of ML and DL
3. the subset of
as its components.
Artificial Intelligence.
The aim is to
The aim is to increase the chance of success and increase accuracy,
4.
not accuracy. but it does not care
about; the success
construct
machines that can
performing a variety of complex jobs. decision-
only accomplish the
making
jobs for which they
have been trained.
The scope of
8. AI has a very broad variety of applications. machine learning is
constrained.
ML allows systems to
9. AI is decision-making. learn new things
from data.
It involves creating
It is developing a system that mimics humans to
10. self-learning
solve problems.
algorithms.
2. Unsupervise
d Learning
3. Reinforceme
nt Learning
ML is a subset of AI
AI refers to the broad field of creating machines
that involves training
that can simulate human intelligence and
algorithms on data to
15. perform tasks such as understanding natural
make predictions,
language, recognizing images and sounds,
decisions, and
making decisions, and solving complex problems.
recommendations.
teaching machines
how to learn from
methods for creating intelligent machines, data without being
including rule-based systems, expert systems, explicitly
and machine learning algorithms. AI systems can programmed, using
be programmed to follow specific rules, make algorithms such as
logical inferences, or learn from data using ML. neural networks,
decision trees, and
clustering.
In contrast, ML
algorithms require
large amounts of
structured data to
learn and improve
AI systems can be built using
their performance.
both structured and unstructured data,
The quality and
including text, images, video, and audio. AI
17. quantity of the data
algorithms can work with data in a variety of
used to train ML
formats, and they can analyze and process data
algorithms are
to extract meaningful insights.
critical factors in
determining the
accuracy and
effectiveness of the
system.
algorithms require
human involvement
to set up, train, and
optimize the system.
autonomously or with minimal human
ML algorithms
intervention, depending on the complexity of the
require the expertise
task. AI systems can make decisions and take
of data scientists,
actions based on the data and rules provided to
engineers, and other
them.
professionals to
design and
implement the
system.
Artificial intelligence is a technology which enables a Machine learning is a subset of AI which allows a machine to automat
machine to simulate human behavior. data without programming explicitly.
The goal of AI is to make a smart computer system like The goal of ML is to allow machines to learn from data so that they can
humans to solve complex problems.
In AI, we make intelligent systems to perform any task In ML, we teach machines with data to perform a particular task and giv
like a human.
Machine learning and deep learning are the two main Deep learning is a main subset of machine learning.
subsets of AI.
AI has a very wide range of scope. Machine learning has a limited scope.
AI is working to create an intelligent system which can Machine learning is working to create machines that can perform only t
perform various complex tasks. which they are trained.
AI system is concerned about maximizing the chances of Machine learning is mainly concerned about accuracy and patterns.
success.
The main applications of AI are Siri, customer support The main applications of machine learning are Online recommen
using catboats, Expert System, Online game playing, search algorithms, Facebook auto friend tagging suggestions, e
intelligent humanoid robot, etc.
On the basis of capabilities, AI can be divided into three Machine learning can also be divided into mainly three types
types, which are, Weak AI, General AI, and Strong AI. learning, Unsupervised learning, and Reinforcement learning.
It includes learning, reasoning, and self-correction. It includes learning and self-correction when introduced with new data.
AI completely deals with Structured, semi-structured, and Machine learning deals with Structured and semi-structured data.
unstructured data.
Artificial intelligence (AI) is computer software that mimics human
cognitive abilities in order to perform complex tasks that historically could
only be done by humans, such as decision making, data analysis, and
language translation.
Today, machine learning is the primary way that most people interact with
AI. Some common ways that you’ve likely encountered machine learning
before include:
Artificial intelligence:
AI allows a machine to simulate human intelligence to solve problems
AI systems use logic and decision trees to learn, reason, and self-
correct
Machine learning:
The goal is to build machines that can learn from data to increase the
accuracy of the output
Ml vs Deep learning:
Requires more human intervention to correct Learns on its own from environment and past
and learn mistakes
Shorter training and lower accuracy Longer training and higher accuracy
Takes less time to train the model. Takes more time to train the model.
DL is a ML algorithm that
AI is a computer
ML is an AI algorithm which uses deep(more than one
algorithm which exhibits
allows system to learn from layer) neural networks to
intelligence through
data. analyze data and provide
decision making.
output accordingly.
Examples of AI
Examples of ML
applications include: Examples of DL application
applications include: Virtual
Google’s AI-Powered include: Sentiment based
Personal Assistants: Siri,
Predictions, Ridesharing news aggregation, Image
Alexa, Google, etc., Email
Apps Like Uber and Lyft, analysis and caption
Spam and Malware
Commercial Flights Use generation, etc.
Filtering.
an AI Autopilot, etc.
algorithm is trained on
labeled data, where the
desired output is known. In
computer vision, expert tasks such as image and
unsupervised learning, the
systems, and more. speech recognition.
algorithm is trained on
unlabeled data, where the
desired output is unknown.
DL networks consist of
multiple layers of
In reinforcement learning,
interconnected neurons
AI systems can be rule- the algorithm learns by trial
that process data in a
based, knowledge- and error, receiving
hierarchical manner,
based, or data-driven. feedback in the form of
allowing them to learn
rewards or punishments.
increasingly complex
representations of the dat
Batch learning
1. In batch learning, the system is incapable of learning incrementally: it
must be trained using all the available data.
2. This will generally take a lot of time and computing resources, so it is
typically done offline.
3. First the system is trained, and then it is launched into production and
runs without learning anymore; it just applies what it has learned. This
is called offline learning.
4. If you want a batch learning system to know about new data (such as
a new type of spam), you need to train a new version of the system
from scratch on the full dataset (not just the new data, but also the old
data), then stop the old system and replace it with the new one.
5. Fortunately, the whole process of training, evaluating, and launching a
Machine Learning system can be automated fairly easily (as shown in
Figure 1-3), so even a batch learning system can adapt to change.
6. Simply update the data and train a new version of the system from
scratch as often as needed.
Online learning:
1. Online learning In online learning, you train the system incrementally
by feeding it data instances sequentially, either individually or by small
groups called mini-batches.
2. Each learning step is fast and cheap, so the system can learn about
new data on thefly, as it arrives (see Fig1-13)
Instance-based learning:
1. instance-based learning: the system learns the examples by heart,
then generalizes to new cases by comparing them to the learned
examples (or a subset of them), using a similarity measure.
2. If you were to create a spam filter this way, it would just flag all emails
that are identical to emails that have already been flagged by users—
not the worst solution, but certainly not the best.
3. Instead of just flagging emails that are identical to known spam emails,
your spam filter could be programmed to also flag emails that are very
similar to known spam emails.
4. This requires a measure of similarity between two emails.
5. A (very basic) similarity measure between two emails could be to count
the number of words they have in common.
6. The system would flag an email as spam if it has many words in
common with a known spam email.
7. For example, in Figure 1-15 the new instance would be classified as a
triangle because the majority of the most similar instances belong to
that class.
Model-based learning:
1. Another way to generalize from a set of examples is to build a model of
these examples, then use that model to make predictions. This is
called model-based learning.
Overfitting:
Underfitting:
Underfitting occurs when our model is too simple to understand the base
structure of the data, just like an undersized pant. This generally happens
when we have limited data into the data set, and we try to build a linear
model with non-linear data. In such scenarios, the complexity of the model
destroys, and rules of the machine learning model become too easy to be
applied on this data set, and the model starts doing wrong predictions as
well.
ADVERTISEMENT
Methods to reduce Underfitting:
Overfitting:
Underfitting:
Underfitting occurs when our model is too simple to understand the base
structure of the data, just like an undersized pant. This generally happens
when we have limited data into the data set, and we try to build a linear
model with non-linear data. In such scenarios, the complexity of the model
destroys, and rules of the machine learning model become too easy to be
applied on this data set, and the model starts doing wrong predictions as
well.
ADVERTISEMENT
8. Customer Segmentation
Data Biasing is also found a big challenge in Machine Learning. These errors
exist when certain elements of the dataset are heavily weighted or need
more importance than others. Biased data leads to inaccurate results,
skewed outcomes, and other analytical errors. However, we can resolve this
error by determining where data is actually biased in the dataset. Further,
take necessary steps to reduce it.
o Analyze data regularly and keep tracking errors to resolve them easily.
This issue is also very commonly seen in machine learning models. However,
machine learning models are highly efficient in producing accurate results
but are time-consuming. Slow programming, excessive requirements and
overloaded data take more time to provide accurate results than expected.
This needs continuous maintenance and monitoring of the model for
delivering accurate results.
Although machine learning models are intended to give the best possible
outcome, if we feed garbage data as input, then the result will also be
garbage. Hence, we should use relevant features in our training sample. A
machine learning model is said to be good if training data has a good set of
features or less to no irrelevant features.
Ensemble Learning and Random Forests
Voting Classifiers:
Suppose you have trained a few classifiers, each one achieving about 80%
accuracy. You may have a Logistic Regression classifier, an SVM classifier, a
Random Forest classifier, a K-Nearest Neighbors classifier, and perhaps a few
more
Ensemble methods work best when the predictors are as independ ent from
one another as possible. One way to get diverse classifiers is to train them
using very different algorithms. This increases the chance that they will
make very different types of errors, improving the ensemble’s accuracy.
Each individual predictor has a higher bias than if it were trained on the
original training set, but aggregation reduces both bias and variance.
Generally, the net result is that the ensemble has a similar bias but a lower
variance than a single predictor trained on the original training set.
Scikit-Learn offers a simple API for both bagging and pasting with the
BaggingClassifier class (or BaggingRegressor for regression)
Out-of-Bag Evaluation
With bagging, some instances may be sampled several times for any given
predictor, while others may not be sampled at all. By default a
BaggingClassifier samples m training instances with replacement
(bootstrap=True), where m is the size of the training set. This means that
only about 63% of the training instances are sampled on average for each
predictor.6 The remaining 37% of the training instances that are not sampled
are called out-of-bag (oob) instances. Note that they are not the same 37%
for all predictors.
Random Forests
a Random Forest is an ensemble of Decision Trees, generally trained via the
bagging method (or sometimes pasting), typically with max_samples set to
the size of the training set. Instead of building a BaggingClassifier and
passing it a DecisionTreeClassifier, you can instead use the
RandomForestClassifier class, which is more convenient and optimized for
Decision Trees.
rnd_clf.fit(X_train, y_train)
y_pred_rf = rnd_clf.predict(X_test)
This results in a greater tree diversity, which (once again) trades a higher
bias for a lower variance, generally yielding an overall better model.
Extra-Trees
When you are growing a tree in a Random Forest, at each node only a
random subset of the features is considered for splitting (as discussed
earlier). It is possible to make trees even more random by also using random
thresholds for each feature rather than searching for the best possible
thresholds (like regular Decision Trees do).
Exhibits resilience in
Other algorithms may
handling missing values
require imputation or
by leveraging available
Handling of elimination of missing
features for predictions,
Missing Data data, potentially impacting
contributing to
model training and
practicality in real-world
performance.
scenarios.
Provides a built-in
Many algorithms may lack
mechanism for assessing
an explicit feature
variable importance,
Variable importance assessment,
aiding in feature
Importance making it challenging to
selection and
identify crucial variables
interpretation of
for predictions.
influential factors.
Boosting
Boosting (originally called hypothesis boosting) refers to any Ensemble
method that can combine several weak learners into a strong learner.
The general idea of most boosting methods is to train predictors
sequentially, each trying to correct its prede cessor. There are many
boosting methods available, but by far the most popular are AdaBoost
(short for Adaptive Boosting) and Gradient Boosting.
AdaBoost
One way for a new predictor to correct its predecessor is to pay a bit
more attention to the training instances that the predecessor
underfitted. This results in new predic tors focusing more and more on
the hard cases. This is the technique used by Ada Boost.