News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Ian Barber's Blog:
Linear Regression in PHP (part 2)
October 19, 2011 @ 12:40:16

In a previous post Ian Barber started looking at code you could use to determine linear regression in PHP. In part two he restructures the code into a more manageable class rather than the mostly procedural process it was before.

In the last post we had a simple stepping algorithm, and a gradient descent implementation, for fitting a line to a set of points with one variable and one 'outcome'. As I mentioned though, it's fairly straightforward to extend that to multiple variables, and even to curves, rather than just straight lines. For this example I've reorganised the code slightly into a class to make life a little easier, but the main changes are just the hypothesis and learn functions.

He restructures the learning method to make it easier to reuse and includes a "scale data" method to compensate for irregularities in the data and compute the variance.

0 comments voice your opinion now!
linear regression algorithm class reformat variance learning


blog comments powered by Disqus

Similar Posts

PHPRiot.com: Singleton Classes in PHP

Community Crosstalk: Matthew O'Phinney & Scott Johnson on Dynamic Function/Method Calls

Evert Pot's Blog: Creating a Gopher server with PHP and InetD

Elated.com: Object-Oriented PHP: Autoloading, Serializing, and Querying Objects

Stubbles Blog: My wishlist for PHP 6, pt1: The 'object' type hint


Community Events





Don't see your event here?
Let us know!


tips interview threedevsandamaybe laravel symfony bugfix release list zendserver framework language conference deployment api voicesoftheelephpant introduction community code series podcast

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework