Module 1 ML
Module 1 ML
1)Discuss Machine Learning. Explain its relationship to other fields with diagram
Machine Learning
• It frequently quoted definition of machine learning was by Arthur Samuel, one of the pioneers of Artificial
Intelligence.
• He stated that:
"Machine learning is the field of study that gives the computers ability to learn without being explicitly programmed."
• The key to this definition is that the systems should learn by itself without explicit programming.
• Machine learning is a branch of AI which aims to develop intelligent systems by learning from examples and
experience.
• The focus of AI is to develop intelligent systems by using data-driven approach, where data is used as an input
to develop intelligent models.
• Thus, the aim of machine learning is to learn a model or set of rules from the given dataset so that it can
predict the unknown data correctly.
• Artificial Intelligence
• Data Science
• Statistics primarily
• Initially, the idea of AI was ambitious, that is, to develop intelligent systems like Human beings.
• These moved down over the years and came under AI wrappers.
• Machine learning is the subbranch of AI, whose aim is to extract the patterns for prediction.
Module 1
• It is a broad field that includes learning from examples and also areas like reinforcement learning.
Artificial Intelligence
_______________________
Machine Learning
__________________
Deep Learning
______________
Big Data
• Big data is a field of data science that deals with following characteristics:
o Volume
o Variety
o Velocity
Data Mining
• Like while mining the earth one gets into precious resources, it is often believed that unearthing of the data
produces hidden information that otherwise would have eluded the attention of the management.
• Nowadays, many consider that data mining and machine learning are same.
• There is no difference between these fields except that data mining aims to extract the hidden patterns that are
present in the data, whereas machine learning aims to use it for prediction.
Data Analytics
• Machine learning is closely related to this branch of analytics and shares almost all algorithms.
Pattern Recognition
• It is an engineering field.
• It uses machine learning algorithms to extract the features for pattern analysis and pattern classification.
Data Science
-----------------------------------
| | |
Pattern Recognition
• Statistics is a branch of mathematics that has solid theoretical foundation regarding statistical learning.
• But the difference between statistics and ML is that statistical methods look for regularity in data collection.
• Initially, statistics use hypothesis and perform experiments to verify and validate the hypothesis in order to find
relationships in data.
• Statistics requires knowledge of statistical procedures and the guidance of a good statistician.
• It is mathematics intensive and does depend on complicated equations and involve many assumptions.
• It has strong theoretical foundation and interpretations that require a strong statistical knowledge.
• Machine learning, comparatively, has less assumptions and requires less statistical knowledge.
• But, it often requires interaction with various tools to automate the process of learning.
• Nevertheless, there is a school of thought that machine learning is just the latest version of old Statistics and
hence this relationship should be recognized.
Module 1
Source: Uploaded Machine Learning Textbook
• What does the word 'learn' mean? Learning, like adaptation, occurs as the result of interaction of the program
with its environment.
Machine Learning
------------------------------------------------
| | | |
| |
------------ ----------------
| | | | |
analysis reduction
1. Supervised Learning
First stage
• The teacher communicates the information to the student that the student is supposed to master.
• During this stage, the teacher has no knowledge of whether the information is grasped by the student.
Second stage
• The teacher then asks the student a set of questions to find out how much information has been grasped by
the student.
• Based on these questions, the student is tested, and the teacher informs the student about his assessment.
2. Regression
Classification
• The input attributes of the classification algorithms are called independent variables.
• The relationship between the input and target variable is represented in the form of a structure which is called
a classification model.
• Decision Tree
• Random Forest
• Naive Bayes
Regression Models
• Regression models, unlike classification algorithms, predict continuous variables like price.
2. Unsupervised Learning
• In the absence of a supervisor or teacher, self-instruction is the most common kind of learning process.
• Here, the program is supplied with objects, but no labels are defined.
• The algorithm itself observes the examples and recognizes patterns based on the principles of grouping.
• Cluster analysis and Dimensional reduction algorithms are examples of unsupervised algorithms.
Cluster Analysis
• k-means algorithm
Module 1
• Hierarchical algorithms
Dimensional Reduction
• It takes a higher dimension data as input and outputs the data in lower dimensions by taking advantage of the
variance of the data.
3. Semi-supervised Learning
• There are circumstances where the dataset has a huge collection of unlabelled data and some labelled data.
4. Reinforcement Learning
• Like human beings use ears and eyes to perceive the world and take actions, reinforcement learning allows the
agent to interact with the environment to get rewards.
• When the rewards are more, the behavior gets reinforced and learning becomes possible.
• In computer systems, bits encode facts present in numbers, text, images, audio, and video.
• Data can be directly human interpretable (such as numbers or texts) or diffuse data such as images or video
that can be interpreted only by a computer.
Module 1
• Today, business organizations are accumulating vast and growing amounts of data of the order of gigabytes,
tera bytes, exabytes and zetta bytes.
• A bit is 8 bits.
• A bit is either 0 or 1.
• 1000 giga bytes is one tera byte and 1000000 tera bytes is one Exa byte.
• Only when a label is attached like height of students of a class, the data becomes meaningful.
• Processed data is called information that includes patterns, associations, or relationships among data.
1. Volume
• Since there is a reduction in the cost of storing devices, there has been a tremendous growth of data.
• Small traditional data is measured in terms of gigabytes (GB) and terabytes (TB), but Big Data is measured in
terms of petabytes (PB) and exabytes (EB).
2. Velocity
• The fast arrival speed of data and increase in data volume is noted as velocity.
• The availability of IoT devices and Internet power ensures that the data is arriving at a faster rate.
• Velocity helps to understand the relative growth of big data and its accessibility by users, systems and
applications.
3. Variety
Form
• There can be composite data too, where one media can have many other sources of data, for example, a video
can have an audio song.
Module 1
Function
• These are data from various sources like human conversations, transaction records, and old archive data.
Source of data
• Broadly, the data source can be classified as open/public data, social media data and multimodal data.
4. Veracity
• Veracity of data deals with aspects like conformity to the facts, truthfulness, believability, and confidence in
data.
• There may be many sources of error such as technical errors, typographical errors, and human errors.
5. Validity
• Validity is the accuracy of the data for taking decisions or for any other goals that are needed by the given
problem.
6. Value
• Value is the characteristic of big data that indicates the value of the information that is extracted from the data
and its influence on the decisions that are taken based on it.
• In real world, the available data is 'dirty'. By this word 'dirty', it means:
o Incomplete data
o Outlier data
o Inaccurate data
o Duplicate data
• The process of detection and removal of errors in data is called data cleaning.
• Data wrangling means making the data processable for machine learning algorithms.
o Incorrect measurement
• Noise is a random component and involves distortion of a value or introduction of spurious objects.
• It can be observed that data like Salary = " " is incomplete data.
• The age of David is recorded as "5" but his DoB indicates it is 10/10/1980.
o Problems in conversions
o Inconsistent formats
o Difference in units
• Outliers are data that exhibit the characteristics that are different from other data and have very unusual
values.
Module 1
• The age of Raju cannot be 136.
• Outliers may be legitimate data and sometimes are of interest to the data mining algorithms.
• These must be removed so that machine learning algorithms yield better results as the quality of results is
determined by the quality of input data.
REGULAR PAPER
2. Huge data
• This is a primary requirement of machine learning.
• Availability of a quality data is a challenge.
• A quality data means it should be large and should not have data problems
such as missing data or incorrect data.
5. Bias/Variance
• Variance is the error of the model.
• This leads to a problem called bias/variance tradeoff.
• A model that fits the training data correctly but fails to test data is called
overfitting.
• The reverse problem is called underfitting where the model fails for training
data but has good generalization.
• Overfitting and underfitting are great challenges for machine learning
algorithms.
1. Bar Chart
• A Bar chart (or Bar graph) is used to display the frequency distribution for
variables.
Module 1
• Bar charts are used to illustrate discrete data.
• The charts can also help to explain the counts of nominal data.
• It also helps in comparing the frequency of different groups.
Example
• Student marks with Student ID (1,2,3,4,5) and marks (45,60,60,80,85).
2. Pie Chart
• These are equally helpful in illustrating the univariate data.
• The percentage frequency distribution of students marks
(22,22,40,40,70,70,85,90,90) is shown in Pie chart.
• The total number of students are represented as 100%.
Example
• Student marks:
22,22,40,40,70,70,85,90,90
3. Histogram
• Histograms convey useful information like nature of data and its mode.
• Mode indicates the peak of dataset.
• Histograms can be used as charts to show frequency, skewness present in the
data, and shape.
Example
• Student marks:
45,60,60,80,85
• Group ranges:
0–25, 26–50, 51–75, 76–100
4. Dot Plots
• These are similar to bar charts.
• They are less clustered as compared to bar charts.
Module 1
• The advantage is that by visual inspection one can find out what got more
marks.
Example
• Student marks for students with ID (1,2,3,4,5) and marks (45,60,60,80,85).
6. Q-Q Plot
• Most of the statistical tests are designed only for normal distribution of data.
• A Q-Q plot can be used to assess the shape of the distribution.
• The Q-Q plot is a 2D scatter plot of univariate data against theoretical normal
distribution.
Example
• Data:
x = [13 11 2 3 4 8 9]
• The quartiles of the first and second datasets are compared.
Module 1
You're correct. I should have followed your uploaded content exactly and preserved
the notation used in the textbook.
Source: Uploaded Machine Learning Textbook
3)For patients' age list {12,14,19,22,24,26,28,31,34}, find the IQR
Given:
Patients age list = {12,14,19,22,24,26,28,31,34}
Solution
• The median is in the fifth position.
• In this case,
[
24
]
is the median.
• The first quartile is median of the scores below the median i.e.,
[
{12,14,19,22}
]
• Hence, it is the median of the list below 24.
• In this case, the median is the average of the second and third values.
[
Q_{0.25}=16.5
]
• Similarly, the third quartile is the median of the values above the median, that
is,
[
{26,28,31,34}
]
• So,
[
Q_{0.75}
]
is the average of the seventh and eighth score.
Module 1
[
28+\frac{31}{2}
\frac{59}{2}
29.5
]
Hence, the IQR using Eq. (2.10) is:
IQR=Q_{0.75}-Q_{0.25}
[
=29.5-16.5
]
[
=13
]
Answer: IQR = 13
QUESTION BANK
Source: Uploaded Machine Learning Textbook
1)Applications of Machine Learning
• Machine Learning technologies are used widely now in different domains.
• Machine learning applications are everywhere.
• One encounters many machine learning applications in the day-to-day life.
1. Sentiment analysis
• This is an application of natural language processing (NLP) where the words of
documents are converted to sentiments like:
o Happy
o Sad
o Angry
• These are captured by emoticons effectively.
Module 1
• For movie reviews or product reviews, five stars or one star are automatically
attached using sentiment analysis programs.
2. Recommendation systems
• These are systems that make personalized purchases possible.
• For example:
o Amazon recommends users to find related books or books bought by
people who have the same taste like you.
o Netflix suggests shows or related movies of your taste.
• The recommendation systems are based on machine learning.
3. Voice assistants
• Products like:
o Amazon Alexa
o Microsoft Cortana
o Apple Siri
o Google Assistant
• are all examples of voice assistants.
• They take speech commands and perform tasks.
• These chatbots are the result of machine learning technologies.
Data
• All facts are data.
• Data can be numbers or text that can be processed by a computer.
• Today, organizations are accumulating vast and growing amounts of data with
data sources such as:
o Flat files
o Databases
o Data warehouses in different storage formats
Information
• Processed data is called information.
• This includes:
o Patterns
o Associations
o Relationships among data
• For example:
o Sales data can be analyzed to extract information like which is the fast
selling product.
Knowledge
• Condensed information is called knowledge.
• For example:
o The historical patterns and future trends obtained in the above sales
data can be called knowledge.
• Unless knowledge is extracted, data is of no use.
Module 1
Intelligence
• Knowledge is not useful unless it is put into action.
• Intelligence is the applied knowledge for actions.
• An actionable form of knowledge is called intelligence.
• Computer systems have been successful till this stage.
Wisdom
• The ultimate objective of the knowledge pyramid is wisdom.
• Wisdom represents the maturity of mind that is, so far, exhibited only by
humans.
You're right — my previous answer added outside information. Following your rule
(only use uploaded content, preserve wording, point-wise format):
Source: Uploaded Machine Learning Textbook
3)Differentiate between Structured Data and Unstructured Data
Structured Data Unstructured Data
In structured data, data is stored in an organized
Unstructured data includes
manner such as a database where it is available in the
Module 1
Structured Data Unstructured Data
form of a table. video, image, and audio.
It also includes textual
The data can also be retrieved in an organized
documents, programs, and blog
manner using tools like SQL.
data.
The structured data frequently encountered in It is estimated that 80% of the
machine learning are: data are unstructured data.
Record Data
Data Matrix
Graph Data
Ordered Data
Examples of ordered data:
Temporal data
Sequence data
Spatial data
4. Presentation Layer
Module 1
• It has mechanisms such as dashboards, and applications that display the results
of analytical engines and machine learning algorithms.
Given:
Module 1
[
S={12,14,19,22,24,26,28,31,34}
]
The data is already sorted.
Divide into 3 equal frequency bins:
Bin 1
[
{12,14,19}
]
Bin 2
[
{22,24,26}
]
Bin 3
[
{28,31,34}
]
1. Smoothing by Means
Calculate mean for each bin.
Bin 1 Mean
[
\frac{12+14+19}{3}
]
[
=15
]
Result:
[
{15,15,15}
]
Bin 2 Mean
Module 1
[
\frac{22+24+26}{3}
]
[
=24
]
Result:
[
{24,24,24}
]
Bin 3 Mean
[
\frac{28+31+34}{3}
]
[
=31
]
Result:
[
{31,31,31}
]
Final result:
[
{15,15,15,24,24,24,31,31,31}
]
2. Smoothing by Medians
Bin 1 Median
[
14
]
Result:
Module 1
[
{14,14,14}
]
Bin 2 Median
[
24
]
Result:
[
{24,24,24}
]
Bin 3 Median
[
31
]
Result:
[
{31,31,31}
]
Final result:
[
{14,14,14,24,24,24,31,31,31}
]
Bin 2 : {22,24,26}
Boundaries:
[
22,26
]
Result:
[
{22,22,26}
]
Bin 3 : {28,31,34}
Boundaries:
[
28,34
]
Result:
[
{28,28,34}
]
Final result:
[
{12,12,19,22,22,26,28,28,34}
]
Source: Uploaded Machine Learning Textbook
5)What are the different ways of Data Transformation?
• Data transformation routines perform operations like normalization to improve
the performance of the data mining algorithms.
• It is necessary to transform data so that it can be processed.
Module 1
• This can be considered as a preliminary stage of data conditioning.
• Normalization is one such technique.
• In normalization, the attribute values are scaled to fit in a range (say 0–1) to
improve the performance of the data mining algorithm.
• Often, in neural networks, these techniques are used.
• Some of the normalization procedures used are:
1. Min-Max
2. z-Score
1. Min-Max Procedure
• It is a normalization technique where each variable V is normalized by its
difference with the minimum value divided by the range to a new range, say 0–
1.
• Often, neural networks require this kind of normalization.
Formula:
min\text{-}max=\frac{V-min}{max-min}\times(new\ max-new\ min)+new\ min
• Here max-min is the range.
• Min and max are the minimum and maximum of the given data.
• New max and new min are the minimum and maximum of the target range,
say 0 and 1.
2. z-Score Normalization
• This procedure works by taking the difference between the field value and
mean value, and by scaling this difference by standard deviation of the
attribute.
Formula:
V^{*}=\frac{V-\mu}{\sigma}
• Here, σ is the standard deviation of the list V and μ is the mean of the list V.
• z-scores are used to detect outlier detection.
Module 1
• If the data value z-score function is either less than −3 or greater than +3, then
it is possibly an outlier.
• The major disadvantage of z-score function is that it is extremely sensitive to
outliers as it is dependent on mean.
For marks 90
[
min\text{-}max
\frac{90-88}{94-88}\times(1-0)+0
]
[
0.33
]
For marks 92
[
min\text{-}max
\frac{92-88}{94-88}\times(1-0)+0
]
[
\frac{4}{6}
0.66
]
For marks 94
[
min\text{-}max
\frac{94-88}{94-88}\times(1-0)+0
]
[
\frac{6}{6}
Module 1
1
]
Univariate Data
• In case of univariate data, the dataset has only one variable.
• A variable is also called as category.
Bivariate Data
• Bivariate data indicates that the number of variables used are two.
Multivariate Data
• Multivariate data uses three or more variables.
Module 1
1. Mean
• Arithmetic average (or mean) is a measure of central tendency that represents
the 'center' of the dataset.
• This is the commonest measure used in our daily conversation such as:
o Average income
o Average traffic
• It can be found by adding all the data and dividing the sum by the number of
observations.
Formula:
Module 1
\bar{x}=\frac{x_1+x_2+...+x_N}{N}=\frac{1}{N}\sum_{i=1}^{N}x_i
Example
For three numbers:
[
10,20,30
]
[
\frac{10+20+30}{3}
]
[
\frac{60}{3}
]
[
=20
]
Weighted Mean
• Unlike arithmetic mean that gives the weightage of all items equally, weighted
mean gives different importance to all items as the item importance varies.
• Hence, different weightage can be given to items.
Geometric Mean
• Geometric mean is the Nth root of the product of N items.
Formula:
Geometric\ mean=\left(\prod_{i=1}^{N}x_i\right)^{\frac{1}{N}}
Example
If the values are:
[
6,8
]
[
\sqrt{6\times8}
]
[
Module 1
\sqrt{48}
]
2. Median
• The middle value in the distribution is called median.
• If the total number of items in the distribution is odd, then the middle value is
called median.
• If the numbers are even, then the average value of two items in the centre is
the median.
• The median is the value where (x_i) is divided into two equal halves, with half
of the values being lower than the median and half higher than the median.
• A median class is that class where ((N/2)^{th}) item is present.
Formula for continuous case:
Median=L_1+\frac{\frac{N}{2}-cf}{f}\times i
Where:
• (i) = class interval of the median class
• (L_1) = lower limit of median class
• (f) = frequency of median class
• (cf) = cumulative frequency of all classes preceding median
3. Mode
• Mode is the value that occurs more frequently in the dataset.
• In other words, the value that has the highest frequency is called mode.
• Mode is only for discrete data and is not applicable for continuous data as
there are no repeated values in continuous data.
Module 1
• The procedure for finding mode is to calculate the frequencies for all the
values in the data, and mode is the value (or values) with the highest
frequency.
• Normally, the dataset is classified as:
o Unimodal → with modes 1
o Bimodal → with modes 2
o Trimodal → with modes 3
1. Flat Files
• These are the simplest and most commonly available data source.
• It is also the cheapest way of organizing the data.
• These flat files are the files where data is stored in plain ASCII or EBCDIC
format.
• Minor changes of data in flat files affect the results of the data mining
algorithms.
• Hence, flat file is suitable only for storing small dataset and not desirable if the
dataset becomes larger.
Popular spreadsheet formats:
CSV files
• CSV stands for comma-separated value files where the values are separated by
commas.
• These are used by spreadsheet and database applications.
• The first row may have attributes and the rest of the rows represent the data.
TSV files
• TSV stands for Tab separated values files where values are separated by Tab.
• Both CSV and TSV files are generic in nature and can be shared.
• There are many tools like Google Sheets and Microsoft Excel to process these
files.
2. Database System
Module 1
• It normally consists of database files and a database management system
(DBMS).
• Database files contain original data and metadata.
• DBMS aims to manage data and improve operator performance by including
various tools like:
o Database administrator
o Query processing
o Transaction manager
• A relational database consists of sets of tables.
• The tables have rows and columns.
• The columns represent the attributes and rows represent tuples.
• A tuple corresponds to either an object or a relationship between objects.
• A user can access and manipulate the data in the database using SQL.
Different types of databases:
Transactional database
• A transactional database is a collection of transactional records.
• Each record is a transaction.
• A transaction may have:
o Time stamp
o Identifier
o Set of items
• Transactional databases are created for performing associational analysis that
indicates the correlation among the items.
Time-series database
• Stores time related information like log files where data is associated with a
time stamp.
• This data represents the sequences of data.
• Example:
o Hourly
Module 1
o Weekly
o Yearly events
• Observing sales of product continuously may yield a time-series data.
Spatial database
• Spatial databases contain spatial information in a raster or vector format.
• Raster formats are either bitmaps or pixel maps.
• Images can be stored as raster data.
• Vector format can be used to store maps using geometric primitives like:
o Points
o Lines
o Polygons
5. Data Stream
• It is dynamic data, which flows in and out of the observing environment.
• Typical characteristics of data stream are:
o Huge volume of data
o Dynamic
o Fixed order movement
o Real-time constraints
Module 1
6. RSS (Really Simple Syndication)
• It is a format for sharing instant feeds across services.