0% found this document useful (0 votes)
106 views1 page

Logistic Regression Cost Function

The document discusses defining a cost function to train the parameters in logistic regression. It defines the loss function as measuring the discrepancy between predicted (ŷ) and actual (y) outputs. For classification problems, the loss is defined as negative log likelihood. The cost function is the average loss over all training examples, and the goal is to minimize this cost function to find the optimal parameters w and b.

Uploaded by

joeyb379
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
0% found this document useful (0 votes)
106 views1 page

Logistic Regression Cost Function

The document discusses defining a cost function to train the parameters in logistic regression. It defines the loss function as measuring the discrepancy between predicted (ŷ) and actual (y) outputs. For classification problems, the loss is defined as negative log likelihood. The cost function is the average loss over all training examples, and the goal is to minimize this cost function to find the optimal parameters w and b.

Uploaded by

joeyb379
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/ 1

Logistic Regression: Cost Function

To train the parameters 𝑤 and 𝑏, we need to define a cost function.

Recap:
𝑦̂ (𝑖) = 𝜎(𝑤 𝑇 𝑥 (𝑖) + 𝑏), where 𝜎(𝑧 (𝑖) )=
1 𝑥 (𝑖) the i-th training example
(𝑖)
1+ 𝑒 −𝑧

𝐺𝑖𝑣𝑒𝑛 {(𝑥 (1) , 𝑦 (1) ), ⋯ , (𝑥 (𝑚) , 𝑦 (𝑚) )}, 𝑤𝑒 𝑤𝑎𝑛𝑡 𝑦̂ (𝑖) ≈ 𝑦 (𝑖)

Loss (error) function:


The loss function measures the discrepancy between the prediction (𝑦̂ (𝑖) ) and the desired output (𝑦 (𝑖) ).
In other words, the loss function computes the error for a single training example.
1
𝐿(𝑦̂ (𝑖) , 𝑦 (𝑖) ) = (𝑦̂ (𝑖) − 𝑦 (𝑖) )2
2

𝐿(𝑦̂ (𝑖) , 𝑦 (𝑖) ) = −( 𝑦 (𝑖) log(𝑦̂ (𝑖) ) + (1 − 𝑦 (𝑖) )log(1 − 𝑦̂ (𝑖) )

• If 𝑦 (𝑖) = 1: 𝐿(𝑦̂ (𝑖) , 𝑦 (𝑖) ) = − log(𝑦̂ (𝑖) ) where log(𝑦̂ (𝑖) ) and 𝑦̂ (𝑖) should be close to 1
• If 𝑦 (𝑖) = 0: 𝐿(𝑦̂ (𝑖) , 𝑦 (𝑖) ) = − log(1 − 𝑦̂ (𝑖) ) where log(1 − 𝑦̂ (𝑖) ) and 𝑦̂ (𝑖) should be close to 0

Cost function
The cost function is the average of the loss function of the entire training set. We are going to find the
parameters 𝑤 𝑎𝑛𝑑 𝑏 that minimize the overall cost function.
𝑚 𝑚
1 1
𝐽(𝑤, 𝑏) = ∑ 𝐿(𝑦̂ (𝑖) , 𝑦 (𝑖) ) = − ∑[( 𝑦 (𝑖) log(𝑦̂ (𝑖) ) + (1 − 𝑦 (𝑖) )log(1 − 𝑦̂ (𝑖) )]
𝑚 𝑚
𝑖=1 𝑖=1

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy