Module 1 Machine Learning
Module 1 Machine Learning
Module 1
Business organizations use huge amount of data for their daily activities. Earlier, the full
potential of this data was not utilized due to two reasons.
1. One reason was data being scattered across different systems and organizations not being
able to integrate these sources fully.
2. Secondly, the lack of awareness about software tools that could help to unearth the useful
information from data.
Business organizations have now started to use the latest technology, machine learning for this
purpose.
1. High volume of available data to manage: Big companies such as Facebook, Twitter
and Youtube generate huge amount of data that grows at a phenomenal rate. It is
estimated that the data approximately gets doubled every year.
2. The cost of storage has reduced. The hardware cost has also dropped. Therefore, it is
easier now to capture, process, store, distribute and transmit the digital information.
3. Machine learning is popular due to availability of complex algorithms. With the advent
of deep learning, many algorithms are available for machine learning.
With the popularity and ready adaption of machine learning by business organizations, it has
become a dominant technology trend now. A knowledge pyramid is shown in Figure 1.1.
Data
Information
Knowledge
Intelligence
Wisdom
The ultimate objective of knowledge pyramid is wisdom that represents the maturity of
mind that is, so far, exhibited only by humans.
The objective of machine learning is to process archival data for organizations to take better
decisions to design new products, improve the business processes, and to develop effective
decision support systems.
This approach could be difficult for many real-world problems such as puzzles, games,
and complex image recognition applications.
Initially, artificial intelligence aims to understand these problems and develop general
purpose rules manually.
Then, these rules are formulated into logic and implemented in a program to create
intelligent systems.
This idea of developing intelligent systems by using logic and reasoning by converting an
expert‟s knowledge into a set of rules and programs is called an expert system.
The expert system approach was impractical in many domains as programs still depended
on human expertise and hence did not truly exhibit intelligence.
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.
The models can then be used to predict new inputs.
Thus, the aim of machine learning is to learn a model or set of rules from the given
dataset automatically so that it can predict the unknown data correctly.
As humans take decisions based on an experience, computers make models based on
extracted patterns in the input data and then use these data-filled models for prediction
and to take decisions.
For computers, the learnt model is equivalent to human experience.
Figure 1.2: (a) A learning system for humans (b) A learning system for Machine Learning
Often, the quality of data determines the quality of experience and, therefore, the quality
of the learning system.
In statistical learning, the relationship between the input x and output y is
modeled as a function in the form y = f(x).
f is the learning function that maps the input x to output y.
The learning program summarizes the raw data in a model.
Model is an explicit description of patterns within the data in the form of:
1. Mathematical Equation
2. Relational diagrams like trees/graphs
3. Logical if/else rules, or
4. Groupings called clusters
A model can be a formula, procedure or representation that can generate data decisions.
The difference between pattern and model is that the former is local and applicable only
to certain attributes but the latter is global and fits the entire dataset.
“A computer program is said to learn from experience E, with respect to task T and some
performance measure P, if its performance on T measured by P improves with experience E “.
The important components of this definition are experience E, task T, and performance
measure P.
For example, the task T could be detecting an object in an image.
The machine can gain the knowledge of object using training dataset of thousands of
images.
This is called experience E.
So, the focus is to use this experience E for this task object detection T.
The ability of the system to detect the object is measured by performance measures like
precision and recall.
Models of computer systems are equivalent to human experience.
Once the knowledge is gained, when a new problem is encountered, humans search for
similar past situations and then formulate the heuristics and use that for prediction.
1. Collection of data
2. Once data is gathered, abstract concepts are formed out of that data. Abstraction is used
to generate concepts. This is equivalent to humans idea of objects. For example, we have
some idea about how an elephant looks like.
3. Generalization converts the abstraction into an actionable form of intelligence. It can be
viewed as ordering of all possible concepts. So, generalization involves ranking of
concepts, inferencing from them and formation of heuristics, an actionable aspect of
intelligence.
4. Heuristics normally works! But, occasionally, it may fail too. It is not the fault of
heuristics as it is just a „rule of thumb′. The course correction is done by taking evaluation
measures. Evaluation checks the thoroughness of the models and to-do course correction,
if necessary, to generate better formulations.
Machine learning uses the concepts of Artificial Intelligence, Data Science, and Statistics
primarily.
It is the resultant of combined ideas of diverse fields.
Big Data: Data science concerns about collection of data. Big data is a field of data science that
deals with data„s following characteristics:
1. Volume: Huge amount of data is generated by big companies like Facebook, Twitter,
YouTube.
2. Variety: Data is available in variety of forms like images, videos, and in different
formats.
3. Velocity: It refers to the speed at which the data is generated and processed.
Data Mining
Data Analytics
Pattern Recognition
It is an engineering field.
It uses machine learning algorithms to extract the features for pattern analysis and pattern
classification.
One can view pattern recognition as a specific application of machine learning.
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.
Labelled data
Labelled data is data that has some predefined tags such as name, type, or number.
To illustrate labelled data, let us take one example dataset called Iris flower dataset.
The dataset has 50 samples of Iris – with four attributes, length and width of sepals and
petals. The target variable is called class. There are three classes – Iris setosa, Iris
virginica, and Iris versicolor.
Unlabelled data
Any data that does not have any labels specifying its characteristics, identity,
classification, or properties can be considered unlabelled data.
In unlabelled data, there are no labels in the dataset.
(a)
(b)
In the Figure 1.6, the deep neural network takes images of dogs and cats with labels for
classification.
1. Supervised Learning
Supervised algorithms use labelled dataset.
There is a supervisor or teacher component in supervised learning.
A supervisor provides labelled data so that the model is constructed and generates test
data.
In supervised learning algorithms, learning takes place in two stages.
1. During the first stage, the teacher communicates the information to the student that the
student is supposed to master. The student receives the information and understands it.
During this stage, the teacher has no knowledge of whether the information is grasped by
the student.
2. During the Second stage of learning, the teacher 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.
This kind of learning is typically called supervised learning.
1. Classification
2. Regression
1. Classification
Decision Tree
Random Forest
In Figure 1.7 classification algorithm takes a set of labeled data images such as dogs and cats to
construct a model that can be later used to classify an unknown test image data.
2. Regression Models
Regression models, unlike classification algorithms, predict continuous variables like
price. In other words, it is a number.
A fitted regression model is shown in Figure 1.8 for a dataset that represent weeks input x
and product sales y.
The regression model takes input x and generates a model in the form of a fitted line of
the form y = f(x).
Here, x is the independent variable that may be one or more attributes and y is the
dependent variable.
In Figure 1.8, linear regression takes the training set and tries to fit it with a line-product
sales =0.66 x Week +0.54.
Here, 0.66 and 0.54 are all regression coefficients that are learnt from data.
The advantage of this model is that prediction for product sales (y) can be made for
unknown week data (x).
For example, the prediction for unknown eighth week can be made by substituting x as 8
in that regression formula to get y.
One of the most important regression algorithms is linear regression.
Regression algorithms can be used to solve the Classification Algorithms can be used to solve
regression problems such as Weather classification problems such as Identification
Prediction, House price prediction, etc. of spam emails, Speech Recognition,
Identification of cancer cells, etc.
The regression Algorithm can be further The Classification algorithms can be divided
divided into Linear and Non-linear Regression. into Binary Classifier and Multi-class
Classifier
Unsupervised Learning
i. Cluster Analysis
Cluster analysis aims to group objects into disjoint clusters or groups.
Cluster analysis clusters objects based on its attributes.
All the data objects of the partitions are similar in some aspect and vary from the data
objects in the other partitions significantly.
An example of clustering scheme is shown in Figure 1.9 where the clustering algorithm
takes a set of dogs and cats images and groups it as two clusters-dogs and cats.
It can be observed that the samples belonging to a cluster are similar and samples are
different radically across clusters.
k-means algorithm
Hierarchical algorithms
Semi-supervised Learning
There are circumstances where the dataset has a huge collection of unlabelled data
and some labelled data.
Labelling is a costly process and difficult to perform by the humans.
Semi-supervised algorithms use unlabelled data by assigning a pseudo-label.
Then, the labelled and pseudo-labelled dataset can be combined.
Reinforcement Learning
Reinforcement learning mimics human beings.
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.
The agent can be human, animal, robot, or any independent program.
The rewards enable the agent to gain experience.
The agent aims to maximize the reward.
The reward can be positive or negative (Punishment).
When the rewards are more, the behavior gets reinforced and learning becomes possible.
In this grid game, the gray tile indicates the danger, black is a block, and the tile with
diagonal lines is the goal.
The aim is to start, say from bottom-left grid, using the actions left, right, top
and bottom to reach the goal state.
To solve this sort of problem, there is no data.
The agent interacts with the environment to get experience.
In the above case, the agent tries to create a model by simulating many paths and finding
rewarding paths.
This experience helps in constructing a model.
Reinforcement algorithms are reward-based, goal-oriented algorithms.
1. Problems – Machine learning can deal with the „well-posed„ problems where
specifications are complete and available. Computers cannot solve „ill-posed„ problems.
1. y=x1 x x2
2. y=x1x2
3. y=x1x2
This means that the problem is ill-posed.
To solve this problem, one needs more example to check the model.
Puzzles and games that do not have sufficient specification may become an ill-posed
problem and scientific computation has many ill-posed problems.
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
3. High computation power – With the availability of Big Data, the computational
resource requirement has also increased. Systems with Graphics Processing Unit (GPU)
or even Tensor Processing Unit (TPU) are required to execute machine learning
algorithms. Also, machine learning tasks have become complex and hence time
complexity has increased, and that can be solved only with high computing power.
4. Complexity of the algorithms – The selection of algorithms, describing the algorithms,
application of algorithms to solve machine learning task, and comparison of algorithms
have become necessary for machine learning or data scientists now. Algorithms have
become a big topic of discussion and it is a challenge for machine learning professionals
to design,select, and evaluate optimal algorithms.
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 for test data, in
general lacks generalization, is called overfitting. The reverse problem is called
underfitting where the model fails for training data but has good generalization.
The emerging process model for the data mining solutions for business organizations is CRISP-
DM. This process involves six steps. The steps are listed below in Figure 1.11.
1. Understanding the business – This step involves understanding the objectives and
requirements of the business organization. Generally, a single data mining algorithm is
enough for giving the solution. This step also involves the formulation of the problem
statement for the data mining process.
2. Understanding the data – It involves the steps like data collection, study of the
characteristics of the data, formulation of hypothesis, and matching of patterns to the
selected hypothesis.
3. Preparation of data – This step involves producing the final dataset by cleaning the raw
data and preparation of data for the data mining process. The missing values may cause
problems during both training and testing phases. Missing data forces classifiers to
produce inaccurate results.
4. Modelling – This step plays a role in the application of data mining algorithm for the
data to obtain a model or pattern.
5. Evaluate – This step involves the evaluation of the data mining results using statistical
analysis and visualization methods. The performance of the classifier is determined by
evaluating the accuracy of the classifier. The process of classification is a fuzzy issue.
6. Deployment – This step involves the deployment of results of the data mining algorithm
to improve the existing process or for a new situation.
1. Sentiment analysis – This is an application of natural language processing (NLP) where the
words of documents are converted to sentiments like happy, sad, and angry which are captured
by emotions effectively. 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, Amazon recommends users to find related books or books bought by people who
have the same taste like you, and Netflix suggests shows or related movies of your taste. The
recommendation systems are based on machine learning.
3. Voice assistants – Products like Amazon Alexa, Microsoft Cortana, Apple Siri, and Google
Assistant are all examples of voice assistants. They take speech commands and perform tasks.
These chatbots are the result of machine learning technologies.
4. Technologies like Google Maps and those used by Uber are all examples of machine learning
which offer to locate and navigate shortest paths to reduce time.
Understanding Data
WHAT IS DATA?
Data whose volume is less and can be stored and processed by a small-scale computer is
called „small data„.
These data are collected from several sources, and integrated and processed by a
small-scale computer.
Big data is a larger data whose volume is much larger than „small data„ and is
characterized as follows:
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). One exabyte is 1 million
terabytes.
2. Velocity – The fast arrival speed of data and its 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.
Form – There are many forms of data. Data types range from text, graph, audio, video, to
maps. 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.
Function – These are data from various sources like human conversations, transaction
records, and old archive data.
Source of data – This is the third aspect of variety. There are many sources of data.
Broadly, the data source can be classified as open/public data, social media data and
multimodal data.
Some of the other forms of Vs that are often quoted in the literature as characteristics of Big data
are:
4. Veracity of data – Veracity of data deals with aspects like conformity to the facts,
truthfulness, believablity, 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.
The data quality of the numeric attributes is determined by factors like precision, bias,
and accuracy.
Precision is defined as the closeness of repeated measurements. Often, standard
deviation is used to measure the precision.
Bias is a systematic result due to erroneous assumptions of the algorithms or procedures.
Accuracy is the degree of measurement of errors that refers to the closeness of
measurements to the true value of the quantity.
TYPES OF DATA
In Big Data, there are three kinds of data. They are structured data, unstructured data, and semi-
structured data.
1. Structured Data
In structured data, data is stored in an organized manner such as a database where it is
available in the form of a table.
The data can also be retrieved in an organized manner using tools like SQL.
1. Record Data
2. Data Matrix
3. Graph Data
4. Ordered Data
1. Record Data
A dataset is a collection of measurements taken from a process.
We have a collection of objects in a dataset and each object has a set of measurements.
The measurements can be arranged in the form of a matrix.
Rows in the matrix represent an object and can be called as entities, cases, or records.
The columns of the dataset are called attributes, features, or fields.
The table is filled with observed data.
2. Data Matrix
It is a variation of the record type because it consists of numeric attributes.
The standard matrix operations can be applied on these data.
The data is thought of as points or vectors in the multidimensional space where every
attribute is a dimension describing the object.
3. Graph Data
It involves the relationships among objects.
For example, a web page can refer to another web page.
This can be modeled as a graph.
The nodes are web pages and the hyperlink is an edge that connects the nodes.
4. Ordered Data
Ordered data objects involve attributes that have an implicit order among them. The
examples of ordered data are:
i. Temporal data – It is the data whose attributes are associated with time. For example,
the customer purchasing patterns during festival time is sequential data. Time series data
is a special type of sequence data where the data is a series of measurements over time.
ii. Sequence data – It is like sequential data but does not have time stamps. This data
involves the sequence of words or letters. For example, DNA data is a sequence of four
characters – A T G C.
iii. Spatial data – It has attributes such as positions or areas. For example, maps are spatial
data where the points are related by location.
2.Unstructured Data
3. Semi-Structured Data
Once the dataset is assembled, it must be stored in a structure that is suitable for data
analysis.
The goal of data storage management is to make data available for analysis.
There are different approaches to organize and manage data in storage files and systems
from flat file to data warehouses
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.
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.
2. Database System 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 database
administrator, query processing, and 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.
ii. 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, which represent values or events
obtained over a period (for example, hourly, weekly or yearly) or repeated time span. Observing
sales of product continuously may yield a time-series data.
iii. Spatial databases contain spatial information in a raster or vector format. Raster formats are
either bitmaps or pixel maps. For example, images can be stored as a raster data. On the other
hand, the vector format can be used to store maps as maps use basic geometric primitives like
points, lines, polygons and so forth.
3. World Wide Web (WWW) It provides a diverse, worldwide online information source. The
objective of data mining algorithms is to mine interesting patterns of information present in
WWW.
4. XML (eXtensible Markup Language) It is both human and machine interpretable data
format that can be used to represent data that needs to be shared across the platforms.
5. Data Stream It is dynamic data, which flows in and out of the observing environment.
Typical characteristics of data stream are huge volume of data, dynamic, fixed order movement,
and real-time constraints.
6. RSS (Really Simple Syndication) It is a format for sharing instant feeds across services.
7. JSON (JavaScript Object Notation) It is another useful data interchange format that is often
used for many machine learning algorithms.
The primary aim of data analysis is to assist business organizations to take decisions.
For example, a business organization may want to know which is the fastest selling
product, in order for them to market activities.
Data analysis is an activity that takes the data and generates useful information and
insights for assisting the organizations.
Data analysis and data analytics are terms that are used interchangeably to refer to the
same concept.
Data analytics is a general term and data analysis is a part of it.
Data analytics refers to the process of data collection, pre-processing and analysis.
It deals with the complete cycle of data management.
Data analysis is just analysis and is a part of data analytics. It takes historical data and
does the analysis.
Data analytics, instead, concentrates more on future and helps in prediction.
1. Descriptive analytics
2. Diagnostic analytics
3. Predictive analytics
4. Prescriptive analytics
1. Descriptive analytics
2. Diagnostic Analytics
For example, if a product is not selling, diagnostic analytics aims to find out the reason.
There may be multiple reasons and associated effects are analyzed as part of it.
3. Predictive Analytics
4. Prescriptive Analytics
It is about the finding the best course of action for the business organizations.
Prescriptive analytics goes beyond prediction and helps in decision making by giving a
set of actions.
It helps the organizations to plan better for the future and to mitigate the risks that are
involved.
4. Presentation Layer
It has mechanisms such as dashboards, and applications that display the results of
analytical engines and machine learning algorithms.
The Big Data processing cycle involves data management that consists of the following steps.
1. Data collection
2. Data preprocessing
3. Applications of machine learning algorithm
4. Interpretation of results and visualization of machine learning algorithm
DATA COLLECTION
1. Timeliness – The data should be relevant and not stale or obsolete data.
2. Relevancy – The data should be relevant and ready for the machine learning or data
mining algorithms. All the necessary information should be available and there should be
no bias in the data.
3. Knowledge about the data – The data should be understandable and interpretable, and
should be self sufficient for the required application as desired by the domain knowledge
engineer.
Broadly, the data source can be classified as open/public data, social media data and multimodal
data.
1. Open or public data source – It is a data source that does not have any stringent copyright
rules or restrictions. Its data can be primarily used for many purposes. Government census data
are good examples of open data
Digital libraries that have huge amount of text data as well as document images.
Scientific domains with a huge collection of experimental data like genomic data and
biological data.
Healthcare systems that use extensive databases like patient databases, health insurance
data, doctor‟s information, and bioinformatics information.
2. Social media – It is the data that is generated by various social media platforms like Twitter,
Facebook, YouTube, and Instagram. An enormous amount of data is generated by these
platforms.
3. Multimodal data – It includes data that involves many modes such as text, video, audio and
mixed types. Some of them are listed below:
Image archives contain larger image databases along with numeric and text data.
The World Wide Web (WWW) has huge amount of data that is distributed on the
Internet.
DATA PREPROCESSING
In real world, the available data is „dirty„. By this word „dirty„, it means:
Incomplete data
Inaccurate data
Outlier data
Data with missing values
Data with inconsistent values
Duplicate data
Data preprocessing improves the quality of the data mining techniques.
The raw data must be preprocessed to give accurate results.
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.
Some of the data errors include human errors such as typographical errors or incorrect
measurement and structural errors like improper data formats.
Data errors can also arise from omission and duplication of attributes.
Noise is a random component and involves distortion of a value or introduction of
spurious objects.
Consider, for example, the following patient Table 1.5. The „bad‟ or „dirty‟ data can be observed
in this table
The procedures that are given below can solve the problem of missing data:
1. Ignore the tuple – A tuple with missing data, especially the class label, is ignored. This
method is not effective when the percentage of the missing values increases.
2. Fill in the values manually –The domain expert can analyse the data tables and carry out
the analysis and fill in the values manually. But, this is time consuming and may not be
feasible for larger sets.
3. A global constant can be used to fill in the missing attributes. The missing values may
be „Unknown„ or be „Infinity„. But, some data mining results may give spurious results
by analysing these labels.
4. The attribute value may be filled by the attribute value. Say, the average income can
replace a missing value.
5. Use the attribute mean for all samples belonging to the same class. Here, the average
value replaces the missing values of all tuples that fall in this group.
6. Use the most possible value to fill in the missing value. The most probable value can be
obtained from other methods like classification and decision tree prediction.
It can be removed by using binning, which is a method where the given data values are
sorted and distributed into equal frequency bins.
The bins are also called as buckets.
The binning method then uses the neighbor values to smooth the noisy data.
Some of the techniques commonly used are
1. Smoothing by means
In this technique, the mean of the bin removes the values of the bins.
2. Smoothing by bin medians
In this technique, the bin median replaces the bin values.
3. Smoothing by bin boundaries
In this technique, the bin value is replaced by the closest bin boundary. The maximum
and minimum values are called bin boundaries.
Example:
Consider the following set: S = {12, 14, 19, 22, 24, 26, 28, 31, 34}. Apply various binning
techniques and show the result.
Solution: By equal-frequency bin method, the data should be distributed across bins. Let us
assume the bins of size 3, then the above data is distributed across the bins as shown below:
Bin 1 : 12 , 14, 19
Bin 2 : 22, 24, 26
Bin 3 : 28, 31, 34
By smoothing bins method, the bins are replaced by the bin means. This method results in:
Using smoothing by bin boundaries method, the bin‟s values would be like:
As per the method, the minimum and maximum values of the bin are determined, and it serves as
bin boundary and does not change. Rest of the values are transformed to the nearest value. It can
be observed in Bin 1,the middle value 14 is compared with the boundary values 12 and 19 and
changed to the closest value, that is 12. This process is repeated for all bins.
1. Min-Max
2. z-Score
1. Min-Max Procedure
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.
Example:
Consider the set: V = {88, 90, 92, 94}. Apply Min-Max procedure and map the marks to a new
range 0–1.
Solution: The minimum of the list V is 88 and maximum is 94. The new min and new max are
0 and 1, respectively.
For marks 90
For marks 92
For marks 94
So, it can be observed that the marks {88, 90, 92, 94} are mapped to the new range {0, 0.33,
0.66, 1}. Thus, the Min-Max normalization range is between 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.
Here, is the standard deviation of the list V and is the mean of the list V.
Example :
Consider the mark list V = {10, 20, 30}, convert the marks to z-score.
Solution: The mean and Sample Standard deviation () values of the list V are 20 and 10,
respectively. So the z-scores of these marks are calculated using following equation.
Hence, the z-score of the marks 10, 20, 30 are -1, 0 and 1, respectively.
DATA REDUCTION
Data reduction reduces data size but produces the same results.
There are different ways in which data reduction can be carried out such as
1. Data aggregation
2. Feature selection
3. Dimensionality reduction
DESCRIPTIVE STATISTICS
Every attribute should be associated with a value. This process is called measurement. The
type of attribute determines the data types, often referred to as measurement scale types.
Broadly, data can be classified into two types:
The categorical data can be divided into two types. They are nominal type and ordinal type.
i. Nominal Data
Nominal data are symbols and cannot be processed like a number. For example, the average
of a patient ID does not make any statistical sense. Nominal data type provides only information
but has no ordering among data. Only operations like (=, ≠) are meaningful for these data. In
Table 1.6, Patient ID is nominal data.
It provides enough information and has natural order. For example, Fever = {Low, Medium,
High} is an ordinal data. Certainly, low is less than medium and medium is less than high,
irrespective of the value. Any transformation can be applied to these data to get a new value.
It can be divided into two categories. They are interval type and ratio type.
i. Interval Data
Interval data is a numeric data for which the differences between values are meaningful. For
example, there is a difference between 30 degree and 40 degree. Only the permissible
operations are + and – .
For ratio data, both differences and ratio are meaningful. The difference between the ratio
and interval data is the position of zero in the scale. For example, take the Centigrade
Fahrenheit conversion. The zeroes of both scales do not match. Hence, these are interval data.
Discrete Data This kind of data is recorded as integers. For example, the responses of the
survey can be discrete data. Employee identification number such as 10001 is discrete data.
Continuous Data It can be fitted into a range and includes decimal point. For example, age
is a continuous data. Though age appears to be discrete data, one may be 12.5 years old and
it makes sense. Patient height and weight are all continuous data.
Third way of classifying the data is based on the number of variables used in the dataset.
Based on that, the data can be classified as univariate data, bivariate data, and multivariate
data.
Data Visualization
To understand data, graph visualization is must.
Data visualization helps to understand data it helps to present information and data to
customers.
Some of the graphs that are used in unvaried data analysis are bar charts, histograms,
frequency polygons and pie charts.
The advantages of graphs are presentation of data, summarization of data, description of
data, exploration of data, and to make comparisons of data.
Bar Chart
A Bar chart (or Bar graph) is used to display the frequency distribution for variables.
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.
The bar chart for student‟s marks {45, 60, 60, 80, 85} with Student ID = {1, 2, 3, 4, 5} is
shown below in Figure 1.14.
Pie Chart
It can be observed that the number of students with 22 marks are 2. The total number of students
are 10. So, 2/10 × 100 = 20% space in a pie of 100% is allotted for marks 22 in Figure 1.15.
Histogram
It plays an important role in data mining for showing frequency distributions.
The histogram for student‟s marks {45, 60, 60, 80, 85} in the group range of 0-25, 26-50,
51-75, 76- 100 is given below in Figure 1.16.
Histogram conveys useful information like nature of data and its mode.
Histograms can be used as charts to show frequency, skewness present in the data, and
shape.
Dot Plots
Central Tendency
A condensation or summary of the data is necessary.
This makes the data analysis easy and simple.
One such summary is called central tendency.
Thus, central tendency can explain the characteristics of data and that further helps in
comparison.
Mass data have tendency to concentrate at certain values, normally in the central location.
It is called measure of central tendency (or averages).
This represents the first order of measures.
Popular measures are mean, median and mode.
1. Mean
Arithmetic average (or mean) is a measure of central tendency that represents the „center„
of the dataset.
It can be found by adding all the data and dividing the sum by number of observations.
Mathematically, the average of all the values in the sample (population) is denoted as 𝑥 .
Let x1, x2, … , xN be a set of „N„ values or observations, then the arithmetic mean is
given as:
10+20+30 60
For example, the mean of the three numbers 10,20 and 30 is = =20
3 3
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.
In case of frequency distribution, mid values of the range are taken for computation.
Geometric Mean
2. Median
Median class is that class where N/2th item is present. Here, i is the class interval of the median
class and L1 is the lower limit of median class, f is the frequency of the median class, and cf is
the cumulative frequency of all classes preceding median.
3. Mode
Dispersion
The spreadout of a set of data around the central tendency (mean, median or mode) is
called dispersion.
Dispersion is represented by various ways such as range, variance, standard deviation,
and standard error.
These are second order measures.
The most common measures of the dispersion data are listed below:
1. Range
2. Standard Deviarion
3. Quartiles and Inter Quartile Range
4. Five-point Summary and Box Plot
1. Range
Range is the difference between the maximum and minimum of values of the given list of
data.
2. Standard Deviation
The mean does not convey much more than a middle point.
For example, the following datasets {10, 20, 30} and {10, 50, 0} both have a mean of 20.
The difference between these two sets is the spread of data.
Standard deviation is the average distance from the mean of the dataset to each point.
The formula for sample standard deviation is given by
Here, N is the size of the population, xi is observation or value from the population and is the
population mean.
Interquartile percentile = Q3 – Q1
Outliers are normally the values falling apart at least by the amount 1.5 × IQR above the
third quartile or below the first quartile.
Interquartile is defined by Q0.75 – Q0.25 .
Example:
Solution:
The median is in the fifth position. In this case, 24 is the median. The first quartile is median of
scores below the mean i.e, { 12,14,19,22}. Hence, it‟s the median of the list below 24. In this
case, the median is the average of the second and third values, that is Q0.25 =16.5. Similarly, the
third quartile is the median of the values above the median, that is {26,28,31,34}. So, Q0.75 is the
average of the seventh and eighth score. In this case, it is 28+31/2=59/2=29.5
The half of IQR is called semi-quartile range. The Semi Inter Quartile Range ( SIQR) is given as:
1
SIQR = x IQR
2
1
= x 13 =6.5
2
The median, quartiles Q1 and Q3, and minimum and maximum written in the order
< Minimum, Q1, Median, Q3, Maximum > is known as five-point summary.
Box plots are suitable for continuous variables and a nominal variable.
Box plots can be used to illustrate data distributions and summary of data.
It is the popular way for plotting five number summaries.
The box contains bulk of the data.
These data are between first and third quartiles.
The line inside the box indicates location – mostly median of the data.
Example:
Solution:
The minimum is 2 and the maximum is 13. The Q1,Q2 and Q3 are 3,8 and 11 respectively. Hence
5-point summary is {2,3,8,11,13}, that is {minimum, Q1,median,Q3,maximum}
Box plots are useful for describing 5-point summary. The box plot for the set is given in Figure
1.18.
Shape
Skewness and Kurtosis (called moments) indicate the symmetry/asymmetry and peak location of
the dataset.
Skewness
The measures of direction and degree of symmetry are called measures of third order.
Ideally,skewness should be zero as in ideal normal distribution.
More often, the given dataset may not have perfect symmetry(consider the following
Figure 1.19).
Figure 1.19: (a) Positive Skewed and (b) Negative Skewed Data
The dataset may also either have very high values or extremely low values.
If the dataset has far high values, then it is skewed to the right.
If the dataset has far more lower values then it is said to be skewed towards left.
If the tail is longer on the left-hand side and hump on the right-hand side, it is called
positive skew.
Otherwise, it is called negative skew.
A perfect symmetry means skewness is zero.
In positive skew, the mean is greater than the median.
Generally, for negatively skewed distribution, the median is more than the mean.
The relationship between skew and the relative size of the mean and median can be
summarized by a convenient numerical skew index known as Pearson 2 skewness
coefficient.
Let X1, X2, …, XN be a set of „N„ values or observations then the skewness can be given as:
Here, is the population mean and is the population standard deviation of the univariate data.
Kurtosis
Kurtosis also indicates the peaks of data.
If the data is high peak, then it indicates higher kurtosis and vice versa.
Kurtosis is the measure of whether the data is heavy tailed or light tailed relative to
normal distribution.
Here, 𝑥 and are the mean and standard deviation of the univariate data, respectively.
Some of the other useful measures for finding the shape of the univariate dataset are
mean absolute deviation (MAD) and coefficient of variation (CV)
Coefficient of Variation(CV)
The ideal way to check the shape of the dataset is a stem and leaf plot.
A stem and leaf plot are a display that help us to know the shape and the distribution of
the data. In this method, each value is split into a „stem‟ and a „leaf;.
The last digit is usually the leaf and digits to the left of the leaf mostly form the stem.
For example, marks 45 are divided into stem 4 and leaf 5 in Figure 1.20.
The stem and leaf plot for the English subject maks, say {45,60,60,80,85}is given in
Figure 1.20.
It can be seen from Figure 1.20 that the first column is stem and the second column is
leaf.
For the given English marks, two students with 60 marks are shown in stem and leaf plot
as stem-6 with 2 leaves with 0.
Q-Q plot
Ideally, the points fall along the reference line (45 Degree) if the data follows normal
distribution.
If the deviation is more, then there is greater evidence that the datasets follow some
different distribution. i.e Other than the normal distribution