# 逻辑回归2

* 逻辑斯蒂分布
  * 分布函数：$$F(x)=P(X \leq x)=\frac{1}{1+e^{-(x-\mu)/\gamma}}$$
  * 密度函数：$$f(x)=F'(x)=\frac{e^{-(x-\mu)/\gamma}}{\gamma(1+e^{-(x-\mu)/\gamma})^2}$$
* 二项逻辑斯蒂回归模型概率分布：

  $$P(Y=1|x)=\frac{exp(w\.x+b)}{1+exp(w\.x+b)}$$

  $$P(Y=0|x)=\frac{1}{1+exp(w\.x+b)}$$
* 通常合并w、b：

  $$P(Y=1|x)=\frac{exp(w\.x)}{1+exp(w\.x)}$$

  $$P(Y=0|x)=\frac{1}{1+exp(w\.x)}$$
* 特点：对数几率
  * 正负概率只比$$\frac{p}{1-p}$$
  * 取对数$$log\frac{p}{1-p}=w\.b$$
  * 意义：$$w .b$$越大正类的概率比负类的比越大
* 模型参数估计：极大似然

  记：$$P(Y=1|x)=\pi(x),Y(Y=0|x)=1-\pi(x)$$

  似然估计函数：$$\prod\_{i=1}^N \[\pi(x\_i)]^{y\_i}\[1-\pi(x\_i)]^{1-y\_i}$$

  `对数似然`：

  $$
  \begin{aligned}
  L(w)=\sum\_{i=1}^{N}\[y\_ilog\pi(x\_i)+(1-y\_i)log(1-\pi(x\_i))] \\
  \= \sum\_{i=1}^{N}\[y\_ilog\frac{\pi(x\_i)}{1-\pi(x\_i)}+log(1-\pi(x\_i))] \\
  \= \sum\_{i=1}^{N}\[y\_i(w\.x\_i)-log(1+exp(w\.x\_i))] \\
  \end{aligned}
  $$
* 然后对w求偏导数，得到梯度下降等进行参数求解


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://im-qianuxn.gitbook.io/pytorch/ji-suan-ji/ml/6-luo-ji-hui-gui.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
