Linear classifier and gradient descent












1












$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?










share|improve this question









$endgroup$

















    1












    $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?










    share|improve this question









    $endgroup$















      1












      1








      1





      $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?










      share|improve this question









      $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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 2 days ago









      r1d1r1d1

      374




      374






















          1 Answer
          1






          active

          oldest

          votes


















          0












          $begingroup$

          Let us break this down into a few steps for better understanding:




          1. 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 weights m .


          2. 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.


          3. Gradient descent optimizes the values of m by taking into account the final output and understanding which features are important and which are not.


          4. 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.


          5. The loss is the difference in the predicted value vs actual value.


          6. 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.


          7. 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.


          8. 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.






          share|improve this answer









          $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











          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
          });


          }
          });














          draft saved

          draft discarded


















          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









          0












          $begingroup$

          Let us break this down into a few steps for better understanding:




          1. 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 weights m .


          2. 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.


          3. Gradient descent optimizes the values of m by taking into account the final output and understanding which features are important and which are not.


          4. 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.


          5. The loss is the difference in the predicted value vs actual value.


          6. 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.


          7. 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.


          8. 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.






          share|improve this answer









          $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
















          0












          $begingroup$

          Let us break this down into a few steps for better understanding:




          1. 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 weights m .


          2. 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.


          3. Gradient descent optimizes the values of m by taking into account the final output and understanding which features are important and which are not.


          4. 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.


          5. The loss is the difference in the predicted value vs actual value.


          6. 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.


          7. 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.


          8. 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.






          share|improve this answer









          $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














          0












          0








          0





          $begingroup$

          Let us break this down into a few steps for better understanding:




          1. 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 weights m .


          2. 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.


          3. Gradient descent optimizes the values of m by taking into account the final output and understanding which features are important and which are not.


          4. 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.


          5. The loss is the difference in the predicted value vs actual value.


          6. 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.


          7. 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.


          8. 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.






          share|improve this answer









          $endgroup$



          Let us break this down into a few steps for better understanding:




          1. 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 weights m .


          2. 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.


          3. Gradient descent optimizes the values of m by taking into account the final output and understanding which features are important and which are not.


          4. 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.


          5. The loss is the difference in the predicted value vs actual value.


          6. 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.


          7. 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.


          8. 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.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          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


















          • $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


















          draft saved

          draft discarded




















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          How to label and detect the document text images

          Vallis Paradisi

          Tabula Rosettana