<p>For logistic regression, the <em><strong>Cost</strong></em> function is defined as:
<span class="math-container">\begin{equation}
Cost(h_{\theta}(x)-y) = -ylog(h_{\theta}(x))-(1-y)log(1-h_{\theta}(x))
\end{equation}</span></p>

<p>I now have a nonlinear function
<span class="math-container">\begin{equation}
 h_{\theta}^{(i)}(x)=xe^{-j\theta_i|x|^2}
\end{equation}</span>
where <span class="math-container">$i$</span> denotes the <span class="math-container">$i$</span>th training sample. How should I define cost function for this particular nonlinear function? </p>

CC BY-SA 4.0
2019-05-29T23:13:43.607Z
Hi Yifan. I might be able to answer this question later. Meanwhile, if you need immediate help, you might want to ask the question also on https://stats.stackexchange.com/.
nbro
CC BY-SA 4.0
2019-05-30T08:37:09.247Z
Hi nbro, thank you very much for the suggestion~~ However I'll wait for your response~~ I'll ask there next time : )
yfliuuu
CC BY-SA 4.0
2019-06-07T09:57:34.157Z
Hi again~~ I would really like to ask if you could give me a hint on this problem~ Thank you so much
yfliuuu
CC BY-SA 4.0
2019-06-07T10:44:12.153Z
Hi Yifan! I am sorry I only answer now. It had been a while since I had worked with logistic regression, so I needed some time to review it. Have a look at [generalised linear models](https://en.wikipedia.org/wiki/Generalized_linear_model) (link function and prediction/mean function). In the usual case of logistic regression, the link function is the logarithm of the odds ratio, that is, it is $\ln \left( \frac{p}{1 - p} \right)$, because the mean function is $\frac{1}{1 + e^{-x^T \beta}}$. In your case, you have a different mean function, which will correspond to some link function.
nbro
CC BY-SA 4.0
2019-06-07T21:39:18.917Z
Hi~~~ thank you so much for this. I'll have a deeper look into it and let you know~ Thank you so much for all the help!
yfliuuu
<deep-learning><deep-neural-networks><logistic-regression>
How to define cost function for custom nonlinear functions?
yfliuuu
# How to define cost function for custom nonlinear functions?

(Asked by: username_0 on 2019-05-28)

For logistic regression, the ***Cost*** function is defined as:
\begin{equation}
Cost(h\_{\theta}(x)-y) = -ylog(h\_{\theta}(x))-(1-y)log(1-h\_{\theta}(x))
\end{equation}

I now have a nonlinear function
\begin{equation}
h\_{\theta}^{(i)}(x)=xe^{-j\theta\_i|x|^2}
\end{equation}
where $i$ denotes the $i$th training sample. How should I define cost function for this particular nonlinear function?

**Tags:** deep-learning, deep-neural-networks, logistic-regression

> **Comments:**
> **username_1**: Hi Yifan. I might be able to answer this question later. Meanwhile, if you need immediate help, you might want to ask the question also on https://stats.stackexchange.com/.  
> **username_0**: Hi username_1, thank you very much for the suggestion~~ However I'll wait for your response~~ I'll ask there next time : )  
> **username_0**: Hi again~~ I would really like to ask if you could give me a hint on this problem~ Thank you so much  
> **username_1**: Hi Yifan! I am sorry I only answer now. It had been a while since I had worked with logistic regression, so I needed some time to review it. Have a look at [generalised linear models](https://en.wikipedia.org/wiki/Generalized_linear_model) (link function and prediction/mean function). In the usual case of logistic regression, the link function is the logarithm of the odds ratio, that is, it is $\ln \left( \frac{p}{1 - p} \right)$, because the mean function is $\frac{1}{1 + e^{-x^T \beta}}$. In your case, you have a different mean function, which will correspond to some link function.  
> **username_0**: Hi~~~ thank you so much for this. I'll have a deeper look into it and let you know~ Thank you so much for all the help!  

---

## 0 answers

