# How to solve for the parameters in a logistic function? [duplicate]

I want to find the parameters of a logistic function. I read the guide here. It has a very clear explanation, but it did not have the final solution that I need.

Now, we will consider a basis logistic function: $$h_\theta(x^{i})=\frac{1}{1+e^{-\theta_0-\theta_1x}}$$ We want to find $\theta_0$ and $\theta_1$ subject to minimum cost function: $$J(\theta)=-\frac{1}{m}\sum_{i=1}^{m}y^{i}\log(h_\theta(x^{i}))+(1-y^{i})\log(1-h_\theta(x^{i}))$$

We use the notation:

$$\theta x^i:=\theta_0+\theta_1 x^i_1$$

Then

$$\log h_\theta(x^i)=\log\frac{1}{1+e^{-\theta x^i} }=-\log ( 1+e^{-\theta x^i} ),$$ $$\log(1- h_\theta(x^i))=\log(1-\frac{1}{1+e^{-\theta x^i} })=\log (e^{-\theta x^i} )-\log ( 1+e^{-\theta x^i} )=-\theta x^i-\log ( 1+e^{-\theta x^i} ),$$

and

$$J(\theta)=-\frac{1}{m}\sum_{i=1}^m \left[y_i\theta x^i-\theta x^i-\log(1+e^{-\theta x^i})\right]=-\frac{1}{m}\sum_{i=1}^m \left[y_i\theta x^i-\log(1+e^{\theta x^i})\right],~~(*)$$

where the second equality follows from:

$$-\theta x^i-\log(1+e^{-\theta x^i})= -\left[ \log e^{\theta x^i}+ \log(1+e^{-\theta x^i} ) \right]=-\log(1+e^{\theta x^i}).$$

All I need now is to compute the partial derivatives of $(*)$ w.r.t. $\theta_j$. As

$$\frac{\partial}{\partial \theta_J}y_i\theta x^i=y_ix^i_j$$ $$\frac{\partial}{\partial \theta_j}\log(1+e^{\theta x^i})=\frac{x^i_je^{\theta x^i}}{1+e^{\theta x^i}}=x^i_jh_\theta(x^i),$$

The above steps are correct, but it did not have the solution for $\theta_0$ and $\theta_1$. We can take the derivative and put it equal $0$. Namely,

$$\frac{\partial J(\theta)}{\partial \theta_0}=y-\frac{e^{\theta_0+\theta_1 x}}{1+e^{\theta_0+\theta_1 x}}=0~~(*)$$ $$\frac{\partial J(\theta)}{\partial \theta_1}=yx-\frac{xe^{\theta_0+\theta_1 x}}{1+e^{\theta_0+\theta_1 x}}=0 ~~(**)$$

• Are $(*)$ and $(**)$ correct?
• Assume that $y$ and $x$ are known. How do you represent $\theta_0$ and $\theta_1$ by $y$ and $x$?
-