ML Unit-1
ML Unit-1
(AUTONOMOUS)
PREPARED BY
S.SENTHIL ME.,(PhD).
AL3451-MACHINE LEARNING
COURSE OBJECTIVES
2020.
TOPICS TO BE COVERED:
Review of Linear Algebra for machine learning
Introduction and motivation for machine learning
Examples of machine learning applications
Vapnik-Chervonenkis (VC) dimension
Probably Approximately Correct (PAC) learning
Hypothesis spaces
Inductive bias
Generalization
Bias variance trade-off.
1.1 Review of Linear Algebra for machine learning
• Linear algebra helps to solve and compute large and complex dataset
• Linear algebra also helps to create better supervised and unsupervised machine
learning algorithms
Scalar
• Example : 20 and 80
Contd..
• Vector
• It has just one index, which can refer to a particular value within the vector
v=[e1,e2,e3,e4]
1-dimensional array.
• Matrix having its left diagonal elements as 1 and other elements 0 is an identity
matrix
• 2-dimensional array
• It is a rectangular array
• A=
Contd..
• Tensor
• It is an array of numbers, arranged on a regular grid
Operations
Scalar-vector multiplication
Scalar2
Vector p=[p1,p2,p3]
P*2=[2*p1,2*p2,2*p3]
Scalar-matrix multiplication
Scalar2
Contd..
• Matrix operation
• Scalar-matrix multiplication
• Matrix-matrix addition
• Matrix-matrix subtraction
• Matrix-matrix multiplication
• vector-matrix operation
• Vector-matrix multiplication
• Transpose
• Inverse
Contd..
• Scalar:
24
Vector:
[2,-6,9] or
Matrix:
Vapnik-Chervonenkis (VC) dimension
• In the context of data analysis and machine learning algorithms,
dimensions refers to the features of attributes of data
• 1D-points
• 2D-area
• 3D-more points
Introduction and motivation for machine learning
Examples of machine learning applications
• Prerequisite:
• Basics of probability and linear algebra
• Python language
• Derivatives of single variable and multivariante functions
• Machine learning algorithms enable the computers to learn from data, and
even improve themselves, without being explicitly programmed.
• ML allows software applications to become more accurate in predicting
outcomes.
• To build algorithms that can receive input data and use statistical analysis to
predict an output.
• Machine learning concerned with computer programs, that automatically
improve their performance through experience.
• Machine learning is influencing out day-to-day life and perhaps many people.
• Machine learning is an application, that allows machines to learn from
data.
Process of machine learning
• Data collection-collected from various sources such as files, database,
internet, or mobile devices.
• Data preparation
• Data exploration-find correlations, general trends, and outliers.
• Data pre-processing-transforming the data in a proper format to make it more
suitable for analysis.
• Data cleansing-missing values, duplicate data, invalid data, noise.
• Build model-classification, regression, cluster analysis, association.
• Train model-use datasets to train the model.
• Test model-check for the accuracy of model by providing a test dataset to it.
• Deploy model-deploy the model in the real system
Kaggle dataset-popular source for machine learning datasets
Classification of machine learning
• Supervised learning
• Unsupervised learning
• Reinforcement learning
Supervised learning
• Labeled data are provided to the machine learning system for
training, and the system then predicts the output based on the
training data.
• Provide input data as well as correct output data.
• Objectives
• The mapping of the input data to the output data
• Types
• Classification
• Regression
• Example:
• Spam filtering, image classification, fraud detection.
Contd..
Unsupervised learning
• The training is provided to the machine learning with the set of data
that has not been labelled, classified, or categorized and the
algorithm needs to act on that data without any supervision.
• In unsupervised learning, we don’t have a predetermined result.
• Objective
• The machine tries to find useful insights from the huge amount of
data
• Types
• Clustering
• Association
• Ex: recommender system, targeted maketting.
Reinforcement learning
• Reinforcement learning- it is a feedback-based learning method
where the agent interacts with the environment and explores it.
• It learns by interacting with its environment.
• The agent receives rewards for performing correctly and penalties for
performing incorrectly
Example of machine learning application
• Spam mail filter- to develop system
• Youtube recommendation- discover knowledge from large dataset
• Face recognition- smart phone password
• Hand writing recognition
• Image recognition
• Bank-fraud detection
• Hospital-to detect and diagnose diseases
• Companies-supply chain inventory control
• Chatbot
• Self driving cars
• Music composer
Contd..
• The film writer
• Gamer
• Robots
• Visual personal assistant-amzon “alexa” google assistant,apple -siri
Problems
• Data sparsity-clustering and classification challenging
become negligible
• High dimension refers to the challenges and complications that arises when
analyzing and organising data in high-dimensional spaces(100-1000 dimensions).
• “dimensional reduction”.
• By this we can retain the most important information in dataset while discarding
the redundant or less important features
Dimensional reduction methods
• Correct means agrees with target concept on labels for all data.
Probably Approximately Correct (PAC) learning
• PAC learning to find a hypothesis that performs well on unseen examples given a sample
of labeled data for training.
• Supervised learning
• Sample selection
• Active learning
• PAC learning plays a role in shaping the design, evaluation, and analysis of machine
learning algorithms.
• PAC learning is to design algorithms that can learn a target concept with high
probability and accuracy, given a finite amount of labeled training data.
• Concept Class(C): set of all possible target concepts. The goal is for learning
algorithms to output a hypothesis that approximates the true concepts.
• Eg: gender
• X1ΛX2
• Noise tolerance:
• PAC learning often assumes that the training data may contain some
amount of noise or errors.
• Y=mx+c
Contd..
• Where,
• Y-range
• X-domain
• C-intercept(constant)
• Preventing overfitting- a model with no bias might fit with the training
data perfectly, capturing every minute detail, including noise.
• For example, in decision tree algorithms like ID3, the preference is for
shorter trees over longer trees.
• Supervised learning in the domain of machine learning refers to a way for the
model to learn and understand data. based on this training data, the model
learns to make predictions.
• Generalization examines how well a model can digest new data and make
Contd..
• A model is able to generalize is the key to its success.
• If you train a model too well on training data, it will be incapable of generalizing.
In such cases, it will end up making erroneous predictions when its given new
data. This would make the model ineffective even though its capable of making
corrections predictions for the training dataset. This is known as overfitting.
• The inverse(underfitting) is also true, which happens when you train
a model with inadequate data.
• In case of underfitting, your model would fail to make accurate predictions even
with the training data.
• This would make the model just as useless overfitting.
• Generalization is a measure of how your model performs on predicting unseen
data.so it is important to come up with the best-generalized model to give
better performance against future data.
Contd..
• Let us first understand what is underfitting and overfitting, and then
see what are the best practices to train a generalized model.
What is underfitting?
• Underfitting is a state where the model cannot model itself on the
training data. and also not able to generalize new data.
• You can notice it with the help of loss function during your training.
• If the model is very simple with fewer parameters, it may have low variance
and high bias.
• Trade-off
• While inductive bias helps models generalize from training data,
there’s a trade-off.
• A strong inductive bias means the model might not be flexible enough
to capture all patterns in the data.
• On the other hand, a bias that is too weak could lead the model to
overfit the training data.
• Inductive bias is the “background knowledge” or assumptions that
guide a machine learning algorithm.
• It’s essential for generalization, especially when the training data is
noisy.
• However, choosing the right type and amount of inductive bias for a
particular problem is an art and is crucial for the success of the
model.
variance
• A model is said to have high variance if its predictions are sensitive to
small challenge in the input.
• When a model does not perform as well as it does with the trained
data set, there is a possibility the model has a variance.
• It basically tells how scattered the predicted values are from the
actual values
• Bias: error in training data
• Variance: error in the data
• Overfitting: a statistical model is said to be overfitted when we feed it
a lot more data than necessary. Training data accuracy is high and test
data accuracy is low.
• Underfitting: in order to avoid overfitting, we could stop the training
at an earlier stage.
• Training data acc is low and test data acc is low underfitting would
imply that the model has still capacity to learn, so you would simply
train for more iterations or collect more data.
Bias-variance trade off
• It is a standalone theory that provides a different perspective on
generalization.