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)
Oct 19, 2011 @ 17: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.

tagged: linear regression algorithm class reformat variance learning

Link:

Ian Barber's Blog:
Linear Regression in PHP
Oct 13, 2011 @ 17:57:09

Ian Barber has a new post about an interesting method for determining the "line" that results follow in your statistics - linear regression in PHP (complete with code samples).

There are a lot of problems that fall under predicting these types of continuous values based on limited inputs - for example: given the air pressure, how much rain will there be, given the qualifying times, how quick will the fastest lap be in the race. By taking a bunch of existing data and fitting a line, we will be able to make a prediction easily - and often reasonably correctly.

He defines two pieces of information, the intercept and the gradient, and how they relate to minimize the "square error" that can come from getting the square root of your values based on the difference between an actual and predicted value. Based on a sample data set, he comes up with these results, showing the trend line for the points given. He points out a few issues with the method and corrects them with a few tweaks to his original algorithm.

tagged: linear regression algorithm square error

Link:

Johannes Schluter's Blog:
NetBeans plugin for running phpt tests
Dec 18, 2008 @ 15:35:16

In a new post to his blog today Johannes Schluter talks about a plugin for the NetBeans IDE that allows you to run tests for PHP's regression test suite right in the editor.

The test system therefore produces a bunch of files, a file containing the expected output, one containing the actual output and a diff between these as relevant files. The problem there is that the diff, for being portable, is using a quite simple mechanism which only shows the lines which differ without any context.

[...] Lately I've changed my way of working and use vim less, I still use it, but I use NetBeans as an IDE more and more. So I thought a bit about that test issue and searched my brain for my Java skills and started playing around to see whether I manage to write a NetBeans plugin which can run the tests and report the results in a usable way.

Hes created a project for the plugin (where you can download the latest version - 0.6.0) and install it to your local IDE copy. It adds a toolbar icon, asks for the location of the binaries to test and runs the diff quickly and easily. You can see a screenshot of the tool in action here.

tagged: netbeans plugin phpt test regression toolbar button wizard

Link:


Trending Topics: