Introduction to Machine
Learning
Module -1
Chapter -1
First Encounter of
Machine Learning
• The computer program was IBM’s Deep Blue
and it defeated world chess champion, Gary
Kasparov.
• While Deep Blue was searching some 200
million positions per second,
• Kasparov was searching not more than 5–10
positions probably, per second.
Continue….
• It can recommend toys to toddlers
• It can suggest a technology book to a geek
• It recommends rich title in literature to a writer.
• It predicts the future market to help amateur traders compete with seasoned
stock traders.
• It helps an oncologist find whether a tumour is malignant or benign.
• It helps in optimizing energy consumption thus helping the cause of Green
Earth.
Continue…
• Google has become one of the front-runners focusing a lot of its
research on machine learning and artificial intelligence –
• Google self-driving car (Sebastian Thrun, the former director of the Stanford
Artificial Intelligence Laboratory (SAIL) 2009)
• Google Brain (Enable robots to complete tasks by learning from experience,
Andrew Ng )
The Evolution of Machine Learning
🚗 1961 – Stanford Cart (First autonomous wheeled robot).
🚗 1986 – Mercedes-Benz (First AI-based self-driving car).
🚛 2004-2007 – DARPA Grand Challenge (Major innovation in
self-driving cars).
🚕 2010+ – Google/Waymo, Tesla, and others advance self-driving
technology.
1.2 WHAT IS HUMAN LEARNING?
• In our daily life, we need to carry out multiple activities
• Simple or it may be some complex task
• To do a task in a proper way, we need to have prior information on
one or more things related to the task
• As we keep learning more or in other words acquiring more
information, the efficiency in doing the tasks keep improving.
1.3 TYPES OF HUMAN LEARNING
• Human learning happens in one of the three ways –
(1) Either somebody who is an expert in the subject directly
reaches us.
(2) We build our own notion indirectly based on what we have
learnt from the expert in the past.
(3) We do it ourselves, may be after multiple attempts, some being
unsuccessful.
1.3.1 Learning under expert guidance
• Falls under the category of learning directly under expert guidance
• Guided learning is the process of gaining information from a person
having sufficient knowledge due to the past experience
1.3.2 Learning guided by knowledge gained
from experts
• The second type falls under learning guided by knowledge gained
from experts
• There is no direct learning. It is some past information shared on
some different context, which is used as a learning to make decisions
1.3.3 Learning by self
• Third type is learning by self or self-learning
• Humans are left to learn on their own
• Not all things are taught by others
• A lot of things need to be learnt only from mistakes made in the past.
1.4 WHAT IS MACHINE LEARNING?
• ‘A computer program is said to learn from experience E with respect
to some class of tasks T and performance measure P, if its
performance at tasks in T, as measured by P, improves with
experience E.’
By Tom M Mitchell, Professor of Machine Learning Department, School
of Computer Science, Carnegie Mellon University
Continue…
• In the context of the learning to play checkers,
E represents the Experience of playing the game,
T represents the Task of playing checkers and
P is the Performance measure indicated by the percentage of games
won by the player.
Continue…
• The same mapping can be applied for any other machine learning problem, for
example, Image Classification Problem.
• In context of image classification,
E represents the past data with images having labels or assigned classes (for
example whether the image is of a class cat or a class dog or a class elephant
etc.),
T is the task of assigning class to new, unlabelled images
P is the performance measure indicated by the percentage of images correctly
classified.
1.4.1 How do machines learn?
• The basic machine learning process can be divided into three parts.
1. Data Input: Past data or information is utilized as a basis for
future decision-making
2. Abstraction: The input data is represented in a broader way
through the underlying algorithm
3. Generalization: The abstracted representation is generalized
to form a framework for making decisions
Schematic representation of the machine
learning process
• Data Input: Collect past data for learning (e.g., house prices ).
• Data Input
🔹 Definition:
• The model receives raw data as input.
• This data can be structured (e.g., databases, spreadsheets) or unstructured
(e.g., images, text, videos).
• The goal is to use past data to make future predictions.
🔹 Example:
• In house price prediction, the input data includes:
• House size (sq. ft)
• Number of bedrooms
• Location
• Price (historical data)
• Abstraction: Use algorithms to find patterns in the data (e.g., price increases with house size )
• Definition:
• The input data is processed and transformed into a mathematical model using algorithms.
• The goal is to extract meaningful patterns and relationships.
• Different machine learning algorithms are used for abstraction, such as:
• Linear Regression (for predicting continuous values)
• Decision Trees (for classification)
• Neural Networks (for deep learning tasks)
Example:
• In house price prediction, the algorithm learns patterns such as:
• "Larger houses tend to have higher prices."
• "Urban areas have more expensive houses than rural areas."
• Generalization: Apply learning to new cases (e.g., predict price of a
new house ).
• Definition:
• The model applies what it has learned to new, unseen data to make
accurate predictions.
• A good model doesn’t just memorize past data but generalizes well
to real-world scenarios.
• This step ensures that the model performs well on new examples
rather than just the training data.
Example:
• In house price prediction, once trained, the model can predict the
price of a new house based on its features.
• The model generalizes its learning to new houses that were not in
the original dataset.
Data Input
• During the machine learning process, knowledge is fed in the form of
input data.
• The data cannot be used in the original shape and form.
[Link] Abstraction
• The first part of machine learning process is abstraction i.e. abstract
the knowledge which comes as input data in the form of a model.
• However, this abstraction process, or more popularly training the
model, is just one part of machine learning.
• The input data based on which the model is being finalized is known
as training data.
Continue…
• The model may be in any one of the following forms:
• Computational blocks like if/else rules
• Mathematical equations
• Specific data structures like trees or graphs
• Logical groupings of similar observations
Continue…
• The decision related to the choice of model is taken based on multiple
aspects, some of which are listed below:
• The type of problem to be solved:
• Whether the problem is related to forecast or prediction, analysis of trend,
understanding the different segments or groups of objects, etc.
• Nature of the input data: How exhaustive the input data is, whether the data
has no values for many fields, the data types, etc.
• Domain of the problem: If the problem is in a business critical domain with a
high rate of data input and need for immediate inference, e.g. fraud detection
problem in banking domain.
Continue…
• Once the model is chosen, the next task is to fit the model based on the
input data.
• Let’s understand this with an example.
• In a case where the model is represented by a mathematical equation, say
‘y = c1 + c2 x’, based on the input data, we have to find out the values of c1
and c2 and x.
• Otherwise, the equation (or the model) is of no use.
[Link] Generalization
• The other key part is to tune up the abstracted knowledge to a form
which can be used to take future decisions.
• This is achieved as a part of generalization, which is quite difficult to
achieve because the model is trained based on a finite set of data,
which may possess a limited set of characteristics.
Continue…
• But when we want to apply the model to take decision on a set of
unknown data, usually termed as test data, we may encounter two
problems:
1. The trained model is aligned with the training data too much,
hence may not portray the actual trend.
2. The test data possess certain characteristics apparently unknown
to the training data.
1.4.2 Well-posed learning problem
• For defining a new problem, which can be solved using machine
learning, a simple framework can be used.
• This framework also helps in deciding whether the problem is a right
candidate to be solved using machine learning.
• The framework involves answering three questions:
1. What is the problem?
2. Why does the problem need to be solved?
3. How to solve the problem?
Step 1: What is the Problem?
• A number of information should be collected to know
what is the problem.
• Informal description of the problem,
• e.g. I need a program that will prompt the next word as and when I type a
word.
Example:
• Machine learning formalism stated above to define the T, P, and E for the
problem.
• For example:
Task (T): Prompt the next word when I type a word.
Experience (E): A corpus of commonly used English words and
phrases.
Performance (P): The number of correct words prompted
considered as a percentage (which in machine
learning paradigm is known as learning accuracy).
• Assumptions - Create a list of assumptions about the problem.
• Similar problems
• What other problems have you seen or can you think of that are
similar to the problem that you are trying to solve?
Step 2: Why does the problem need to be
solved?
• Motivation
• Solution benefits
• Solution use
Step 3: How would I solve the problem?
• Detail out step-by-step
• data collection
• data preparation
• program design to solve the problem.
• Collect all these details and update the previous sections of the
problem definition, especially the assumptions.
1.5 TYPES OF MACHINE LEARNING
• Machine learning can be classified into three broad categories:
1. Supervised learning – Also called predictive learning. A
machine predicts the class of unknown objects based on prior
class related information of similar objects.
2. Unsupervised learning – Also called descriptive learning. A
machine finds patterns in unknown objects by grouping similar
objects together.
3. Reinforcement learning – A machine learns to act on its own
to achieve the given goals.
Types of machine learning
Supervised
learning
Continue…
• Simple depiction of the supervised learning process.
• Labelled training data containing past information comes as an input.
• Based on the training data, the machine builds a predictive model
that can be used on test data to assign a label for each record in the
test data.
Note
• Supervised machine learning is as good as the data used to train it.
• If the training data is of poor quality, the prediction will also be far
from being precise.
Steps involved in Supervised ML
Examples of Supervised learning
• Predicting the results of a game
• Predicting whether a tumour is malignant or benign
• Predicting the price of domains like real estate, stocks, etc.
• Classifying texts such as classifying a set of emails as spam or
non-spam
Two Areas Of Supervised
Learning
• When we are trying to predict a categorical or nominal variable, the
problem is known as a classification problem.
• Whereas when we are trying to predict a real valued variable, the
problem falls under the category of regression.
Classification problems
Some typical classification problems include:
• Image classification
• Prediction of disease
• Win–loss prediction of games
• Prediction of natural calamity like earthquake, flood, etc.
• Recognition of handwriting
Algorithm for solving Classification problems
• Naïve Bayes,
• Decision tree,
• k- Nearest Neighbour
Regression
• A regression is a statistical technique that relates a dependent
variable to one or more independent (explanatory) variables.
• A regression model is able to show whether changes observed in the
dependent variable are associated with changes in one or more of the
explanatory variables.
Applications of regression
• Demand forecasting in retails
• Sales prediction for managers
• Price prediction in real estate
• Weather forecast
• Skill demand forecast in job market
Unsupervised Learning
• No labelled training data to learn from and no prediction to be made.
• In unsupervised learning, the objective is to take a dataset as input and
try to find natural groupings or patterns within the data elements or
records.
• Therefore, unsupervised learning is often termed as descriptive model
and the process of unsupervised learning is referred as pattern
discovery or knowledge discovery.
Two types of Unsupervised Learning
• Clustering is the main type of unsupervised learning.
• It intends to group or organize similar objects together.
Continue…
• One of the most commonly adopted similarity measure is distance.
• Two data items are considered as a part of the same cluster if the
distance between them is less.
• In the same way, if the distance between the data items is high, the
items do not generally belong to the same cluster.
• This is also known as distance-based clustering
Association analysis
• One more variant of unsupervised learning is association analysis
• The association between data elements is identified
• Common examples, i.e. market basket analysis
Continue…
• From past transaction data in a grocery store, it may be observed that most of the
customers who have bought item A, have also bought item B and item C or at least one of
them.
• This means that there is a strong association of the event ‘purchase of item A’ with the
event ‘purchase of item B’, or ‘purchase of item C’.
• Identifying these sorts of associations is the goal of association analysis.
• This helps in boosting up sales pipeline, hence a critical input for the sales group.
Reinforcement learning
Continue…
• When a sub-task is accomplished successfully, a reward is given.
• When a sub-task is not executed correctly, obviously no reward is
given.
• This continues till the machine is able to complete execution of the
whole task.
• This process of learning is known as reinforcement learning.
Continue…
• One contemporary example of reinforcement learning is self-driving cars.
• The critical information which it needs to take care of are speed and speed
limit in different road segments, traffic conditions, road conditions, weather
conditions, etc.
• The tasks that have to be taken care of are start/stop,
accelerate/decelerate, turn to left / right, etc.
PROBLEMS NOT TO BE SOLVED USING
MACHINE LEARNING
• Machine learning should not be applied to tasks in which humans are
very effective or frequent human. Example : air traffic control
• For very simple tasks which can be implemented using traditional
programming paradigms. Example: simple rule-driven or
formula-based applications.
Continue…
• For situations where training data is not sufficient, machine learning
cannot be used effectively.
• This is because, with small training data sets, the impact of bad data
is exponentially worse.
• For the quality of prediction or recommendation to be good, the
training data should be sizeable.
1.9 ISSUES IN MACHINE LEARNING
• Self – Learning Topic
Preparing to Model
Chapter - 2
Introduction
• To understand the incoming data and create basic understanding
about the nature and quality of the data.
2.2 MACHINE LEARNING ACTIVITIES
• The first step in machine learning activity starts with data.
• In case of supervised learning, it is the labelled training data set
followed by test data which is not labelled.
• In case of unsupervised learning, it is unlabelled data but the task is to
find patterns in the input data.
Continue…
• A thorough review and exploration of the data is needed to
understand
• type of the data
• the quality of the data
• relationship between the different data elements.
Continue…
• Based on that, multiple pre-processing activities need to be done on
the input data before we can go ahead with core machine learning
activities.
Four-step process of
Machine Learning
Typical Preparation Activities
• Understand the type of data in the given input data set.
• Explore the data to understand the nature and quality.
• Explore the relationships amongst the data elements, e.g. inter feature
relationship.
• Find potential issues in data. Do the necessary remediation, e.g. impute
missing data values, using mean or median method
Continue…
• Once the data is prepared for modelling, then the learning tasks start off. As a part
of it, do the following activities:
• The input data is first divided into parts – the training data and the test data (called
holdout). This step is applicable for supervised learning only.
• Consider different models or learning algorithms for selection.
• Train the model based on the training data for supervised learning problem and
apply to unknown data.
• Directly apply the chosen unsupervised model on the input data for unsupervised
learning problem.
2.3 BASIC TYPES OF DATA IN MACHINE
LEARNING
• A data set is a collection of related information or records.
• The information may be on some entity or some subject area.
• Data can broadly be divided into following two types:
1. Qualitative data
2. Quantitative data
Qualitative data
• Qualitative data provides information about the quality of an object or
information which cannot be measured.
• For example, if we consider the quality of performance of students in terms
of ‘Good’, ‘Average’, and ‘Poor’, it falls under the category of qualitative
data.
• Also, name or roll number of students are information that cannot be
measured using some scale of measurement, qualitative data.
• Qualitative data is also called categorical data.
Qualitative data
• Qualitative data can be further subdivided into two types as follows:
1. Nominal data
2. Ordinal data
Nominal data
• Nominal data is one which has no numeric value, but a named value. It is
used for assigning named values to attributes.
• Nominal values cannot be quantified.
• Examples of nominal data are
1. Blood group: A, B, O, AB, etc.
2. Nationality: Indian, American, British, etc.
3. Gender: Male, Female, Other
Ordinal data
• Ordinal data, in addition to possessing the properties of nominal data, can also be
naturally ordered.
• This means ordinal data also assigns named values to attributes but unlike nominal data,
they can be arranged in a sequence of increasing or decreasing value so that we can say
whether a value is better than or greater than another value.
• Examples of ordinal data are
1. Customer satisfaction: ‘Very Happy’, ‘Happy’, ‘Unhappy’, etc.
2. Grades: A, B, C, etc.
3. Hardness of Metal: ‘Very Hard’, ‘Hard’, ‘Soft’, etc.
Quantitative data
• Quantitative data relates to information about the quantity of an
object – hence it can be measured.
• Quantitative data is also termed as numeric data.
• There are two types of quantitative data:
1. Interval data
2. Ratio data
Interval data
• Interval data is numeric data for which not only the order is known, but the
exact difference between values is also known.
• An ideal example of interval data is Celsius temperature.
• However, interval data do not have something called a ‘true zero’ value.
• For example, there is nothing called ‘0 temperature’ or ‘no temperature’.
Ratio
• Ratio data represents numeric data for which exact value can be
measured.
• Absolute zero is available for ratio data
• Examples of ratio data include height, weight, age, salary, etc.
Continue…
• Attributes can also be categorized into types based on a number of
values that can be assigned.
• The attributes can be either discrete or continuous based on this factor.
• Example of discrete attribute include roll number, street number, pin code,
etc.
• Examples of continuous attribute include length, height, weight, price, etc