# HG changeset patch # User Jeff Hammel # Date 1506291949 25200 # Node ID 0807ac8992ba1f30d3a2c61f8ba664d4474e70d6 # Parent 673a295fd09c32114debe7f179d3b34c3cc717a4 [logistic regression] note further steps diff -r 673a295fd09c -r 0807ac8992ba tvii/logistic_regression.py --- 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): """