Skip to content

Instantly share code, notes, and snippets.

View alparslankapani's full-sized avatar

Alparslan Kapani alparslankapani

  • istanbul
View GitHub Profile
@ltk
ltk / gradient_descent.rb
Created April 30, 2013 13:11
Ruby implementation of a gradient descent linear regression algorithm
def params
[0,0]
end
def examples
[
{
:x => 1,
:y => 3
},
@actsasgeek
actsasgeek / line.rb
Created July 20, 2012 21:11
ruby implementation of gradient descent linear regression
require 'generator'
samples = [
{ :xs => [ 1.0, 0.25], :y => 0.98},
{ :xs => [ 1.0, 0.49], :y => 0.82},
{ :xs => [ 1.0, 0.60], :y => 0.41},
{ :xs => [ 1.0, 0.89], :y => 0.31}
]
# line is the sum of the dot product of the weight (thetas)