100% found this document useful (1 vote)
21 views13 pages

Unit 1

Computer science and engineering

Uploaded by

kmwtkuldeep1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
21 views13 pages

Unit 1

Computer science and engineering

Uploaded by

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

Unit-I

Machine learning
Machine learning is programming computers to optimize a performance
criterion using example data or past experience. We have a model
defined up to some parameters, and learning is the execution of a
computer program to optimize the parameters of the model using the
training data or past experience. The model may be predictive to make
predictions in the future, or descriptive to gain knowledge from data, or
both.

Arthur Samuel, an early American leader in the field of computer gaming


and artificial intelligence, coined the term “Machine Learning” in 1959
while at IBM. He defined machine learning as “the field of study that
gives computers the ability to learn without being explicitly programmed.”
However, there is no universally accepted definition for machine learning.
Different authors define the term differently.
Types of Learning
In general, machine learning algorithms can be classified into three
types.
a. Supervised learning
b. Unsupervised learning
c. Reinforcement learning

Supervised learning

A training set of examples with the correct responses (targets) is


provided and, based on this training set, the algorithm generalises to
respond correctly to all possible inputs. This is also called learning from
exemplars. Supervised learning is the machine learning task of learning
a function that maps an input to an output based on example input-
output pairs.
In supervised learning, each example in the training set is a pair
consisting of an input object (typically a vector) and an output value. A
supervised learning algorithm analyzes the training data and produces a
function, which can be used for mapping new examples. In the optimal
case, the function will correctly determine the class labels for unseen
instances. Both classification and regression problems are supervised
learning problems. A wide range of supervised learning algorithms are
available, each with its strengths and weaknesses. There is no single
learning algorithm that works best on all supervised learning problems.

Unsupervised learning
Correct responses are not provided, but instead the algorithm tries to
identify similarities between the inputs so that inputs that have
something in common are categorised together. The statistical
approach to unsupervised learning is known as density estimation.
Unsupervised learning is a type of machine learning algorithm used to
draw inferences from datasets consisting of input data without labeled
responses. In unsupervised learning algorithms, a classification or
categorization is not included in the observations. There are no output
values and so there is no estimation of functions. Since the examples
given to the learner are unlabeled, the accuracy of the structure that is
output by the algorithm cannot be evaluated. The most common
unsupervised learning method is cluster analysis, which is used for
exploratory data analysis to find hidden patterns.

Reinforcement learning

This is somewhere between supervised and unsupervised learning. The


algorithm gets told when the answer is wrong, but does not get told how
to correct it. It has to explore and try out different possibilities until it
works out how to get the answer right. Reinforcement learning is
sometime called learning with a critic because of this monitor that
scores the answer, but does not suggest improvements.
Reinforcement learning is the problem of getting an agent to act in the
world so as to maximize its rewards. A learner (the program) is not told
what actions to take as in most forms of machine learning, but instead
must discover which actions yield the most reward by trying them. In the
most interesting and challenging cases, actions may affect not only the
immediate reward but also the next situations and, through that, all
subsequent rewards.

 Perspectives in Machine Learning


One useful perspective on machine learning is that it involves searching
a very large space of possible hypotheses to determine one that best fits
the observed data and any prior knowledge held by the learner.
For example, consider the space of hypotheses that could in principle be
output by the above checkers learner. This hypothesis space consists of
all evaluation functions that can be represented by some choice of
values for the weights wo through w6. The learner's task is thus to
search through this vast space to locate the hypothesis that is most
consistent with the available training examples. The LMS algorithm for
fitting weights achieves this goal by iteratively tuning the weights, adding
a correction to each weight each time the hypothesized evaluation
function predicts a value that differs from the training value. This
algorithm works well when the hypothesis representation considered by
the learner defines a continuously parameterized space of potential
hypotheses.
Many of the chapters in this book present algorithms that search a
hypothesis space defined by some underlying representation (e.g., linear
functions, logical descriptions, decision trees, artificial neural networks).
These different hypothesis representations are appropriate for learning
different kinds of target functions. For each of these hypothesis
representations, the corresponding learning algorithm takes advantage
of a different underlying structure to organize the search through the
hypothesis space.
Throughout this book we will return to this perspective of learning as a
search problem in order to characterize learning methods by their search
strategies and by the underlying structure of the search spaces they
explore. We will also find this viewpoint useful in formally analyzing the
relationship between the size of the hypothesis space to be searched,
the number of training examples available, and the confidence we can
have that a hypothesis consistent with the training data will correctly
generalize to unseen examples.

 Issues in Machine Learning


