1 of 79

Course Name : MACHINE LEARNING

Course Code : 23AM01

Course Instructor :Dr S Naganjaneyulu

Semester : VI

Regulation : R23

1

2 of 79

20AM01- MACHINE LEARNING

  • Theory - 4 hours per week

    • TEXTBOOKS:
        • 1. “Machine Learning Theory and Practice”, M N Murthy, V S Ananthanarayana, Universities Press (India), 2024.

        • 2. Tom M. Mitchell, “Machine Learning’, MGH, 2017.

2

3 of 79

20AD04- MACHINE LEARNING

  • Pre-requisite :
    • Probability and Statistics
    • Data Warehousing and Data Mining

  • Course Educational Objective:
  • The objective of the course is to provide the basic concepts and techniques of Machine Learning and helps to use machine learning algorithms for solving real world problems. It enables students to gain experience by doing independent study and research.

3

4 of 79

Course Outcomes:

At the end of this course, the student will be able to

  • CO1: Understand development steps of model building and evaluation approaches. (Understand- L2)
  • CO2: Apply Nearest Neighbor-based models to solve real-time regression and classification problems (Apply- L3)
  • CO3: Make use of supervised learning algorithms to solve classification problems. (Apply- L3)
  • CO4: Apply linear discriminants and perceptron classifiers to classify datasets. (Apply- L3)
  • CO5: Apply various clustering techniques to solve complex problems. (Apply- L3)

5 of 79

UNIT-I: SYLLABUS

Introduction to Machine Learning:

  • Evolution of Machine Learning, Paradigms for ML, Learning by Rote, Learning by Induction, Reinforcement Learning, Types of Data, Matching, Stages in Machine Learning, Data Acquisition, Feature Engineering, Data Representation, Model Selection, Model Learning, Model Evaluation, Model Prediction, Search and Learning, Data Sets.

6 of 79

Introduction:

What is ‘Artificial Intelligence?

  • Definition :The effort to automate intellectual tasks normally performed by humans. As such, AI is a general field that encompasses machine learning and deep learning.

(or)

  • Definition: Artificial Intelligence is composed of two words Artificial and Intelligence, where Artificial defines "man-made," and intelligence defines "thinking power", hence AI means "a man-made thinking power."
  • Artificial Intelligence exists when a machine can have human based skills such as learning, reasoning, and solving problems.

6

12/13/2025

7 of 79

ARTIFICIAL INTELLIGENCE, MACHINE LEARNING, AND DEEP LEARNING

7

12/13/2025

8 of 79

WHAT IS MACHINE LEARNING?

  • Do machines really learn?
  • If so, how do they learn?
  • Which problem can we consider as a well-posed learning problem?
  • What are the important features that are required to well-define a learning problem?

  • Tom M. Mitchell, Professor of Machine Learning Department, School of Computer Science, Carnegie Mellon University defined Machine Learning as:

‘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.’

  • It means that a machine can be considered to learn if it is able to gather experience by doing a certain task and improve its performance in doing the similar tasks in the future.

9 of 79

MACHINE LEARNING:

  • Definition Machine Learning is:

“A computer program is said to learn from experience E with respect to a task T and performance measure P if its performance at task T improves with experience E.”

(or)

Machine Learning is a technique where computers learn from examples (data) and improve their performance automatically.

Figure. ML Paradigm

5 / 38

10 of 79

10

12/13/2025

11 of 79

1.2 WHAT IS MACHINE LEARNING? Cont…

  • Eg-1: 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.
  • Eg-2: 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 and
    • P is the performance measure indicated by the percentage of images correctly classified.

12 of 79

1.2.1 How do machines learn? Cont…

For example, a broad pool of knowledge may consist of all living animals and their characteristics such as

    • whether they live in land or water,
    • whether they lay eggs
    • whether they have scales or fur or none,etc.
  • It is a difficult task for any student to memorize the characteristics of all living animals.
  • It is better to draw a notion about the basic groups that all living animals belong to and the characteristics which define each of the basic groups.
    • The basic groups of animals are invertebrates and vertebrates.
    • Vertebrates are further grouped as mammals, reptiles, amphibians, fishes, and birds.

13 of 79

