diff options
author | Patrick Simianer <p@simianer.de> | 2014-03-02 16:36:13 +0100 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2014-03-02 16:36:13 +0100 |
commit | 9d693723ba7bcf380182e8bd4d622f6d8eff4e3a (patch) | |
tree | e7c489836a41bdbcc30c9690108ed9e3a77b965d /lin_reg | |
parent | 38862b7e0cde7ac7285169c10e1377357ea24488 (diff) |
logistic regression
Diffstat (limited to 'lin_reg')
-rwxr-xr-x | lin_reg | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -44,13 +44,13 @@ def main i += 1 u = SparseVector.new zeros overall_loss = 0.0 - data.each_with_index { |d,j| - loss = model.dot(d) - t[j] + data.each_with_index { |x,j| + loss = model.dot(x) - t[j] overall_loss += loss**2 - u += d * (loss * (1.0/t.size)) + u += x * loss } STDERR.write "#{i} #{overall_loss/data.size}\n" if cfg[:show_loss] - u *= cfg[:learning_rate] + u *= cfg[:learning_rate]*(1.0/t.size) model -= u if model.approx_eql? prev_model stop += 1 |