How to introduce different costs by class in a binary logistic regression?












0














What is the form of the Negative Log-Likelihood Goal function in Logistic regression if we introduce different costs per class (e.g. the cost of erring class 1 is errc1, and class 2 is errc2)?










share|cite|improve this question



























    0














    What is the form of the Negative Log-Likelihood Goal function in Logistic regression if we introduce different costs per class (e.g. the cost of erring class 1 is errc1, and class 2 is errc2)?










    share|cite|improve this question

























      0












      0








      0


      1





      What is the form of the Negative Log-Likelihood Goal function in Logistic regression if we introduce different costs per class (e.g. the cost of erring class 1 is errc1, and class 2 is errc2)?










      share|cite|improve this question













      What is the form of the Negative Log-Likelihood Goal function in Logistic regression if we introduce different costs per class (e.g. the cost of erring class 1 is errc1, and class 2 is errc2)?







      logistic-regression log-likelihood






      share|cite|improve this question













      share|cite|improve this question











      share|cite|improve this question




      share|cite|improve this question










      asked Nov 19 '18 at 0:34









      MrT77

      114




      114






















          1 Answer
          1






          active

          oldest

          votes


















          0














          The logistic regression hypothesis (sigmoid) is defined as:
          $$h_w(x) = sigma(w^T x)$$
          where $sigma(z) = frac{1}{1 + exp(-z)}$.
          Logistic regression is fit by maximum likelihood, i.e. we want to maximize the probability of the observed data:
          $$ arg,max ({mathbf{w}}) ;p(x^{(1)},y^{(1)}),p(x^{(2)},y^{(2)}),...,p(x^{(N)},y^{(N)})$$
          which is equivalent to (by eliminating the constant priors):
          $$ arg,max ({mathbf{w}}) ;p(y^{(1)}|x^{(1)})cdot p(y^{(2)}|x^{(2)})cdot...cdot p(y^{(N)}|x^{(N)})$$



          By assumption, these conditional probabilities are the sigmoid, so our goal function (through MLE, and assuming independence) is:
          $$ J(w) = arg,max ({mathbf{w}}) prod_{i=1}^{N} ;(p(y_i=1|x_i))^{y_i}cdot (p(y_i=0|x_i))^{1-y_i}$$



          If we introduce different costs, this is equivalent to weighting according to the correspondent class probabilities, e.g. if the cost of erring $C_2$ is twice the cost of erring $C_1$, this is like having another $C_2$ case in the training data. Thus, it's equivalent to doubling it's probability:



          $$ J(w) = arg,max ({mathbf{w}}) prod_{i=1}^{N} ;(p(y_i=1|x_i))^{C_1/C_0*y_i}cdot (p(y_i=0|x_i))^{(C_0/C_1)*(1-y_i)}$$






          share|cite|improve this answer





















            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: "69"
            };
            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: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            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
            },
            noCode: true, onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3004336%2fhow-to-introduce-different-costs-by-class-in-a-binary-logistic-regression%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














            The logistic regression hypothesis (sigmoid) is defined as:
            $$h_w(x) = sigma(w^T x)$$
            where $sigma(z) = frac{1}{1 + exp(-z)}$.
            Logistic regression is fit by maximum likelihood, i.e. we want to maximize the probability of the observed data:
            $$ arg,max ({mathbf{w}}) ;p(x^{(1)},y^{(1)}),p(x^{(2)},y^{(2)}),...,p(x^{(N)},y^{(N)})$$
            which is equivalent to (by eliminating the constant priors):
            $$ arg,max ({mathbf{w}}) ;p(y^{(1)}|x^{(1)})cdot p(y^{(2)}|x^{(2)})cdot...cdot p(y^{(N)}|x^{(N)})$$



            By assumption, these conditional probabilities are the sigmoid, so our goal function (through MLE, and assuming independence) is:
            $$ J(w) = arg,max ({mathbf{w}}) prod_{i=1}^{N} ;(p(y_i=1|x_i))^{y_i}cdot (p(y_i=0|x_i))^{1-y_i}$$



            If we introduce different costs, this is equivalent to weighting according to the correspondent class probabilities, e.g. if the cost of erring $C_2$ is twice the cost of erring $C_1$, this is like having another $C_2$ case in the training data. Thus, it's equivalent to doubling it's probability:



            $$ J(w) = arg,max ({mathbf{w}}) prod_{i=1}^{N} ;(p(y_i=1|x_i))^{C_1/C_0*y_i}cdot (p(y_i=0|x_i))^{(C_0/C_1)*(1-y_i)}$$






            share|cite|improve this answer


























              0














              The logistic regression hypothesis (sigmoid) is defined as:
              $$h_w(x) = sigma(w^T x)$$
              where $sigma(z) = frac{1}{1 + exp(-z)}$.
              Logistic regression is fit by maximum likelihood, i.e. we want to maximize the probability of the observed data:
              $$ arg,max ({mathbf{w}}) ;p(x^{(1)},y^{(1)}),p(x^{(2)},y^{(2)}),...,p(x^{(N)},y^{(N)})$$
              which is equivalent to (by eliminating the constant priors):
              $$ arg,max ({mathbf{w}}) ;p(y^{(1)}|x^{(1)})cdot p(y^{(2)}|x^{(2)})cdot...cdot p(y^{(N)}|x^{(N)})$$



              By assumption, these conditional probabilities are the sigmoid, so our goal function (through MLE, and assuming independence) is:
              $$ J(w) = arg,max ({mathbf{w}}) prod_{i=1}^{N} ;(p(y_i=1|x_i))^{y_i}cdot (p(y_i=0|x_i))^{1-y_i}$$



              If we introduce different costs, this is equivalent to weighting according to the correspondent class probabilities, e.g. if the cost of erring $C_2$ is twice the cost of erring $C_1$, this is like having another $C_2$ case in the training data. Thus, it's equivalent to doubling it's probability:



              $$ J(w) = arg,max ({mathbf{w}}) prod_{i=1}^{N} ;(p(y_i=1|x_i))^{C_1/C_0*y_i}cdot (p(y_i=0|x_i))^{(C_0/C_1)*(1-y_i)}$$






              share|cite|improve this answer
























                0












                0








                0






                The logistic regression hypothesis (sigmoid) is defined as:
                $$h_w(x) = sigma(w^T x)$$
                where $sigma(z) = frac{1}{1 + exp(-z)}$.
                Logistic regression is fit by maximum likelihood, i.e. we want to maximize the probability of the observed data:
                $$ arg,max ({mathbf{w}}) ;p(x^{(1)},y^{(1)}),p(x^{(2)},y^{(2)}),...,p(x^{(N)},y^{(N)})$$
                which is equivalent to (by eliminating the constant priors):
                $$ arg,max ({mathbf{w}}) ;p(y^{(1)}|x^{(1)})cdot p(y^{(2)}|x^{(2)})cdot...cdot p(y^{(N)}|x^{(N)})$$



                By assumption, these conditional probabilities are the sigmoid, so our goal function (through MLE, and assuming independence) is:
                $$ J(w) = arg,max ({mathbf{w}}) prod_{i=1}^{N} ;(p(y_i=1|x_i))^{y_i}cdot (p(y_i=0|x_i))^{1-y_i}$$



                If we introduce different costs, this is equivalent to weighting according to the correspondent class probabilities, e.g. if the cost of erring $C_2$ is twice the cost of erring $C_1$, this is like having another $C_2$ case in the training data. Thus, it's equivalent to doubling it's probability:



                $$ J(w) = arg,max ({mathbf{w}}) prod_{i=1}^{N} ;(p(y_i=1|x_i))^{C_1/C_0*y_i}cdot (p(y_i=0|x_i))^{(C_0/C_1)*(1-y_i)}$$






                share|cite|improve this answer












                The logistic regression hypothesis (sigmoid) is defined as:
                $$h_w(x) = sigma(w^T x)$$
                where $sigma(z) = frac{1}{1 + exp(-z)}$.
                Logistic regression is fit by maximum likelihood, i.e. we want to maximize the probability of the observed data:
                $$ arg,max ({mathbf{w}}) ;p(x^{(1)},y^{(1)}),p(x^{(2)},y^{(2)}),...,p(x^{(N)},y^{(N)})$$
                which is equivalent to (by eliminating the constant priors):
                $$ arg,max ({mathbf{w}}) ;p(y^{(1)}|x^{(1)})cdot p(y^{(2)}|x^{(2)})cdot...cdot p(y^{(N)}|x^{(N)})$$



                By assumption, these conditional probabilities are the sigmoid, so our goal function (through MLE, and assuming independence) is:
                $$ J(w) = arg,max ({mathbf{w}}) prod_{i=1}^{N} ;(p(y_i=1|x_i))^{y_i}cdot (p(y_i=0|x_i))^{1-y_i}$$



                If we introduce different costs, this is equivalent to weighting according to the correspondent class probabilities, e.g. if the cost of erring $C_2$ is twice the cost of erring $C_1$, this is like having another $C_2$ case in the training data. Thus, it's equivalent to doubling it's probability:



                $$ J(w) = arg,max ({mathbf{w}}) prod_{i=1}^{N} ;(p(y_i=1|x_i))^{C_1/C_0*y_i}cdot (p(y_i=0|x_i))^{(C_0/C_1)*(1-y_i)}$$







                share|cite|improve this answer












                share|cite|improve this answer



                share|cite|improve this answer










                answered Dec 18 '18 at 13:35









                MrT77

                114




                114






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Mathematics 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.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


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


                    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%2fmath.stackexchange.com%2fquestions%2f3004336%2fhow-to-introduce-different-costs-by-class-in-a-binary-logistic-regression%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

                    QoS: MAC-Priority for clients behind a repeater

                    Ивакино (Тотемский район)

                    Can't locate Autom4te/ChannelDefs.pm in @INC (when it definitely is there)