# How to define cost function for custom nonlinear functions?

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?

• 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 stats.stackexchange.com. – nbro May 29 '19 at 23:13
• Hi nbro, thank you very much for the suggestion~~ However I'll wait for your response~~ I'll ask there next time : ) – Yifan Liu May 30 '19 at 8:37
• Hi again~~ I would really like to ask if you could give me a hint on this problem~ Thank you so much – Yifan Liu Jun 7 '19 at 9:57
• 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 (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 Jun 7 '19 at 10:44
• 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! – Yifan Liu Jun 7 '19 at 21:39