Our checkers example raises a number of generic questions about
machine learning. The field of machine learning, and much of this book,
is concerned with answering questions such as the following:
What algorithms exist for learning general target functions from
specific training examples? In what settings will particular algorithms
converge to the desired function, given sufficient training data? Which
algorithms perform best for which types of problems and
representations?
How much training data is sufficient? What general bounds can be
found to relate the confidence in learned hypotheses to the amount of
training experience and the character of the learner's hypothesis space?
When and how can prior knowledge held by the learner guide the
process of generalizing from examples? Can prior knowledge be helpful
even when it is only approximately correct?
What is the best strategy for choosing a useful next training experience,
and how does the choice of this strategy alter the complexity of the
learning problem?
What is the best way to reduce the learning task to one or more
function approximation problems? Put another way, what specific
functions should the system attempt to learn? Can this process itself be
automated?
How can the learner automatically alter its representation to improve
its ability to represent and learn the target function?

Classification

Classification is a process of finding a function which helps in dividing


the dataset into classes based on different parameters. In Classification,
a computer program is trained on the training dataset and based on that
training, it categorizes the data into different classes.

The task of the classification algorithm is to find the mapping function


to map the input(x) to the discrete output(y).
Example: The best example to understand the Classification problem is
Email Spam Detection. The model is trained on the basis of millions of
emails on different parameters, and whenever it receives a new email, it
identifies whether the email is spam or not. If the email is spam, then it
is moved to the Spam folder.
Types of ML Classification Algorithms:
Classification Algorithms can be further divided into the following types:

Logistic Regression
K-Nearest Neighbours
Support Vector Machines
Kernel SVM
Naïve Bayes
Decision Tree Classification
Random Forest Classification

Regression

Regression Analysis in Machine learning

Regression analysis is a statistical method to model the relationship


between a dependent (target) and independent (predictor) variables with
one or more independent variables. More specifically, Regression
analysis helps us to understand how the value of the dependent variable
is changing corresponding to an independent variable when other
independent variables are held fixed. It predicts continuous/real values
such as temperature, age, salary, price, etc.

Types of Regression
 Linear Regression
 Logistic Regression

 Linear Regression

Linear regression is one of the easiest and most popular Machine


Learning algorithms. It is a statistical method that is used for predictive
analysis. Linear regression makes predictions for continuous/real or
numeric variables such as sales, salary, age, product price, etc.

Linear regression algorithm shows a linear relationship between a


dependent (y) and one or more independent (y) variables, hence called
as linear regression. Since linear regression shows the linear
relationship, which means it finds how the value of the dependent
variable is changing according to the value of the independent variable.
The linear regression model provides a sloped straight line representing
the relationship between the variables.
Consider the below image:

Mathematically, we can represent a linear regression as:

Y=MX+C
Here,
Y= Dependent Variable (Target Variable)
X= Independent Variable (predictor Variable)
M and C are the linear coefficients

The values for x and y variables are training datasets for Linear
Regression model representation.

Types of Linear Regression

Linear regression can be further divided into two types of the algorithm:

 Simple Linear Regression:


If a single independent variable is used to predict the value of a
numerical dependent variable, then such a Linear Regression algorithm
is called Simple Linear Regression.
 Multiple Linear regression:
If more than one independent variable is used to predict the value of a
numerical dependent variable, then such a Linear Regression algorithm
is called Multiple Linear Regression.
 Logistic Regression:

 Logistic regression is another supervised learning algorithm which