ML vs. Deep Learning (cont’d)

  • Deep learning (DL) is a machine learning subfield that uses multiple layers for learning data representations.
  • Deep learning is a form of Representation learning as the problem you are trying to do is dealing with the raw inputs, mapping it in such a way that the final representation is easier to work with, to classify, and to generate new samples of that data

    • DL is exceptionally effective at learning patterns

14 of 79

ML vs. Deep Learning (Cont’d)

14

12/13/2025

15 of 79

Evolution of Machine Learning

16 of 79

Evolution of Machine Learning

17 of 79

1.3 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.

18 of 79

Machine Learning Types:

  • Supervised: learning with labeled data
    • Example: email classification, image classification
    • Example: regression for predicting real-valued outputs
  • Unsupervised: discover patterns in unlabeled data
    • Example: cluster similar data points
  • Reinforcement learning: learn to act based on feedback/reward

class A

class B

Classification

Regression

Clustering

19 of 79

1.3 TYPES OF MACHINE LEARNING Cont….

Supervised learning

  • The name suggests, Supervised machine learning is based on supervision. It means in the supervised learning technique, we train the machines using the "labelled" dataset, and based on the training, the machine predicts the output.
  • The labelled data specifies that some of the inputs are already mapped to the output. More preciously, we can say; first, we train the machine with the input and corresponding output, and then we ask the machine to predict the output using the test dataset.
  • Eg: we have an input dataset of cats and dog images. So, first, we will provide the training to the machine to understand the images, such as the shape & size of the tail of cat and dog, Shape of eyes, colour, height (dogs are taller, cats are smaller), etc. 
  • The tag is called ‘ label’ and we say that the training data is labelled in case of supervised learning.

20 of 79

1.3 TYPES OF MACHINE LEARNING Cont….

1.3.1 Supervised learning

  • 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.
  • 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.

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

21 of 79

1.3.1 SUPERVISED LEARNING Cont….

1.3.1.1 Classification

  • In classification, the whole problem revolves around assigning a label or category or class to a test data based on the label or category or class information that is imparted by the training data.
  • classification problems in which the output variable is categorical, such as "Yes" or No, Male or Female, Red or Blue, etc. .

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
  • Identification of fraudulent transactions in banking

22 of 79

1.3.1 SUPERVISED LEARNING Cont….

1.3.1.2 Regression

  • In linear regression, the objective is to predict numerical features like real estate or stock price, temperature, marks in an examination, sales revenue, etc.
  • regression problems in which there is a linear relationship between input and output variables.
  • In case of linear regression, a straight line relationship is ‘fitted’ between the predictor variables and the target variables, using the statistical concept of least squares method.
  • The sum of square of error between actual and predicted values of the target variable is tried to be minimized.
  • In simple linear regression, there is only one predictor variable whereas in multiple linear regression, multiple predictor variables can be included in the model.
  • Eg: sales prediction for the next year based on sales figure of previous years vis-à-vis investment being put in.

Solution: A simple linear regression model can be applied with investment as predictor variable and sales revenue as the target variable.

A typical linear regression model can be represented in the form –

where x’ is the predictor variable and ‘y’ is the target variable.

23 of 79

1.3.1 SUPERVISED LEARNING Cont….

1.3.1.2 Regression

Eg: The Iris data set is typically used as a training data for solving the classification problem of predicting the flower species based on feature values.

  • We can also demonstrate regression using this data set, by predicting the value of one feature using another feature as predictor.
  • petal length is a predictor variable which, when fitted in the simple linear regression model, helps in predicting the value of the target variable sepal length.

Applications of regression:

  • Demand forecasting in retails
  • Sales prediction for managers
  • Price prediction in real estate
  • Weather forecast
  • Skill demand forecast in job market

24 of 79

Supervised Learning:

  • Supervised learning categories and techniques
    • Numerical classifier functions
      • Linear classifier, perceptron, logistic regression, support vector machines (SVM), neural networks
    • Parametric (probabilistic) functions
      • Naïve Bayes, Gaussian discriminant analysis (GDA), hidden Markov models (HMM), probabilistic graphical models
    • Non-parametric (instance-based) functions
      • k-nearest neighbors, kernel regression, kernel density estimation, local regression
    • Symbolic functions
      • Decision trees, classification and regression trees (CART)
    • Aggregation (ensemble) learning
      • Bagging, boosting (Adaboost), random forest

