Linear classifier and gradient descent
$begingroup$
I understood that gradient descent is needed to find the local extremum of any function, but how is it applied to the linear classifier (single matrix, two classes case, for example)? How does it step by step modify the elements of this matrix?
classification gradient-descent
$endgroup$
add a comment |
$begingroup$
I understood that gradient descent is needed to find the local extremum of any function, but how is it applied to the linear classifier (single matrix, two classes case, for example)? How does it step by step modify the elements of this matrix?
classification gradient-descent
$endgroup$
add a comment |
$begingroup$
I understood that gradient descent is needed to find the local extremum of any function, but how is it applied to the linear classifier (single matrix, two classes case, for example)? How does it step by step modify the elements of this matrix?
classification gradient-descent
$endgroup$
I understood that gradient descent is needed to find the local extremum of any function, but how is it applied to the linear classifier (single matrix, two classes case, for example)? How does it step by step modify the elements of this matrix?
classification gradient-descent
classification gradient-descent
asked 2 days ago
r1d1r1d1
374
374
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
Let us break this down into a few steps for better understanding:
Your linear classifier let us represent it with an equation y :
y = m1x1 + m2x2 + m3x3 + .....
where y takes into account all the features you have provided, multiplies it with random weightsm
.Now you need to find the ideal values of
m
in order for you to get maximum accuracy. You could ofcourse brute force your way but there are optimized ways to do this. This is where gradient descent comes into play.Gradient descent optimizes the values of
m
by taking into account the final output and understanding which features are important and which are not.The loss function determines what is to be compared. In your example you are talking about two classes, in this case, the loss function will be a simple cross entropy loss function, that tells you how far you are from the actual values.
The loss is the difference in the predicted value vs actual value.
The only way you can minimize this loss is by playing around with weights. In order to understand which weights to play around with, you use simple first order derivatives to associate impact of output with each feature multiple by its weight.
Gradient descent is then used to compute the next set of weights that helps you reduce the loss by looking at the direction of weights to be used.
When you run this thru multiple epochs and steps, it stabilizes this weight matrix thereby improving performance of your model.
Hope this clears your question, would be happy to elaborate in case you need it.
$endgroup$
$begingroup$
Thx, can you write small example of performing one step for weights correction for model with three predictors?
$endgroup$
– r1d1
2 days ago
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "557"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f47072%2flinear-classifier-and-gradient-descent%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Let us break this down into a few steps for better understanding:
Your linear classifier let us represent it with an equation y :
y = m1x1 + m2x2 + m3x3 + .....
where y takes into account all the features you have provided, multiplies it with random weightsm
.Now you need to find the ideal values of
m
in order for you to get maximum accuracy. You could ofcourse brute force your way but there are optimized ways to do this. This is where gradient descent comes into play.Gradient descent optimizes the values of
m
by taking into account the final output and understanding which features are important and which are not.The loss function determines what is to be compared. In your example you are talking about two classes, in this case, the loss function will be a simple cross entropy loss function, that tells you how far you are from the actual values.
The loss is the difference in the predicted value vs actual value.
The only way you can minimize this loss is by playing around with weights. In order to understand which weights to play around with, you use simple first order derivatives to associate impact of output with each feature multiple by its weight.
Gradient descent is then used to compute the next set of weights that helps you reduce the loss by looking at the direction of weights to be used.
When you run this thru multiple epochs and steps, it stabilizes this weight matrix thereby improving performance of your model.
Hope this clears your question, would be happy to elaborate in case you need it.
$endgroup$
$begingroup$
Thx, can you write small example of performing one step for weights correction for model with three predictors?
$endgroup$
– r1d1
2 days ago
add a comment |
$begingroup$
Let us break this down into a few steps for better understanding:
Your linear classifier let us represent it with an equation y :
y = m1x1 + m2x2 + m3x3 + .....
where y takes into account all the features you have provided, multiplies it with random weightsm
.Now you need to find the ideal values of
m
in order for you to get maximum accuracy. You could ofcourse brute force your way but there are optimized ways to do this. This is where gradient descent comes into play.Gradient descent optimizes the values of
m
by taking into account the final output and understanding which features are important and which are not.The loss function determines what is to be compared. In your example you are talking about two classes, in this case, the loss function will be a simple cross entropy loss function, that tells you how far you are from the actual values.
The loss is the difference in the predicted value vs actual value.
The only way you can minimize this loss is by playing around with weights. In order to understand which weights to play around with, you use simple first order derivatives to associate impact of output with each feature multiple by its weight.
Gradient descent is then used to compute the next set of weights that helps you reduce the loss by looking at the direction of weights to be used.
When you run this thru multiple epochs and steps, it stabilizes this weight matrix thereby improving performance of your model.
Hope this clears your question, would be happy to elaborate in case you need it.
$endgroup$
$begingroup$
Thx, can you write small example of performing one step for weights correction for model with three predictors?
$endgroup$
– r1d1
2 days ago
add a comment |
$begingroup$
Let us break this down into a few steps for better understanding:
Your linear classifier let us represent it with an equation y :
y = m1x1 + m2x2 + m3x3 + .....
where y takes into account all the features you have provided, multiplies it with random weightsm
.Now you need to find the ideal values of
m
in order for you to get maximum accuracy. You could ofcourse brute force your way but there are optimized ways to do this. This is where gradient descent comes into play.Gradient descent optimizes the values of
m
by taking into account the final output and understanding which features are important and which are not.The loss function determines what is to be compared. In your example you are talking about two classes, in this case, the loss function will be a simple cross entropy loss function, that tells you how far you are from the actual values.
The loss is the difference in the predicted value vs actual value.
The only way you can minimize this loss is by playing around with weights. In order to understand which weights to play around with, you use simple first order derivatives to associate impact of output with each feature multiple by its weight.
Gradient descent is then used to compute the next set of weights that helps you reduce the loss by looking at the direction of weights to be used.
When you run this thru multiple epochs and steps, it stabilizes this weight matrix thereby improving performance of your model.
Hope this clears your question, would be happy to elaborate in case you need it.
$endgroup$
Let us break this down into a few steps for better understanding:
Your linear classifier let us represent it with an equation y :
y = m1x1 + m2x2 + m3x3 + .....
where y takes into account all the features you have provided, multiplies it with random weightsm
.Now you need to find the ideal values of
m
in order for you to get maximum accuracy. You could ofcourse brute force your way but there are optimized ways to do this. This is where gradient descent comes into play.Gradient descent optimizes the values of
m
by taking into account the final output and understanding which features are important and which are not.The loss function determines what is to be compared. In your example you are talking about two classes, in this case, the loss function will be a simple cross entropy loss function, that tells you how far you are from the actual values.
The loss is the difference in the predicted value vs actual value.
The only way you can minimize this loss is by playing around with weights. In order to understand which weights to play around with, you use simple first order derivatives to associate impact of output with each feature multiple by its weight.
Gradient descent is then used to compute the next set of weights that helps you reduce the loss by looking at the direction of weights to be used.
When you run this thru multiple epochs and steps, it stabilizes this weight matrix thereby improving performance of your model.
Hope this clears your question, would be happy to elaborate in case you need it.
answered 2 days ago
Nischal HpNischal Hp
48829
48829
$begingroup$
Thx, can you write small example of performing one step for weights correction for model with three predictors?
$endgroup$
– r1d1
2 days ago
add a comment |
$begingroup$
Thx, can you write small example of performing one step for weights correction for model with three predictors?
$endgroup$
– r1d1
2 days ago
$begingroup$
Thx, can you write small example of performing one step for weights correction for model with three predictors?
$endgroup$
– r1d1
2 days ago
$begingroup$
Thx, can you write small example of performing one step for weights correction for model with three predictors?
$endgroup$
– r1d1
2 days ago
add a comment |
Thanks for contributing an answer to Data Science Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f47072%2flinear-classifier-and-gradient-descent%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown