Professional Documents
Culture Documents
UNIT I
Above figure shows the subareas of machine learning and summarizes the tasks.
However, in literature, other classifications of machine learning methods can be
found.
23-08-2022 3
Dr.R.Hepziba Gnanamalar
INTRODUCTION TO MACHINE LEARNING
Dr.R.Hepziba Gnanamalar
INTRODUCTION TO MACHINE LEARNING
23-08-2022 8
Dr.R.Hepziba Gnanamalar
SUPERVISED LEARNING
Classification − Classification-based tasks predict the categorical output
responses or labels for the given training data. This output, which will belong to
a specific discrete category, is based on what our ML model learns in the
training phase. For example, to predict high-risk patients and discriminate such
patients from low-risk patients is a classification task.
23-08-2022 10
Dr.R.Hepziba Gnanamalar
PERCEPTRON
The perceptron is a simple neural network, proposed in 1958 by Rosenblatt, which became
a landmark in early machine learning history.
It is one of the oldest machine learning algorithms. The perceptron consists of a single
neuron and is a binary classifier that can linearly separate an input x, a real valued vector,
into a single, binary output.
It is an online learning algorithm. Online learning means it processes one input at a time.
The data is presented in a sequential order and updates the predictor at each step using
the best predictor.
The perceptron is modeled after a neuron in the brain and is the basic element of a neural
network.
23-08-2022 11
Dr.R.Hepziba Gnanamalar
PERCEPTRON
A perceptron performs three processing steps:
Each input signal x is multiplied by a weight w: wixi
All signals are summed up
The summed up inputs are fed to an activation function
The output is calculated using the output function f(x), as defined by equation
f(x) =X i=1 wixi +b
where w = Weight x = Input b = Bias
Each input signal has its own weight that is adjusted individually. During training, the
weights are adjusted until the desired result is obtained.
Usually, the initial weights are all zero or assigned random numbers, usually between 0
and 1. After each learning iteration, the error at the output is calculated.
The weights are adjusted based on the calculated error, in such a way that the next
result is closer to the desired result.
Dr.R.Hepziba Gnanamalar 23-08-2022 12
PERCEPTRON
23-08-2022 20
Dr.R.Hepziba Gnanamalar
SEMI-SUPERVISED LEARNING
Semi-supervised learning uses a combination of labeled and unlabeled data. It is
typically used when a small amount of labeled data and a large amount of unlabeled
data is present.
Since semi-supervised learning still requires labeled data, it can be considered a subset
of supervised learning. However, other forms of partial supervision other than
classification are possible.
Data is often labeled by a data scientist, which is a laborious task and bares the risk of
introducing a human bias.
Bias stems from human prejudice that, in the case of labeling data, might result in the
under or overrepresentation of some features in the data set.
Machine learning heavily depends on the quality of the data. If the data set is biased,
the result of the machine learning task will be biased.
However, human bias cannot only negatively influence machine learning through data
but also through algorithms and interaction.
Dr.R.Hepziba Gnanamalar 23-08-2022 21
SEMI-SUPERVISED LEARNING
Human bias does not need to be conscious.
It can originate from ignorance, for instance, an under representation of minorities in
a sample population or from a lack of data that includes minorities.
Generally speaking, training data should equally represent all our world.There are
many different semi-supervised training methods.
Probably the earliest idea about using unlabeled data in classification is self-learning,
which is also known as self-training, self-labeling, or decision-directed learning.
The basic idea of self-learning is to use the labeled data set to train a learning
algorithm, then use the trained learner iteratively to label chunks of the unlabeled
data until all data is labeled using pseudo labels.
Then the trained learner is retrained using its own predictions.
Self-learning bears the risk that the pseudo labeled data will have no effect on the
learner or that self-labeling happens without knowing on which assumptions the self-
learning is based on.
23-08-2022 22
Dr.R.Hepziba Gnanamalar
FUNCTION APPROXIMATION
f:X→Y
where X = Input space Y = Output space, number of predictions
Dr.R.Hepziba Gnanamalar 23-08-2022 23
FUNCTION APPROXIMATION
where the input space can be multidimensional X ⊆ R 2 , in this case n-dimensional.
The function: f(x) = y (2.7) maps x ∈ X to y ∈Y, where the distribution of x and the
function f are unknown.
f can have some unknown properties for a space where no data points are available.
A discriminative algorithm does not care about how the data was generated, it simply
categorizes a given signal.
It directly estimates posterior probabilities, they do not attempt to model the underlying
probability distributions.
Logistic regression, support vector machines (SVM), traditional neural networks and
nearest neighbor models fall into this category.
Discriminative models tend to perform better since they solve the problem directly,
whereas generative models require an intermediate step.
However, generative models tend to converge a lot faster.
Dr.R.Hepziba Gnanamalar
EVALUATION OF LEARNER
The mean squared error simply takes the difference between the predictions and the
ground truth, squares it, and averages it out across the whole data set.
The mean squared error is always positive and the closer to zero the better. The mean
squared error is computed as shown in the equation
where
y = Vector of n predictions
n = Number of predictions
f(xi) = Prediction for the ith observation
Other popular loss functions include hinge loss or the likelihood loss. The likelihood
loss function is also a relatively simple function and is often used for classification
problems.
Dr.R.Hepziba Gnanamalar 23-08-2022 29
EVALUATION OF LEARNER
Dr.R.Hepziba Gnanamalar
DATA PRE-PROCESSING
UNIT - 2
Dr.R.Hepziba Gnanamalar
FEATURE EXTRACTION
A sample feature extraction task is word frequency counting. For instance, reviews of a
consumer product contain certain words more often if they are positive or negative.
A positive review of a new car typically contains words such as “good”, “great”,
“excellent” more often than negative reviews.
Here, feature extraction means defining the words to count and counting the number
of times a positive or negative word is used in the review.
The resulting feature vector is a list of words with their frequencies. A feature vector is
an n-dimensional vector of numerical features, so the actual word is not part of the
feature vector itself.
The feature vector can contain the hash of the word as shown in Figure, or the word is
recognized by its index, the position in the vector
23-08-2022 41
Dr.R.Hepziba Gnanamalar
SAMPLING
Another sampling method uses stratification. Stratification is used to avoid
overrepresentation of a class label in the sample and provide a sample with an even
distribution of labels.
For instance, a sample might contain an overrepresentation of male or female
instances. Stratification first divides the data in homogeneous subgroups before
sampling.
The subgroups should be mutually exclusive. Instead of using the whole population, it
is divided into subpopulations (stratum), a bin with female and a bin with male
instances.
Then, an even number of samples is selected randomly from each bin. We end up with
a stratified random sample with an even distribution of female and male instances.
Stratification is also often used when dividing the data set into a training and testing
subset.
Both data sets should have an even distribution of the features, otherwise the
evaluation of the trained learner might give flawed results.
23-08-2022 42
Dr.R.Hepziba Gnanamalar
DATA TRANSFORMATION
Raw data often needs to be transformed. There are many reasons why data needs to be
transformed.
For instance, numbers might be represented as strings in a raw data set and need to be
transformed into integers or doubles to be included into a feature vector.
Another reason might be the wrong unit. For instance, Fahrenheit needs to be converted
into Celsius, or inch needs to be converted into metric.
Sometimes the data structure has to be transformed. Data in JSON (JavaScript Object
Notation) format might have to be transformed into XML (Extensible Markup Language)
format.
In this case, data mapping has to be transformed since the metadata might be different
in the JSON and XML file.
For instance, in the source JSON file names might be denoted by “first name”, “last
name” whereas in the XML it is called “given name” and “family name”.
Data transformation is almost always needed in one or another form, especially if the
data has more than one source.
23-08-2022 43
Dr.R.Hepziba Gnanamalar
OUTLIER REMOVAL
Outlier removal is another common data pre-processing task. An outlier is an observation point
that is considerably different from the other instances.
Some machine learning techniques, such as logistic regression, are sensitive to outliers, i.e.,
outliers might seriously distort the result.
For instance, if we want to know the average number of Facebook friends of Facebook users we
might want to remove prominent people such as politicians or movie stars from the data set
since they typically have many more friends than most other individuals.
However, if they should be removed or not depends on the aim of the application, since outliers
can also contain useful information.
Outliers can also appear in a data set by chance or through a measurement error. In this case,
outliers are a data quality problem like noise.
However, in a large data set outliers are to be expected and if the number is small, they are
usually not a real problem. Clustering is often used for outlier removal.
Outliers can also be detected and removed visually, for instance, through a scatter plot, or
mathematically, for instance, by determining the z-score, the standard deviations by which the
outlier is above the mean value of the data set
23-08-2022 44
Dr.R.Hepziba Gnanamalar
DATA DEDUPLICATION
Duplicates are instances with the exact same features. Most machine learning tools will
produce different results if some of the instances in the data files are duplicated,
because repetition gives them more influence on the result.
For example, Retweets are Tweets posted by a user that is not the author of the original
Tweet and have the exact same content as the original Tweet except for metadata such
as the timestamp of when it has been posted and the user who posted, retweeted, it.
As with outliers, if duplicates should be removed or not depends on the context of the
application.
Duplicates are usually easily detectable by simple comparison of the instances,
especially if the values are numeric, and machine learning frameworks often offer data
deduplication functionality out of the box.
It can also use clustering for data deduplication since many clustering techniques use
similarity metrics and they can be used for instance matching based on similarities.
Dr.R.Hepziba Gnanamalar
NORMALIZATION, DISCRETIZATION AND AGGREGATION
NORMALIZATION
Discretization
Discretization means transferring continuous values into discrete values.
The process of converting continuous features to discrete ones and deciding the
continuous range that is being assigned to a discrete value is called discretization.
For instance, sensor values in a smart building in an Internet of Things (IoT) setting,
such as temperature or humidity sensors, are delivering continuous measurements,
whereas only values every minute might be of interest.
An other example is the age of online shoppers, which are continuous and can be
discretized into age groups such as “young shoppers”, “adult shoppers” and “senior
shoppers”.
23-08-2022 53
Dr.R.Hepziba Gnanamalar
BIAS-VARIANCE TRADEOFF
Bias refers to model error and variance refers to the consistency in predictive accuracy of
models applied to other data sets.
The irreducible error, also called noise, cannot fundamentally be reduced during training by
any model.
It can be reduced sometimes by performing better data pre-processing steps, usually better
data cleansing.
The irreducible error stems from the data itself, bias and variance from the choice of the
learning algorithm.
With infinite training data it should be possible to reduce bias and variance towards 0
(asymptotic consistency and asymptotic efficiency).
However, some learners are not capable of fitting a model even if enough data is available.
For instance, algorithms that linearly separate the data, such as the perceptron, cannot fit
data that has a non linear pattern.
Figure shows data that can and cannot be fitted using a linear algorithm
23-08-2022 54
Dr.R.Hepziba Gnanamalar
BIAS-VARIANCE TRADEOFF