25 of 79

�Applications of Supervised Learning�

  • Image Segmentation: In this process, image classification is performed on different image data with pre-defined labels.
  • Medical Diagnosis: It is done by using medical images and past labelled data with labels for disease conditions. With such a process, the machine can identify a disease for the new patients.
  • Fraud Detection - Supervised Learning classification algorithms are used for identifying fraud transactions, fraud customers, etc. It is done by using historic data to identify the patterns that can lead to possible fraud.
  • Spam detection - In spam detection & filtering, classification algorithms are used. These algorithms classify an email as spam or not spam. The spam emails are sent to the spam folder.
  • Speech Recognition - Supervised learning algorithms are also used in speech recognition. The algorithm is trained with voice data, and various identifications can be done using the same, such as voice-activated passwords, voice commands, etc.

26 of 79

1.3.2 UNSUPERVISED LEARNING

  • The name suggests, there is no need for supervision. It means, in unsupervised machine learning, the machine is trained using the unlabeled dataset, and the machine predicts the output without any supervision.
  • In unsupervised learning, the models are trained with the data that is neither classified nor labelled, and the model acts on that data without any supervision.
  • Clustering is the main type of unsupervised learning.
    • It intends to group or organize similar objects together.
    • The objective of clustering to discover the intrinsic grouping of unlabelled data and form clusters,
    • Different measures of similarity can be applied for clustering.
    • Eg: Distance based clustering

27 of 79

1.3.2 UNSUPERVISED LEARNING Cont…

  • One more variant of unsupervised learning is association analysis.
  • Eg: market basket analysis
    • 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.

28 of 79

Unsupervised Learning

  • Unsupervised learning categories and techniques
    • Clustering
      • k-means clustering
      • Mean-shift clustering
      • Spectral clustering
    • Density estimation
      • Gaussian mixture model (GMM)
      • Graphical models
    • Dimensionality reduction
      • Principal component analysis (PCA)
      • Factor analysis

29 of 79

�Applications of Unsupervised Learning�

  • Network Analysis: Unsupervised learning is used for identifying plagiarism and copyright in document network analysis of text data for scholarly articles.
  • Recommendation Systems: Recommendation systems widely use unsupervised learning techniques for building recommendation applications for different web applications and e-commerce websites.
  • Anomaly Detection: Anomaly detection is a popular application of unsupervised learning, which can identify unusual data points within the dataset. It is used to discover fraudulent transactions.
  • Singular Value Decomposition: Singular Value Decomposition or SVD is used to extract particular information from the database. For example, extracting information of each user located at a particular location.

30 of 79

�Semi-Supervised Learning�

  • Semi-Supervised learning is a type of Machine Learning algorithm that lies between Supervised and Unsupervised machine learning.
  • It represents the intermediate ground between Supervised (With Labelled training data) and Unsupervised learning (with no labelled training data) algorithms and uses the combination of labelled and unlabeled datasets during the training period.
  • The main aim of semi-supervised learning is to effectively use all the available data, rather than only labelled data like in supervised learning.

31 of 79

1.3.2 REINFORCEMENT LEARNING

  • We have seen babies learn to walk without any prior knowledge.
    • First they notice somebody else walking around.
    • They understand that legs have to be used, one at a time, to take a step.
    • While walking, sometimes they fall down hitting an obstacle, whereas other times they are able to walk smoothly avoiding bumpy obstacles.
    • When they are able to walk overcoming the obstacle, their parents are elated and appreciate the baby with loud claps / or may be a chocolates.
    • Reinforcement learning works on a feedback-based process, in which an AI agent (A software component) automatically explore its surrounding by hitting & trail, taking action, learning from experiences, and improving its performance.
    • Agent gets rewarded for each good action and get punished for each bad action; hence the goal of reinforcement learning agent is to maximize the rewards.

32 of 79

1.3.2 REINFORCEMENT LEARNING

  • Machines often learn to do tasks autonomously.
  • Eg: Baby or child learn walking autonomously
  • The action tried to be achieved is walking.
  • The child is the agent.
  • The place with hurdles on which the child is trying to walk resembles the environment.
  • It tries to improve its performance of doing the task.
  • When a sub-task is accomplished successfully, a 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.
  • In reinforcement learning, there is no labelled data like supervised learning, and agents learn from their experiences only.