is used to solve the classification problems. In classification
problems, we have dependent variables in a binary or discrete
format such as 0 or 1.
 Logistic regression algorithm works with the categorical variable
such as 0 or 1, Yes or No, True or False, Spam or not spam, etc.
 It is a predictive analysis algorithm which works on the concept of
probability.
 Logistic regression is a type of regression, but it is different from
the linear regression algorithm in the term how they are used.
 Logistic regression uses sigmoid function or logistic function
which is a complex cost function. This sigmoid function is used to
model the data in logistic regression. The function can be
represented as:

 f(x)= Output between the 0 and 1 value.


 x= input to the function
 e= base of natural logarithm
When we provide the input values (data) to the function, it gives the S-
curve as follows

 Decision Tree
Introduction Decision Trees are a type of Supervised Machine Learning
(that is you explain what the input is and what the corresponding output
is in the training data) where the data is continuously split according to a
certain parameter. The tree can be explained by two entities, namely
decision
nodes and leaves. The leaves are the decisions or the final outcomes.
And the decision nodes are where the data is split.

An example of a decision tree can be explained using above binary tree.


Let’s say you want to predict whether a person is fit given their
information like age, eating habit, and physical activity, etc.

 Support Vector Machines

Support Vector Machine or SVM is one of the most popular Supervised


Learning algorithms, which is used for Classification as well as
Regression problems. However, primarily, it is used for Classification
problems in Machine Learning. The goal of the SVM algorithm is to
create the best line or decision boundary that can segregate n-
dimensional space into classes so that we can easily put the new data
point in the correct category in the future. This best decision boundary is
called a hyperplane.
SVM chooses the extreme points/vectors that help in creating the
hyperplane. These extreme cases are called as support vectors, and
hence algorithm is termed as Support Vector Machine. Consider the
below diagram in which there are two different categories that are
classified using a decision boundary
or hyperplane:

Example: SVM can be understood with the example that we have used in
the KNN classifier. Suppose we see a strange cat that also has some
features of dogs, so if we want a model that can accurately identify
whether it is a cat or dog, so such a model can be created by using the
SVM algorithm.

We willfirst train our model with lots of images of cats and dogs so that
it can learn about different features of cats and dogs, and then we test it
with this strange creature. So as support vector creates a decision
boundary between these two data (cat and dog) and choose extreme
cases (support vectors), it will see the extreme case of cat and dog. On
the basis of the support vectors, it will classify it as a cat. Consider the
below diagram:
SVM algorithm can be used for Face detection, image classification, text
categorization, etc.

SVM can be of two types:

 Linear SVM: Linear SVM is used for linearly separable data, which
means if a dataset can be classified into two classes by using a
single straight line, then such data is termed as linearly separable
data, and classifier is used called as Linear SVM classifier.

 Non-linear SVM: Non-Linear SVM is used for non-linearly separated


data, which means if a dataset cannot be classified by using a
straight line, then such data is termed as non-linear data and
classifier used is called as Non-linear SVM classifier.

 Linear SVM:

The working of the SVM algorithm can be understood by using an


example. Suppose we have a dataset that has two tags (green and blue),
and the dataset has two features x1 and x2. We want a classifier that
can classify the pair(x1, x2) of coordinates in either green or blue.
Consider the below image:
So as it is 2-d space so by just using a straight line, we can easily
separate these two classes. But there can be multiple lines that can
separate these classes. Consider the below image:

 Non-Linear SVM:

If data is linearly arranged, then we can separate it by using a straight


line, but for non-linear data, we cannot draw a single straight line.
Consider the below image:
So to separate these data points, we need to add one more dimension.
For linear data, we have used two dimensions x and y, so for non-linear
data, we will add a third dimension z. It can be calculated as:
z=x2 +y2
By adding the third dimension, the sample space will become as below
image:

So now, SVM will divide the datasets into classes in the following way.
Consider the below image:
Since we are in 3-d Space, hence it is looking like a plane parallel to the x
-axis. If we convert it in 2d space with z=1, then it will become as:

Hence we get a circumference of radius 1 in case of non-linear data.

You might also like