Permalink
Browse files

Some small quick changes. (nothing important)

Added methods we would like to add to the regression library and a note to the readme about how I would like to modify the regression library before moving on to other library elements.
  • Loading branch information...
1 parent f1eeffc commit 74a6c797a621e444784b087d4c4b53412107d349 Giuseppe Burtini committed Dec 4, 2011
Showing with 21 additions and 1 deletion.
  1. +8 −0 README
  2. +13 −1 lib/parametric/regression.php
View
8 README
@@ -19,3 +19,11 @@ If you need to work with the Learning Library in an environment
that is not conducive to the GPL, please contact me at <joe@truephp.com>
and we can discuss alternative licensing terms.
+--
+
+I would like to rewrite the regression stuff to be more generic
+in particular, it should have an optimization function that takes
+two functions as inputs ($objective, $derivatives($number)) and
+returns a maximum accordingly. That would allow the methods to
+be genericized over different types of problems (say linear vs.
+logistic).
@@ -10,7 +10,7 @@
$xs represents the data you want to regress on.
$ys represents the list of "answers" (i.e., y = b0 + b1x1 + b2x2)
- $method is either gradient or normal
+ $method is either gradient or normal (right now)
$alpha is used in gradient descent and represents the "learning rate", set this as high as you can get away with.
$initialization is the vector of values to start your b0, b1, b2 values at during the gradient descent. if you don't pass it, will use a vector of 0s.
$repetitions is the number of times to repeat. This is required unless LL_AUTODETECT_CONVERGENCE is defined to be a floating point value, in which case, we will repeat until we're within that distance from the previous iteration.
@@ -26,6 +26,18 @@ function ll_linear_regression($xs, $ys, $method="gradient", $alpha=null, $initia
return _ll_gradient_descent($xs, $ys, $initialization, $alpha, $repetitions);
break;
+ case "stochastic":
+ trigger_error("Stochastic gradient descent not implemented.");
+ break;
+
+ case "conjugate":
+ trigger_error("Conjugate gradient not implemented.");
+ break;
+
+ case "bfgs": case "lbfgs": case "l-bfgs":
+ trigger_error("BFGS not implemented.");
+ break;
+
case "normal":
// compute the normal equations method... parameters = (x' x)^-1 x' y
return _ll_normal_equation($xs, $ys);

0 comments on commit 74a6c79

Please sign in to comment.