33 of 79

1.3.2 REINFORCEMENT LEARNING

  • 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.

34 of 79

1.3.2 Comparison of Supervised, Unsupervised and Reinforcement Learning

35 of 79

1.3.2 Comparison of Supervised, Unsupervised and Reinforcement Learning Cont…

36 of 79

1.4 Applications of Machine Learning

  • Banking and finance
  • Insurance
  • Healthcare
  • Image Recognition
  • Speech Recognition
  • Traffic prediction
  • Product recommendations
  • Self-driving cars
  • Email Spam and Malware Filtering
  • Virtual Personal Assistant
  • Automatic Language Translation

37 of 79

Seven steps in Machine Learning :

1. Gathering Data

  • Deciding what “data” means is part of problem

2. Preparing Data

  • Ensuring that there is no bias

3. Choosing a Model/ Algorithm

  • Example: Random Forest, ANN’s , Hidden Markov Models, etc

4. Training

  • Using data to determine model parameters

5. Evaluation-How well did we do? (testing phase)

6. Hyper parameter tuning

7. Prediction -> Deployment

37

12/13/2025

38 of 79

1.6 Machine Learning Activities

Preparation activities to be done on the input data:

  • 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, etc., if needed.
  • Apply pre-processing steps, as necessary
  • Once the data is prepared for modelling, then the learning tasks start off by doing 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.
  • After the model is selected, trained (for supervised learning), and applied on input data, the performance of the model is evaluated. Based on options available, specific actions can be taken to improve the performance of the model, if possible.

39 of 79

1.6 Machine Learning Activities Cont…

Fig. Detailed process of machine learning

40 of 79

1.6 Machine Learning Activities Cont…

Table. Activities in Machine Learning

41 of 79

1.7 BASIC TYPES OF DATA IN MACHINE LEARNING

  • Each row of a data set is called a record.
  • Each data set also has multiple attributes, each of which gives information on a specific characteristic.
  • Attributes can also be termed as feature, variable, dimension or field.

FIG. Student data set

FIG. Data set records and attributes

42 of 79

Learning by Rote

  • Learning by Rote means memorizing the training data exactly as it is, without understanding or generalizing.
  • Learning by Rote is a simple memorization-based learning method where the system stores training examples exactly and retrieves them when the same input appears again.

Working of Learning by Rote

  • Learning by Rote follows a store-and-retrieve mechanism.

Step-by-Step Working

  • Store Training Examples
    • The system memorizes each input–output pair.�Example: (“apple”, “fruit”), (“carrot”, “vegetable”)
  • Match New Input
    • When a new input comes, the system checks if it exactly matches any stored input.
  • Retrieve Output
    • If a match is found, the corresponding output is retrieved and returned.
  • No Generalization
    • If no match exists, the system cannot answer because it did not learn patterns, only memorized.

42

12/13/2025

43 of 79

Benefits of Learning by rote:

  • Rote learning can save time compared to re-computing values.
  • It is also used to establish a foundational understanding of basic concepts.
  • Ex: Recalling the multiplication tables, periodic tables, formulas etc.

Learning by Induction:

  • learning by Induction is a method where the machine learns general rules or patterns from specific training examples and uses these rules to predict outcomes for new data.

Training examples:

  • Bird → can fly
  • Sparrow → can fly
  • Eagle → can fly
  • The model learns the general rule

44 of 79

1.7 BASIC TYPES OF DATA IN MACHINE LEARNING Cont...

Data can broadly be divided into two types:

1. Qualitative data

2. Quantitative data

  • Qualitative data provides information about the quality of an object or information which cannot be measured.
  • Qualitative data is also called categorical data.
  • Eg: name or roll number of students are information that cannot be measured using some scale of measurement.
  • Qualitative data can be further subdivided into two types
    • 1. Nominal data
    • 2. Ordinal 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.

Eg: 1. Blood group: A, B, O, AB, etc.

2. Nationality: Indian, American, British, etc.

