B = (X^TX)^(-1)X^TY anyone?
Performing Linear Regression Using Ruby
11–20 of 44 posts
Re: Performing Linear Regression Using Ruby
#12It's very useful to code basic statistical algorithms yourself so you understand how they work, but for any serious analysis you'll get more reliable and performant results with a library.
Re: Performing Linear Regression Using Ruby
#13Re: Performing Linear Regression Using Ruby
#14Ruby is great for data prep, basic calculations, web app development, and scraping aggregating data and R for visualization. I find them to be a joyful combination. Great for small data sets, quick estimations, and various small projects. Larger data sets and performance intensive operations are better handled in Python (or Java, C++, etc). Lots of statistical analysis is way below the threshold of Hadoop and company…
I mostly agree with this, because I do like Ruby even though I don't use it. The missing link here, and the reason Python gets more love from the data community, is that Python scales down to the smaller data sets as well as it handles big ones. (Not sure if you ment it couldn't, but the distinction you make implies that.)
Re: Performing Linear Regression Using Ruby
#15Earlier quoted context omitted.
I mostly agree with this, because I do like Ruby even though I don't use it. The missing link here, and the reason Python gets more love from the data community, is that Python scales down to the smaller data sets as well as it handles big ones. (Not sure if you ment it couldn't, but the distinction you make implies that.)
Python is surprisingly heavy-duty. But my kingdom for a seamlessly distributed or parallelized version of NumPy/SciPy! How nice would it be to just enter "C = A * B", with A living as a sparse CSC across many nodes?
Re: Performing Linear Regression Using Ruby
#16Earlier quoted context omitted.
I mostly agree with this, because I do like Ruby even though I don't use it. The missing link here, and the reason Python gets more love from the data community, is that Python scales down to the smaller data sets as well as it handles big ones. (Not sure if you ment it couldn't, but the distinction you make implies that.)
Python is surprisingly heavy-duty. But my kingdom for a seamlessly distributed or parallelized version of NumPy/SciPy! How nice would it be to just enter "C = A * B", with A living as a sparse CSC across many nodes?
Re: Performing Linear Regression Using Ruby
#17B = (X^TX)^(-1)X^TY anyone?
Here is one of my favorite OLS-related abuses of linear algebra: y = XB + e ---> e = y - XB ---> e = y - X(X'X)^(-1)X'Y ---> e = [I - X(X'X)^(-1)X'Y]y = My
Now use the two idempotent matrices to compute the SSR: e'e = (My)'(My) ---> e'e = y'M'My ---> e'e = y'MMy ---> e'e = y'My
Re: Performing Linear Regression Using Ruby
#18B = (X^TX)^(-1)X^TY anyone?
|0 0 0|
|0 1 0|
|0 0 1|
i.e identity matrix with (0,0) set to 0This ensures that the matrix is now invertible. Regularization takes care of overfitting.
P.S I'm a ml n00b doing Machine Learning course on Coursera so I might be unaware of more practical knowledge of the above. :D
Re: Performing Linear Regression Using Ruby
#19We do regressions with rb-gsl. require 'gsl' x = GSL::Vector.alloc(array_of_x_values) y = GSL::Vector.alloc(array_of_y_values) c0, c1, cov00, cov01, cov11, chisq, status = GSL::Fit::linear(x, y) It's not nearly as much work, and it's much faster than doing it in pure Ruby. :) (It also does weighted regressions and exponential fitting, among a host of other things. That wheel's gone done been invented already.)
GSL can be used internally ("in-house") without restriction, but only redistributed in other software that is under the GNU GPL.
http://www.gnu.org/software/gsl/