In the previous post I mentioned using Iceberg successfully.
The code I was pushing is
a simple linear regression calculator, written to take Oleksandr Zaytsev's
DataFrame library for a spin, by way of
porting Jason Brownlee's excellent
simple linear regression in Python
Firstly, install DataFrame. This also pulls in Roassal.
SLRCalculator implements mean, variance, covariance, coefficients etc, and
also incorporates the Swedish automobile insurance dataset used by Jason in
his Python example.
The computation for covariance also uses DataFrame.
Let's see how to use SLRCalculator to perform linear regression, with
graphing using Roassal. First declare the variables and instantiate some objects:
Next, split the data set into training and test subsets. Splitting without
shuffling means to always take the first 60% of the data for training.
Set up for graphing. Load `allData' as points.
Create the points to plot the linear regression of the full data set, using
the coefficients computed from the training subset.
Make the plot look nice.
Putting the code altogether:
Copy/paste the code into a playground, press shift-ctrl-g...