3. Gender: Male, Female, Other

  • Mathematical operations cannot be performed on nominal data. So, statistical functions such as mean, variance, etc. can also not be applied on nominal data.
  • However, a basic count is possible. So mode, i.e. most frequently occurring value, can be identified for nominal data.

45 of 79

1.7 BASIC TYPES OF DATA IN MACHINE LEARNING Cont...

  • Ordinal data, in addition to possessing the properties of nominal data, can also be naturally ordered.
  • This means 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.

Eg:

1. Customer satisfaction: ‘Very Happy’, ‘Happy’, ‘Unhappy’, etc.

2. Grades: A, B, C, etc.

3. Hardness of Metal: ‘Very Hard’, ‘Hard’, ‘Soft’, etc.

  • Basic counting is possible for ordinal data. Hence, the mode can be identified.
  • Median, and quartiles can be identified in addition. Mean can still not be calculated.

46 of 79

1.7 BASIC TYPES OF DATA IN MACHINE LEARNING Cont...

  • Quantitative data relates to information about the quantity of an object – hence it can be measured.
  • Quantitative data is also termed as numeric data.
  • For example, if we consider the attribute ‘marks’, it can be measured using a scale of measurement.
  • There are two types of quantitative data:

1. Interval data

2. Ratio data

  • Interval data is numeric data for which not only the order is known, but the exact difference between values is also known.
    • Eg: Celsius temperature, date, time etc.
  • For interval data, mathematical operations are possible. So mean, median, mode and standard deviation can also be calculated.
  • Interval data do not have ‘true zero’ value.
  • Hence, only addition and subtraction applies for interval data. The ratio cannot be applied.
  • Eg: we can say a temperature of 40°C is equal to the temperature of 20°C + temperature of 20°C.
  • However, we cannot say the temperature of 40°C means it is twice as hot as in temperature of 20°C.

47 of 79

1.7 BASIC TYPES OF DATA IN MACHINE LEARNING Cont...

  • Ratio data represents numeric data for which exact value can be measured.
  • Absolute zero is available for ratio data.
  • Also, these variables can be added, subtracted, multiplied, or divided.
  • The central tendency can be measured by mean, median, or mode and methods of dispersion such as standard deviation.
  • Examples of ratio data include height, weight, age, salary, etc.

48 of 79

Types of DATA

The data can be both Numeric or quantitative and Categorical or Qualitative in nature.

Numeric or Quantitative data is in numeric form , which can be discrete that includes finite numerical values or continuous which also takes fractional values apart from finite values. For instance, the number of girls in a class can only take finite values, so it is a discrete variable, while the cost of a product is a continuous variable.

Categorical or Qualitative data is not-numerical which can be based on methods such as interviews, grades given in an exam etc. It can be nominal and ordinal, where nominal data does not contains any order such as the gender, marital status, while ordinal data has a particular order such as ratings of a movie, sizes of a shirt.

49 of 79

� Numeric or Quantitative data

Discrete: A variable that can only take a certain number of values (either text or numbers). For example, the variable Color where values could be black, blue, red, yellow, and so on, or the variable Score where the variable can only take values 1, 2, 3, 4, or 5.

Continuous: A variable where an infinite number of numeric values are possible within a specific range. An example of a continuous value is temperature where between the minimum and maximum temperature, the variable could take any value.

50 of 79

  • Few examples of this category are:
    • Whole numbers or Natural Numbers
    • The number of laptops you own, (here you will definitely have an integer as an answer, no one can say that it has 1.1 laptops, it will be obviously 1, 2, 3, etc.)
    • The number of shirts you have.
    • The number of houses you own.
    • The number of vehicles you own.
    • The number of children in the family.
    • The number of pets in the family.
    • The number of bank accounts one has.

Discrete

51 of 79

  • Few examples of this category are:
    • The amount of your postpaid mobile bill. (Generally, it is not an integer, it is like 500.50, etc)
    • Total time spent on watching a web series (120.5 seconds, etc)
    • Total amount spent on ordering food online (1500.57 INR, etc)
    • The interest rate on loan.
    • Weight of an individual. (It is not always an integer, mostly it is like 90.5 kg, etc)

Continuous

52 of 79

Measures of Central Tendency

  • An essential statistical concept is the “measure of central tendency“. This measure is an important way to summarize the dataset with one representative value.
  • This measure provides a rough picture of where data points are centered. The commonly used measures of central tendency are:
    • Mean
    • Median
    • Mode

