changeset 54:0807ac8992ba

[logistic regression] note further steps
author Jeff Hammel <k0scist@gmail.com>
date Sun, 24 Sep 2017 15:25:49 -0700
parents 673a295fd09c
children 0908b6cd3217
files tvii/logistic_regression.py
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tvii/logistic_regression.py	Sun Sep 24 14:42:56 2017 -0700
+++ b/tvii/logistic_regression.py	Sun Sep 24 15:25:49 2017 -0700
@@ -12,14 +12,22 @@
 
 
 import numpy as np
+import sklearn
 from .sigmoid import sigmoid
 
+def logistic_regression(X, Y):
+    """"train a logisitic regression classifier"""
+    clf = sklearn.linear_model.LogisticRegressionCV()
+    clf.fit(X.T, Y.T)
+    return clf
+
 
 def loss(a, y):
     # UNTESTED!
     # derivative = -(y/a) + (1-y)/(1-a)
     return -y*np.log(a) - (1-y)*np.log(1-a)
 
+
 def propagate(w, b, X, Y):
     """
     Implement the cost function and its gradient for the propagation:
@@ -87,6 +95,12 @@
     cost = np.sum(Y*np.log(A) + (1 - Y)*np.log(1 - A))
     return (-1./m)*cost
 
+def compute_costs(Yhat, Y):
+    """
+    Computes the cross-entropy cost given:
+    """
+    raise NotImplementedError('TODO')
+
 
 def optimize(w, b, X, Y, num_iterations, learning_rate, print_cost = False):
     """