0% found this document useful (0 votes)
15 views73 pages

Unit No. 1

Uploaded by

patilshahu9507
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views73 pages

Unit No. 1

Uploaded by

patilshahu9507
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 73

INTRODUCTION

SOPHIA ROBOT
FACEBOOK
FRAUD WITHIN BANK
GOAL OF MACHINE LEARNING

Input Output

Identification
Image Image
Search
ML ………

Speech recognition
Audio Music classification
Speaker identification
………….
ML

Anti-spam
Machine translation
Tex Sentiment analysis
t Summarization
ML
WHY MACHINE LEARNING?
• Computer also should be in position to take decisions autonomously and intelligently
based on the information given (Just like Humans)
• Human learn from experience and computer only follows instruction.
• Different approach than typical programming.
• In regular programming logic that needs intelligence is developed by developer and
computer merely follows the logic.
• Computer’s ability to perform operations much faster than humans is focused.
• Give experience directly to computer to learn and prepare itself for action
• Define the experience in a structured format
• So, computer learn from data(experience) and this process is called “Machine Learning”
PROBLEMS THAT HUMAN CAN NOT ANSWER

• Despite Highest Intelligence, Human can not answer many Questions


• What will be the situation of covid-19 in October 2022?
• What will be gold price next week?
• How many tourists will visit Kolhapur next week?
• How much rainfall will be there in the next year in India?
• These problems don’t have fixed algorithm, so we can not write typical C Program.
• In Case of Humans we call this as “Ability of prediction”
• Humans try to find out answer to these question by using available information with
them.
SPECIAL ABILITIES OF HUMAN

• Ability to Predict
• Ability to Classify
• Ability of Grouping
• Ability of Vision
• Language Understanding
MACHINE LEARNING APPLICATIONS
MACHINE LEARNING APPLICATIONS
MACHINE LEARNING APPLICATIONS
DEFINITIONS

• Machine learning is the training of a model from data that generalizes a decision against
a performance measure.
• "A computer program is said to learn from experience E with respect to some class of
tasks T and performance measure P, if its performance at tasks in T, as measured by P,
improves with experience E.“
• For Example, Machine learning behaves similarly to the growth of a child. As a child
grows, her experience E in performing task T increases, which results in higher
performance measure (P).
LEARNING PROBLEMS

• Handwriting recognition learning problem


• Task T: recognizing and classifying handwritten words within images
• Performance measure P : percent of words correctly classified
• Training experience E: a database of handwritten words with given
classifications
WHAT IS LEARNING?

• Learning is the process of acquiring new or modifying existing knowledge,


behaviour, skills, values, or preferences.
WHAT IS LEARNING?
MACHINE LEARNING -ARCHITECTURE

Model
Data (algorithms, Output
parameters)
MACHINE LEARNING -ARCHITECTURE
MACHINE LEARNING -ARCHITECTURE
WHAT IS LEARNING

• The following are some considerations to define a learning problem:


1. Provide a definition of what the learner should learn and the need for
learning.
2. Define the data requirements and the sources of the data.
3. Define if the learner should operate on the dataset in entirety or a subset will
do.
• As a first step, the given data is segregated into three datasets: training, validation,
and testing.
• There is no one hard rule on what percentage of data should be training, validation,
and testing datasets. It can be 70-10-20, 60-30-10, 50-25-25, or any other values.
TERMINOLOGY

• For performing Machine learning, there are primarily two types of datasets required.
• Training Dataset and Testing Dataset
• Training dataset: It is usually manually prepared, where the input data and the
expected output data are available and prepared. It is important that every piece of
input data has an expected output data point available
• Testing Dataset: It is where we have the input data, and we are interested in predicting
the expected output.
• But there are three datasets are available in Machine learning
• Training dataset, Validation dataset and Testing dataset
• Validation Dataset: The validation dataset refers to the data examples that are verified
against the built classifier and can help tune the accuracy of the output.
TERMINOLOGY

• There are typically three phases for performing Machine learning:


• Phase 1—Training Phase: This is the phase where training data is used to train the
model by pairing the given input with the expected output. The output of this phase is
the learning model itself.

• Phase 2—Validation and Test Phase: This phase is to measure how good the learning
model that has been trained is and estimate the model properties, such as error
measures, recall, precision, and others. This phase uses a validation dataset, and the
output is a sophisticated learning model.