53 of 79

Mean�

  • “Average” value is termed as the mean of the dataset. It is very easy to calculate the mean.
  • Steps to calculate Mean:
    • Step 1. Count the number of data values. Let it be n.
    • Step 2. Add all the data values. Let the sum be s.
    • Step 3. Mean = Sum of all data values (s)/Total number of data values(n)

54 of 79

Median��

  • The middle value of the sorted dataset is called the median. Consider a dataset comprising ‘n’ elements.
  • Steps to calculate median:
    • Step 1. The dataset is arranged in either increasing or decreasing order.
    • Step 2. If the data set has an odd number of data values (n=odd), then the middlemost value of the sorted dataset is computed as the median. In other words, the data at (n + 1)/2 place is the median of the dataset.
    • Step 3. If the dataset has an even number of data values (n = even), the average of two middle values is computed as the median. i.e. mean of (n/2) and {(n/2) + 1}th is the median of the dataset.

55 of 79

Mode��

  • The most frequently occurring value in the dataset is called mode.

  • Steps to calculate mode:

    • Step 1. Use tally marks to identify how many times each data value occurs in the dataset.
    • Step 2. The data value with maximum tally is the mode of the dataset.

56 of 79

  • Example 1. Consider the weight (in kg) of 5 children as 36, 40, 32, 42, 30. Let’s compute mean, median, and mode:
  • Solution:
  • Mean = (36 + 40 + 32 + 42 + 30)/5 = 180/5 = 36kg
  • Median: Arrange the data in ascending order: 30, 32, 36, 40, 42 The middle value is 36. So, median = 36kg.
  • Mode: 36 kg occurs most number of times, so mode = 36 kg
  • In this example, we saw that mean, median and mode are same.
  • Example 2. Consider the ages of five employees as 30, 30, 32, 38, 60 years. Calculate the measures of central tendency.
  • Solution:
  • Mean = (30 + 30 + 32 + 38 + 60)/5 = 190/5 = 38 years
  • Median: Arrange the data in ascending order: 30, 30, 32, 38, 60. The middlemost value is 32. So, median = 32 years
  • Mode: 30 years occurs most number of ties, so mode = 30 years
  • In this example, we saw that mean, median and mode have different values.

57 of 79

  • Example 3. Five students A, B, C, D, E appeared in a test and scored 80, 95, 90, 85, and 100 marks respectively. Find the mean?
  • Solution:
  • Total number of students = 5
  • Sum of marks = 80 + 95 + 90 + 85 +100 = 450
  • Mean = Sum of marks/total number of students = 450/5 = 90 marks
  • Example 4. A batsman scores an average of 48 runs in six matches. If his score in five matches is 51, 45,46, 44, and 49. Find his score in the sixth match?
  • Solution:
  • Total number of matches = 6
  • Assume his score in sixth match = x runs
  • Average = 48 runs
  • So, (51 + 45 + 46 + 44 + 49 + x)/6 = 48
  • So, 235 + x = 48 x 6 = 288 = 235 + x = 288 , x = 288 – 235 = 53, He scores 53 runs in sixth match.

58 of 79

  • Example 5. The average of five consecutive odd numbers is 15. Find the numbers?
  • Solution:
  • Assume the smallest odd number be x.
  • So, the other numbers are x + 2, x + 4, x + 6, x + 8
  • Given that the average = 15.
  • So, (x + x + 2 + x + 4 + x + 6 + x + 8)/5 = 15
  • = 5x + 20 = 75 = 5x = 55 ,
  • x = 55/5 = 11 ,
  • So, the numbers are 11, 13, 15, 17, 19

59 of 79

  • Example 6. A teacher reported a mean of 35 marks in a class of 20 students. Later she realized that marks of a student were actually 45, but by mistake, she had written as 25. Find the correct mean marks of the class.
  • Solution:
  • Mean = 35
  • Number of students = 20
  • So, total sum of marks = 35 × 20 = 700
  • Corrected sum of marks = 700 – 25 + 45 = 720
  • So, average = 720/20 = 36
  • Correct mean = 36 marks

