Introduction to Machine Learning Concepts
Introduction to Machine Learning Concepts
Syllabus:
Introduction: Need for Machine Learning, Machine Learning Explained, Machine Learning
in Relation to other Fields, Types of Machine Learning, Challenges of Machine Learning,
Machine Learning Process, Machine Learning Applications.
Business organizations use huge amount of data for their daily activities.
The full potential of this data was not utilized due to two reasons.
1. Data being scattered across different archive systems and organizations were not
able to integrate these sources fully.
2. Lack of awareness about software tools that could help to unearth the useful
infom1ation from data.
Machine learning has become so popular because of three reasons:
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. Second reason is that 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 infom1ation.
3. Third reason for popularity of machine learning is the availability of complex
algorithms now. Especially with the advent of deep learning, many
algorithms are available for machine learning.
Data: All facts are data, Data can be numbers or text that can be processed by a
computer.
Information: Processed data is called information; this includes patterns,
associations, or relationships among data. For example, sales data can be analysed to
extract information like which is the fast selling product.
Knowledge: Condensed information is called knowledge. Unless knowledge is
extracted, data is of no use. knowledge is not useful unless it is put into action.
Intelligence: Intelligence is the applied knowledge for actions, An actionable fom1 of
knowledge is called intelligence.
Wisdom: The ultimate objective of knowledge pyramid is wisdom that represents the
maturity of mind that is, so far, exhibited only by humans.
Tom Mitchell's definition of machine learning states that, "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.
Example: 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. the focus is to use this experience E for the task of object
Deep learning is a sub branch of machine learning. In deep learning, the models are
constructed using neural network technology. Neural networks are based on the
human neuron models. Many neurons fom1 a network connected with the activation
functions that trigger further neurons to perfom1 tasks.
Data science deals with gathering of data for analysis, it includes the following
Big 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, and YouTube.
2. Variety: Data is available in variety of forms like images, videos, and in
different fom1ats.
3. Velocity: It refers to the speed at which the data is generated and processed.
Big data is used by many machine learning algorithms for applications such as
language Translation and image recognition.
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
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:
Pattern Recognition
It uses machine learning algorithms to extract the features for pattern analysis and
pattern classification.
Supervised Learning:
Classification
Regression Model:
The regression model takes input x and generates a model in the fom1 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.
What is the difference between classification and regression models? The main difference is
that regression models predict continuous variables such as product price, while classification
concentrates on assigning labels such as class.
Unsupervised Learning:
Cluster Analysis:
Dimensionality Reduction:
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 perfom1by 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 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
behaviour gets reinforced and learning becomes possible.
Example : Grid Game
Consider the following example of a Grid game as shown in Figure
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, 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.
1. Problems -Machine learning can deal with the 'well-posed' problems where
specifications are complete and available. Computers cannot solve 'ill-posed'
problems.
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, fom1ulation 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. This is a perennial problem for the classification
models. Hence, suitable strategies should be adopted to handle the missing data.
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
detem1ined by evaluating the accuracy of the classifier. The process of classification
is a fuzzy issue. For example, classification of emails requires extensive domain
Big data, is a larger data whose volume is much larger than 'small data' and is characterized
as follows:
Types of Data:
1. Structured data
2. Unstructured data
3. Semi-structured data.
The structured data frequently encountered in machine learning are listed below:
1. Record Data:
A dataset is a collection of measurements taken from a process.
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.
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 modes 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:
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.
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
Unstructured 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
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.
RSS (Really Simple Syndication) It is a format for sharing instant feeds across
services.
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.
Data analysis is an activity that takes the data and generates useful information and
insights for assisting the organizations.
Data analytics is a general term and data analysis is a part of it Data analytics
refers to the process of data collection, preprocessing and analysis.
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.
Descriptive Analytics:
Predictive Analytics
It deals with the future. It deals with the question - 'What will happen in future given
this data?'.
This involves the application of algorithms to identify the patterns to predict the
future.
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.
Big data framework is a layered architecture. . A 4-layer architecture has the following
layers:
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
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.
In the above table It can be observed that data like Salary = ' ' is incomplete data.
The DOB of patients, John, Andre, and Raju, is the missing data.
The age of David is recorded as '5' but his DOB indicates it is 10/10/1980. This is
called inconsistent data.
Salary for John is -1500. It cannot be less than 'O'.
The age of Raju cannot be 136.
Outliers may be legitimate data and sometimes are of interest to the data mining algorithms.
These errors often come during data collection stage. These must be removed so that machine
The primary data cleaning process is missing data analysis. Data cleaning routines attempt to
fill up the missing values, smoothen the noise while identifying the outliers and correct the
inconsistencies of the data. This enables data mining to avoid overfitting of the models.
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 - Here, the domain expert can analyze 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 analyzing 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
Data integration involves routines that merge data from multiple sources into a single
data source.
The main goal of data integration is to detect and remove redundancies that arise from
integration.
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.
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.
Some of the normalization procedures used are:
1. Min-Max
2. z-Score
Min-Max Procedure
It is a normalization technique where each variable 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. The formula to implement this normalization is given as:
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.
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, a is the standard deviation of the list V and µ is the mean of the list V.
z-scores are used to detect outlier detection. If the data value z-score function is either less
than -3 or greater than +3, then it is possibly an outlier.
Data reduction reduces data size but produces the same results. There are different ways in
which data reduction can be carried out such as data aggregation, feature selection, and
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.
Nominal Data - In Table 2.2, patient ID is 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. For
example, the patient ID can be checked for equality and nothing else.
Ordinal 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.
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-.
Ratio Data - 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.
Data Visualization
To understand data, graph visualization is must.
It helps to present information and data to customers.
Some of the graphs that are used in univariate data analysis are bar charts, histograms,
frequency polygons and pie charts.
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.
Pie Chart: The percentage frequency distribution of students' marks {22, 22, 40, 40, 70, 70,
70, 85, 90, 90)
Histogram It plays an important role in data mining for showing frequency distributions. The
histogram for students' marks {45, 60, 60, 80, 85} in the group range of 0-25, 26-50, 51-75,
76-100 is given below in Figure 2.5. One can visually inspect from Figure 2.5 that the
number of students in the range 76-100 is 2.
Histogram conveys useful information like nature of data and its mode. Mode indicates the
peak of dataset.
Dot Plot These are similar to bar charts. they are less clustered as compared to bar charts, as
they illustrate the bars only with single points. The dot plot of English marks for five students
with ID as {l, 2, 3, 4, 5) and marks {45.,60, 60, 80, 85} is given in Figure
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 the number of observations. the average of all the values in the sample
(population) is denoted as x. Let x1, x2, • • • , xN be a set of 'N' values or
observations, then the arithmetic mean is given as:
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 - Let x1, x2, .••, xN be a set of 'N' values or observations.
Geometric mean is the N'th root of the product of N items. The formula for
computing geometric mean is given as follows:
3. Mode - Mode is the value that occurs more frequently in the dataset. The procedure
for finding the mode is to calculate the frequencies for all the values in the data, and
mode is the value (or values) with the highest frequency.
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.
Range Range is the difference between the maximum and minimum of values of the given
list of data.
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.
Quartiles and Inter Quartile Range It is sometimes convenient to subdivide the dataset
using coordinates.
For example, median is 50th percentile and can be denoted as Qo so The 25th percentile is
called first quartile (Q1) and the 75th percentile is called third quartile (Q3 ). Another
measure that is useful to measure dispersion is Inter Quartile Range (IQR). The IQR is the
difference between Q3 and Q1.
Five-point Summary and Box Plots 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.
Skewness and Kurtosis (called moments) indicate the symmetry/asymmetry and peak
location of the dataset.
Skewness
If the dataset has far higher values, then it is said to be skewed to the right.
On the other hand, if the dataset has far more low 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 the skewness is zero.
In the case of skew, the median is greater than the mean. In positive skew, the mean is
greater than the median.
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 distribution of the
data.
In this method, each value is • split into a 'stem' and a1eaf. The last digit is usually the
leaf and digits to the left of the leaf mostly form the stem.
A Q-Q plot can be used to assess the shape of the dataset. The Q-Q plot is a 2D scatter plot of
an univariate data against theoretical normal distribution data or of two datasets - the quartiles
of the first and second datasets. The normal Q-Q plot for marks x = [1311 2 3 4 8 9] is given
below.