• Phase 3—Application Phase: In this phase, the model is subject to the real-world data
for which the results need to be derived.
COMPONENTS OF MACHINE LEARNING SYSTEM - DATA

• Data forms the main source of learning in Machine learning


• Data is a representation of human experience in machine learning system.
• Data can be any format – structured, semi-structured and unstructured
• Data can be received at any frequency, can be static or dynamic
• Data can be of any size
• Data can have any dimensions (number of features or attributes)
TERMS RELATED TO DATA
TERMS RELATED TO DATA

Term Purpose or meaning in the context of Machine learning


Dataset A collection of rows or instances is called a dataset. In the context of Machine
learning, there are different types of datasets that are meant to be used for
different purposes. An algorithm is run on different datasets at different stages to
measure the accuracy of the model. There are three types of dataset: training,
testing,
and validation datasets. Any given comprehensive dataset is split into three
categories of datasets and is usually in the following proportions: 60% training, 30%
testing, and 10% validation.

a. Training Dataset The training dataset is the dataset that is the base dataset against which the model
is built or trained.
b. Testing Dataset The testing dataset is the dataset that is used to validate the model built. This
dataset is also referred to as a validating dataset.

c. Validation Dataset It is the dataset that is used for final verification of the model (and can be treated
more as user acceptance testing).
TERMS RELATED TO DATA

Name Address Email ID Birthdate


Ichalkaranji 22/06/1995
Bagawade Akash [email protected]
Ichalkaranji 25/12/1995
Bandal Sonali [email protected]
Kolhapur 2/08/1995
Bhendawade Niyojita [email protected]
Pune 20/01/1995
Deshinge Swapnali [email protected]
Pune 28/03/1995
Durgule Supriya [email protected]

• Feature: Name or address or email id or birth date


•Instance: Bandal Sonali Ichalkaranji [email protected] 25/12/1995
• Feature Vector or Tuple : <name,adrees> <name,email Id>, <name, Birth date> etc any
combination
• Dimension : birth date divided into three categories day, month and year
TERMS RELATED TO DATA

• Labeled Data and Unlabeled Data


• The learning models can be applied to both labeled and unlabeled data. We can derive more
accurate models using a combination of labeled and unlabeled datasets.
• The following diagram represents labeled and unlabeled data.
TERMS RELATED TO DATA

• Labeled Data and Unlabeled Data


• Data in the Machine learning context can either be labeled or unlabeled.
• Unlabeled data is usually the raw form of the data.
• It consists of samples of natural or human-created artifacts. This category of data is easily
available
• For example, video streams, audio, photos, and tweets among others. This form of data
usually has no explanation of the meaning attached.
• The unlabeled data becomes labeled data the moment a meaning is attached. i.e. attaching a
“tag” or “label” that is required, and is mandatory, to interpret and define the relevance.
• For example, labels for a photo can be the details of what it contains, such as animal, tree,
college, and so on
• Labeled data is more expensive to obtain than the unlabeled raw data.
MODEL

• Model is the representation of real life object. It mimics behaviour of the object it
represent.
• A simplified description, especially a mathematical one, of a system or process, to assist
calculations and predictions (oxford dictionary).
• mathematical model : a representation in mathematical terms of the behaviour of real
devices and objects
• Models are the output of algorithms applied to a dataset.
CATEGORIES OF MODELS

• Logical Models
• Logical models are more algorithmic in nature and help us derive a set of rules by running
the algorithms iteratively. A Decision tree is one such example

• Geometric Models
• Geometric models use geometric concepts such as lines, planes, and distances. These
models usually operate, or can operate, on high volumes of data

• Probabilistic Models
• Probabilistic models are statistical models that employ statistical techniques. These
models are based on a strategy that defines the relationship between two variables.
TYPES OF LEARNING PROBLEMS

• Classification
• Regression
• Clustering
• Optimization
• Simulation
CLASSIFICATION

• A classification problem is when the output variable is a category, such as “red” or “blue” or
“disease” and “no disease”.
• A classification model attempts to draw some conclusion from observed values.
• For example, when filtering emails “spam” or “not spam”, when looking at transaction data,
“fraudulent”, or “authorized”.
• In short Classification either predicts categorical class labels or classifies data (construct a
model) based on the training set and the values (class labels) in classifying attributes and
uses it in classifying new data.
• There are a number of classification models.
• Classification models include logistic regression, decision tree, random forest, gradient-
boosted tree, multilayer perceptron, one-vs-rest, and Naive Bayes.
CLASSIFICATION
CLASSIFICATION