60 of 79

  • Dataset used — Heights of seven Bodybuilders(Assumed Discrete Series)

61 of 79

62 of 79

63 of 79

64 of 79

1.8 EXPLORING STRUCTURE OF DATA

  • The data set that we take as a reference is the Auto MPG data set available in the UCI repository.
  • The attributes ‘mpg’, ‘cylinders’, ‘displacement’, ‘horsepower’, ‘weight’, ‘acceleration’, ‘model year’, and ‘origin’ are all numeric.
  • Out of these attributes, ‘cylinders’, ‘model year’, and ‘origin’ are discrete in nature.
  • ‘mpg’, ‘displacement’, ‘horsepower’, ‘weight’, and ‘acceleration’ are continuous in nature.
  • ‘car name’ is of type categorical, or more specifically nominal
  • This data set is regarding prediction of fuel consumption in miles per gallon, i.e. the numeric attribute ‘mpg’ is the target attribute.

65 of 79

1.8.1 EXPLORING NUMERIC DATA

  • There are two most effective mathematical plots to explore numerical data – box plot and histogram.
  • To understand the nature of numeric variables, we can apply the measures of central tendency of data, i.e. mean and median.
  • In the context of the Auto MPG data set, let’s try to find out for each of the numeric attributes the values of mean, median and the deviation between these values.
  • For the attributes ‘mpg’, ‘weight’, ‘acceleration’, and ‘model year’ the deviation between mean and median is not significant i.e., the chance of these attributes having too many outlier values is less.
  • The deviation is significant for the attributes ‘cylinders’, ‘displacement’ and ‘origin’. So, we need to further drill down and look at some more statistics for these attributes

66 of 79

1.8.1 EXPLORING NUMERIC DATA Cont…

  • we can find out that the problem is occurring because of the 6 data elements, as shown in Figure as they do not have value for the attribute ‘horsepower’.
  • For that reason, the attribute ‘horsepower’ is not treated as a numeric. That’s why the operations applicable on numeric variables, like mean or median, are failing.

67 of 79

1.8.1 EXPLORING NUMERIC DATA Cont…

  • We need to look at the entire range of values of the attributes.
  • We will take a granular view of the data spread in the form of

1. Dispersion of data

2. Position of the different data values

1. Measuring Dispersion of data

  • Consider the data values of two attributes

1. Attribute 1 values : 44, 46, 48, 45, and 47

2. Attribute 2 values : 34, 46, 59, 39, and 52

  • Both the set of values have a mean and median of 46.
  • However, the first set of values that is of attribute 1 is more concentrated or clustered around the mean/median value whereas the second set of values of attribute 2 is quite spread out or dispersed.
  • To measure the extent of dispersion of a data, or to find out how much the different values of a data are spread out, the variance of the data is measured.

Understanding data spread

68 of 79

1.8.1 EXPLORING NUMERIC DATA Cont…

  • Larger value of variance or standard deviation indicates more dispersion in the data and vice versa.
  • In the above example, for attribute 1,

69 of 79

Machine Learning Life Cycle

It consists of seven phases

  • Data Collection
  • Data Preparation
  • Data Wrangling
  • Model Selection
  • Model Training
  • Model Evaluation
  • Deployment

70 of 79

Data Collection:

  • This phase gathers raw data from various sources such as databases, sensors, files, and the internet.�The quality and quantity of the data determine the model's performance.
  • The more data will give more accurate and prediction.

Data Preparation (Data Cleaning)

  • Raw data is cleaned by handling missing values, removing noise, and correcting inconsistencies.
  • This step also involves transforming data into a usable format.
  • It ensures the dataset is accurate, consistent, and reliable for training.

Feature Engineering & Selection

  • Important features are identified, created, or transformed to improve model learning.
  • Unnecessary or irrelevant features are removed to reduce complexity.
  • Good features help the model perform better and faster.

71 of 79

Model Selection

  • An appropriate ML algorithm is chosen based on data type and problem type.
  • Options include classification, regression, clustering, or deep learning models.�Choosing the right model improves accuracy and efficiency.

Model Training

  • The model learns patterns from the training dataset by adjusting parameters.
  • Training aims to minimize error and improve prediction ability.�This step builds the core intelligence of the ML system.

