view tvii/logistic_regression.py @ 16:b95fe82ac9ce

more notes to self
author Jeff Hammel <k0scist@gmail.com>
date Sun, 03 Sep 2017 13:17:33 -0700
parents 8cb116d63a78
children 3713c6733990
line wrap: on
line source

"""
z = w'x + b
a = sigmoid(z)
L(a,y) = -(y*log(a) + (1-y)*log(1-a))

    [|  |  | ]
X = [x1 x2 x3]
    [|  |  | ]

[z1 z2 z3 .. zm] = w'*X + [b b b b ] = [w'*x1+b + w'*x2+b ...]
"""


import numpy as np
from .sigmoid import sigmoid

def cost_function(_):
    """
    Cost function for binary classification
    yhat = sigmoid(W.T*x + b)
    interpret yhat thhe probably that y=1

    Loss function:
    y log(yhat) + (1- {UNFINISHED})
    """
    raise NotImplementedError('TODO')

def logistic_regression(_):
    """the slow way"""
    J = 0
    dw1 =0
    dw2=0
    db=0

def logistic_regression(nx):
    dw = np.zeros(nx)
    # TODO
    # z = np.dot(wT, x) + b  # "boradcasting
    raise NotImplementedError('TODO')

# derivativs:
# dz1 = a1 - y1 ; dz2 = a2 - y2 ; ....
# dZ = [ dz1 dz2 ... dzm ]
# Z = w'X + b = np.dot(w', X) + b
# A sigmoid(Z)
#dZ = A - Y
#dw = (1./m)*X*dZ'
#db = (1./m)*np.sum(dZ)
# w -= alpha*dw
# b -= alpha*db