• Which of the following is/are classification problem(s)?

a) Predicting the gender of a person by his/her handwriting style


b) Predicting house price based on area
c) Predicting whether monsoon will be normal next year
d) Predict the number of copies a music album will be sold next month
REGRESSION

• A regression problem is when the output variable is a real or continuous value, such as
“salary” or “weight”.
• Many different models can be used, the simplest is the linear regression. It tries to fit data
with the best hyper-plane which goes through the points.
REGRESSION

• Which of the following is a regression task?

a) Predicting age of a person


b) Predicting nationality of a person
c) Predicting whether stock price of a company will increase tomorrow
d) Predicting whether a document is related to hospital?
CLUSTERING

• The method of identifying similar groups of data in a data set is called clustering.
• Entities in each group are comparatively more similar to entities of that group than those of
the other groups.
• It is process of finding meaningful structure and grouping the similar things
• i.e. data in the same group is more similar to other data in the same group and dissimilar to
other data which are present in different groups.
• Unlabelled datasets uses clustering technique.
CLUSTERING

• The data points in the graph below clustered together can be classified into one single
group. We can distinguish the clusters, and we can identify that there are 3 clusters in the
below picture.

It is not necessary
for clusters to be a
spherical.
MACHINE LEARNING TECHNIQUES

• A technique is a way of solving a problem.

• For example, classification is a technique for grouping things that are similar.

• To actually do classification on some data, a data scientist would have to employ a specific
algorithm like Decision Trees (though there are many other classification algorithms to
choose from).
MACHINE LEARNING TECHNIQUES

• Supervised Learning

• Unsupervised Learning

• Reinforcement Learning
SUPERVISED LEARNING

• Supervised Learning
• Supervised learning is similar to human learning in presence of Supervisor or Teacher.
• Supervisor/Teacher’s roll is to provide correct feedback to learner.
• Example: Teacher shows set of dog’s images and informs student that these are of Dogs.
student learns from the images the animal called DOG
• What student understands is the properties of dogs that identifies it as dog like its face,
color, voice, etc.
• Parent show the child animals like dogs, cats and help them to recognize them.
SUPERVISED LEARNING

• In Machine Learning, A machine learning model learns from given examples presented in
the form of data.

• Input to machine learning model is data and its various attributes are properties through
which model learns.

• Similar to teacher in human learning, Along with the data the correct output is also
provided that helps model to learn.
SUPERVISED LEARNING

Data Values Output


Attributes(Proper
ties) Model Learns as
Color Brown Dog
Height 24 inch Dog

Legs 4

Data Values Output


Attributes(Propertie
s)
Model Learns as
No of wheels 4 Vehicle- Car
Vehicle- car
gears 6
Max speed 200
Weight 800 Kg
SUPERVISED LEARNING

• Supervised learning occurs when an algorithm learns from example data and associated
target responses that can consist of numeric values or string labels, such as classes or tags,
in order to later predict the correct response when posed with new examples.

• The aim of supervised machine learning is to build a model that makes predictions based on
evidence in the presence of uncertainty.

• A supervised learning algorithm takes a known set of input data and known responses to
the data (output) and trains a model to generate reasonable predictions for the response to
new data.
SUPERVISED LEARNING

• List of Common Algorithms in Supervised Learning:


• Nearest Neighbour Classifier
• Naive Bayes
• Decision Trees
• Linear Regression
• Support Vector Machines (SVM)
• Neural Networks
UNSUPERVISED LEARNING

• This is learning without teachers. Its learning a new concept comparing it with another concept.
• This is basically human’s ability to group similar elements
• Examples:
• Humans group banana, apple, orange, etc as fruits because they are from trees and eaten
without cooking or any other processing. (hence common attributes among these are “ grown
on tree” and “eaten without cooking”)
• Humans group notebooks, pen, books, pencil as school stationary because these are useful in
school. (hence a common attribute among these is “ useful in school”)
• It resembles the methods humans use to figure out that certain objects or events are from the
same class, such as by observing the degree of similarity between objects.
• Important characteristics of unsupervised learning is to find similarity between two Events or
objects.
UNSUPERVISED LEARNING

