# HG changeset patch # User Jeff Hammel # Date 1504469853 25200 # Node ID b95fe82ac9ce94030904ab4fadb170fda1dae9f2 # Parent 926c127305fa463291070fc2537f09d0820e9b33 more notes to self diff -r 926c127305fa -r b95fe82ac9ce tvii/logistic_regression.py --- a/tvii/logistic_regression.py Sun Sep 03 12:11:03 2017 -0700 +++ b/tvii/logistic_regression.py Sun Sep 03 13:17:33 2017 -0700 @@ -12,6 +12,18 @@ 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""" diff -r 926c127305fa -r b95fe82ac9ce tvii/sigmoid.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tvii/sigmoid.py Sun Sep 03 13:17:33 2017 -0700 @@ -0,0 +1,8 @@ +""" +sigmoid function: 1/(1 + e^-z) +""" + +import math + +def sigmoid(z): + return 1./(1. + math.exp(-z))