This is an old revision of the document!
Logistic regression
Hypothesis
Wertebereich sollte hier liegen: $0 \leq h_\theta(x) \leq 1$
$h_\theta(x) = g(\theta^Tx)$
Logistic/Sigmoid function $g(z) = \frac{1}{1+e^{-z}}$
$h_\theta(x)$: Geschätze Wahrscheinlichkeit, dass y = 1 is für Input x.
$h_\theta(x) = P(y=1 | x; \theta)$
$1 = P(y=1 | x; \theta) + P(y=0 | x; \theta)$
Cost function
How to choose parameters \theta?
$J(\theta) = \frac{1}{m} \sum_{i=1}^m Cost(h_\theta(x),y)$
$Cost(h_\theta(x),y) = 1/2 (h_\theta(x)-y)^2$ nicht konvex bei logistischer Regression!
$Cost(h_\theta(x),y) = \begin{cases} -log(h_\theta(x))&\text{if y = 1}\\-log(1 - h_\theta(x))&\text{if y = 0}\end{cases}$
Für y=1: Wenn y = 1, dann sind Kosten 0, sonst werden sie größer, je weiter entfernt. Für y=0: analog.
Vereinfacht:
$Cost(h_\theta(x),y) = -y * log(h_\theta(x)) - (1-y) * log(1 - h_\theta(x))$
Kann durch Maximum Likelihood Estimation hergeleitet werden.
Gradient Descent
Ähnlicher Algorithmus wie bei linearer Regression, aber andere Hypothesis.
Optimierung
Neben Gradient Descent:
- Conjugate gradient
- BFGS
- L-BFGS
Vorteile: Alpha muss nicht gewählt werden, oft schneller. Nachteil: Komplex.
Octave: Kosten und Gradienten berechnen und an entsprechende Methode übergeben.