• Unsupervised learning finds hidden patterns or intrinsic structures in data.


• It is used to draw inferences from datasets consisting of input data without labeled
(unlabelled) responses.
• Unsupervised learning occurs when an algorithm learns from plain examples without any
associated response, leaving to the algorithm to determine the data patterns on its own.
• Examples:
• Find high crime area for setting up patrol vans
• Find maximum accident prone areas for setting up emergency care wards of an hospital
• Grouping documents into different categories/topics based on the words used in the
documents
UNSUPERVISED LEARNING

Grouping of six fruits given


below:
Fruit Common Attribute - color Category(Group)

Mango Yellow Ripe Fruit

banana Yellow

guava Yellow

Mango Green Raw Fruit

banana Green

guava Green
UNSUPERVISED LEARNING

• Unsupervised learning is where you only have input data (X) and no corresponding output
variables.

• The goal for unsupervised learning is to model the underlying structure or distribution in
the data in order to learn more about the data.

• These are called unsupervised learning because unlike supervised learning above there is
no correct answers and there is no teacher. Algorithms are left to their own devises to
discover and present the interesting structure in the data.
REINFORCEMENT LEARNING

• Reinforcement Learning(RL) is a machine learning technique that enables model to learn in


an interactive environment by trial and error using feedback from its own actions and
experiences.
• Both supervised and reinforcement learning use mapping between input and output, unlike
supervised learning where the feedback provided to the model is correct set of actions for
performing a task, reinforcement learning uses rewards and punishments as signals for
positive and negative behaviour.
MODEL PERFORMANCE

• Is the solution created good?


- Model may or may not give accurate results
- If the model is not giving accurate result, how to measure error?
• If a machine learning model is predicting house prices in a city, then how much
accurately it Is predicting it?
MEASURING PREDICTION PERFORMANCE
Training Data
No. of Size Age of Price
Room the
s House Model
3 500 10 25L
5 1000 5 50L
5 1000 7 45L

Testing Data
No. of Size Age of Price
Room the (Actual)
s House Performance
3 700 12 21L Trained Model
5 1200 4 60L Measuremen
t
6 1500 6 65L
MEASURING ERROR(ERROR METRICS) : FOR PREDICTION TYPE
MODELS

1. Mean Square Error(MSE)


Pi - Predicted value of the ith
record
Ai - Actual value of the ith record
n -Total Records

• If MSE is zero or close to zero, model is predicting the value accurately


• Larger MSE value indicate poor
• Model Performance and needs further training
• It is also common to use square root of this MSE called root mean square error
(RMSE)
MEASURING ERROR(ERROR METRICS) : FOR PREDICTION TYPE
MODELS

2. Mean absolute error (MAE):

Pi - Predicted value of the ith


record
Ai - Actual value of the ith record
n -Total Records
MEASURING ERROR(ERROR METRICS) : FOR CLASSIFICATION TYPE
MODELS

• Confusion Matrix(Error Matrix) in Machine Learning


• A confusion matrix is a table that is often used to describe the performance of a
classification model (or “classifier”) on a set of test data for which the true values are
known.
• It is a two by two table that contains four outcomes produced by a binary classifier.
• It allows the visualization of the performance of an algorithm.
• Most performance measures are computed from the confusion matrix.
• A confusion matrix is a summary of prediction results on a classification problem.
MEASURING ERROR(ERROR METRICS) : FOR CLASSIFICATION TYPE
MODELS

• The number of correct and incorrect predictions are summarized with count values and
broken down by each class. This is the key to the confusion matrix.
• The confusion matrix shows the ways in which your classification model is confused when it
makes predictions.
• It gives us insight not only into the errors being made by a classifier but more importantly
the types of errors that are being made.
MEASURING ERROR(ERROR METRICS) : FOR CLASSIFICATION TYPE
MODELS

Training Images Model


Cat, Algorithm
Dog, Knowledg
Rabbit e

Testing Images Model


C at, Dog, Algorithm Output
Rabbit Knowledg
e
MEASURING ERROR(ERROR METRICS) : FOR CLASSIFICATION TYPE
MODELS

