changeset 5:cdab664cf253 default tip

Minor tweaks
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Wed, 16 Nov 2011 00:55:06 -0500
parents e90718520560
children
files lrCostFunction.m predict.m
diffstat 2 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lrCostFunction.m
+++ b/lrCostFunction.m
@@ -11,7 +11,8 @@
   ## h_theta(x)
   ht = sigmoid (X*theta); 
 
-  J = -(y'*log (ht) + (1 - y)'*log (1 - ht))/m + lambda*sum (theta(2:end).^2)/(2*m);
+  J = -(y'*log (ht) + (1 - y)'*log (1 - ht))/m \
+      + lambda*sumsq (theta(2:end))/(2*m);
 
   grad = (X'*(ht - y) + [0; lambda*theta(2:end,:)])/m ;
 
--- a/predict.m
+++ b/predict.m
@@ -6,7 +6,7 @@
   m = rows (X);
   X = [ones(m, 1), X];
 
-  ## See predictOneVsAll.m for an explanatin of this syntax if it's new
+  ## See predictOneVsAll.m for an explanation of this syntax if it's new
   ## to you.
   [~, p] = max ( [ones(m, 1), sigmoid(X*Theta1')]*Theta2', [], 2);