Model Evaluation

  • The trained model is tested using unseen data to check its performance.�Metrics like accuracy, precision, recall, F1-score, or RMSE are used.�This phase ensures the model can generalize well to new data.

72 of 79

Deployment & Monitoring

  • The model is deployed into a real-world application such as a website, app, or cloud service.
  • Its performance is continuously monitored for accuracy and reliability.
  • Retraining is done if data changes or performance drops.

73 of 79

Data Acquisition:

  • Data Acquisition is the process of gathering raw data from various sources such as databases, sensors, files, and APIs.
  • Cleaning the data to handle missing, inconsistent or noise entries.
  • Splitting the data into training and validation & test sets.

Steps Involved in Data Acquisition

  • Identify the data requirement — what type of data the ML problem needs
  • Select data sources — internal/external
  • Collect data — manually or automatically
  • Validate data — check accuracy, correctness, and completeness
  • Store data — databases, cloud storage, data warehouses

74 of 79

Feature Engineering:

  • Feature Engineering is the process of transforming raw data into meaningful input features that improve a machine learning model’s performance.
  • It involves feature selection, transformation, and creation. Effective feature engineering enhances accuracy, reduces complexity, and helps the model learn relevant patterns.

Steps Involved in Data Acquisition

  • Feature Selection Choosing only the most important attributes from the dataset to avoid noise and reduce complexity.
  • Feature Transformation Standardization, normalization, scaling, encoding categorical data, etc.
  • Feature Creation Making new features such as combining columns, extracting date parts, creating ratios, or applying domain knowledge.

75 of 79

Data Representations:

  • Data representation in ML means organizing and visualizing data in a clear form—such as tables, charts, and graphs—so that patterns, trends, and relationships can be easily understood.
  • It helps both humans and ML models interpret the data effectively learn the relevant patterns.

Bar Chart

  • A bar chart uses rectangular bars to show comparisons between different categories.
  • The height or length of each bar represents the value or frequency.
  • It is useful for visualizing categorical or discrete data

Histogram

  • A histogram shows the distribution of continuous numerical data.�Data is divided into intervals (bins), and the height of each bar shows frequency.
  • It helps identify patterns like skewness, spread, and outliers.

76 of 79

Pie Chart

  • A pie chart represents parts of a whole using slices of a circle.
  • Each slice’s size corresponds to its proportion or percentage.
  • Useful for showing category-wise contribution in a dataset

Frequency Distribution Table

  • A frequency distribution table lists data values or ranges alongside their frequencies.
  • It organizes large datasets into simple tabular form.
  • It Helps understand how often each value or group occurs.

Line Graph

  • A line graph shows data points connected by lines, usually over time.
  • It is used to observe trends, changes, and patterns.
  • Suitable for continuous, time-series, or sequential data.

77 of 79

Scatter Plot

  • A scatter plot displays relationships between two numerical variables.
  • Each point represents one observation on an x–y coordinate system.
  • It helps identify correlations, clusters, and outliers.

78 of 79

  • Model Selection: Choosing the most suitable algorithm or model for a specific problem based on data type, complexity, and performance criteria.
  • Model Learning: Training the selected model on data to learn patterns and relationships by adjusting its parameters.
  • Model Evaluation: Assessing the trained model’s performance using metrics like accuracy, precision, recall, or loss on validation/test data.
  • Model Prediction: Using the trained model to make predictions or infer outcomes on new, unseen data.
  • Search and Learning: Exploring different model architectures, hyper-parameters, or optimization strategies to improve learning and performance.
  • Data Sets: Collections of structured or unstructured data (training, validation, test) used to train, tune, and evaluate machine learning models.

79 of 79

Unit-1 Question Bank

  1. Define machine learning. Explain the process of machine learning with relevant examples.
  2. Discuss various types of machine learning with examples.
  3. Explain various types of supervised learning techniques with neat sketch and example.
  4. Explain various types of un-supervised learning techniques with neat sketch and example.
  5. Illustrate about reinforcement learning with an example.
  6. Differentiate between different machine learning techniques.
  7. List the applications and issues in machine learning.
  8. Explain various machine learning activities with relevant examples
  9. Discuss various basic data types in machine learning with examples.
  10. Explain the data preprocessing techniques with examples.