• A confusion matrix is formed from the four outcomes produced as a result of binary
classification.
• Four outcomes of classification
• A binary classifier predicts all data instances of a test dataset as either positive or negative.
• This classification (or prediction) produces four outcomes – true positive, true negative,
false positive and false negative.

• True positive (TP): correct positive prediction


• False positive (FP): incorrect positive prediction
• True negative (TN): correct negative prediction
• False negative (FN): incorrect negative prediction
MEASURING ERROR(ERROR METRICS) : FOR CLASSIFICATION TYPE
MODELS

Definition of the Terms:


• Positive (P) : Observation is positive (for example: is cat).
• Negative (N): Observation is not positive (for example: is not cat).
• True positive (TP): Observation is positive, and is predicted to be positive.
• False positive (FP): Observation is negative, but is predicted positive.
• True negative (TN): Observation is negative, and is predicted to be negative
• False negative (FN): Observation is positive, but is predicted negative.
MEASURING ERROR(ERROR METRICS) : FOR CLASSIFICATION TYPE
MODELS

• We usually denote them as TP, FP, TN, and FN instead of “the number of true positives”, and
so on.

Actual Class

True Positive False Positive


(TP) (FP)
Predicted Class
False Negative True Negative
(FN) (TN)
MEASURING ERROR(ERROR METRICS) : FOR CLASSIFICATION TYPE
MODELS

SR. Input Model SR. Input Model


No Image Prediction No Image Prediction

1 Cat Dog 14 Cat Dog


2 Dog Dog 15 Dog Rabbit
3 Rabbit Dog 16 Rabbit Rabbit
4 Cat Cat 17 Cat Cat
5 Dog Cat 18 Rabbit Rabbit
6 Dog Dog 19 Rabbit Rabbit
7 Rabbit Rabbit 20 Rabbit Rabbit
8 Cat Cat 21 Cat Cat
9 Dog Dog 22 Dog Cat
10 Rabbit Rabbit 23 Rabbit Rabbit
11 Rabbit Rabbit 24 Rabbit Rabbit
12 Rabbit Dog 25 Rabbit Rabbit
13 Cat Cat 26 Cat Dog
27 Rabbit Rabbit
MEASURING ERROR(ERROR METRICS) : FOR CLASSIFICATION TYPE
MODELS

Actual class (True Class)

Cat Non-cat

Cat 5 True Positives 2 False Positives


Predicted
class
Non-cat 3 False Negatives 17 True Negatives
MEASURING ERROR(ERROR METRICS) : FOR CLASSIFICATION TYPE
MODELS

• Assuming a sample of 27 animals — 8 cats, 6 dogs, and 13 rabbits, the resulting confusion
matrix could look like the table below:
PERFORMANCE MEASUREMENT METRICS

• Following are the metrics used for the Classification Models in the Machine Learning:

1. Accuracy
2. Recall / Sensitivity
3. Precision
4. Specificity
CLASSIFICATION RATE / ACCURACY

• Classification Rate or Accuracy is given by the relation


RECALL / SENSITIVITY

• Recall/Sensitivity can be defined as the ratio of the total number of correctly classified
positive examples divide to the total number of positive examples.

• High Recall indicates the class is correctly recognized (small number of FN).
• Recall is given by the relation:
PRECISION

• To get the value of precision we divide the total number of correctly classified positive
examples by the total number of predicted positive examples.
• High Precision indicates an example labelled as positive is indeed positive (small number of
FP).
• Precision is given by the relation:
SPECIFICITY

• Specificity is the ration of True Negative to Total actual Negative

• Total actual Negative = TN + FP (Negatives That has be predicted as positive)


MACHINE LEARNING PROCESS

• It is process that start with defining the data and ends with the model with some defined level
of accuracy.
1. Define Problem
2. Collect data
3. Prepare Data
4. Split data in training validation and testing
5. Algorithm Selection
6. Training the algorithm
7. Evaluate Test Data
8. Parameter Tuning
9. Start Using the model
MACHINE LEARNING PROCESS

1. Define Problem
• What is the problem?
• Why does this problem need a solution?
2. Collect the Data
• By scraping the website
• Different survey
• Sensors
• Website logs
MACHINE LEARNING PROCESS

3. Prepare the Data


• Cleaning
• Formatting
• Sampling
• Decomposition
• scaling

You might also like