cofi_cost 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.textile CHANGED
@@ -36,6 +36,9 @@ rails 3.2
36
36
  in your Gemfile
37
37
  # <pre>bundle install</pre> from the command line
38
38
 
39
+ h2. Thank you
40
+ Professor Andrew Ng for his wonderful Machine Learning class: ml-class.org
41
+
39
42
  h2. License
40
43
 
41
44
  MIT License 2012 Thomas Wolfe
data/lib/cofi_cost.rb CHANGED
@@ -76,7 +76,7 @@ class CofiCost
76
76
  theta_l, features_l = unroll_params(v)
77
77
  # In octave:
78
78
  # 1/2 * sum(sum(((X * Theta.transpose - Y).*R).^2)) + regularization/2 * sum(sum((Theta).^2)) + regularization/2 * sum(sum((X).^2))
79
- 0.5 * (partial_cost_calc(theta_l,features_l)**2).sum + @regularization/2 * (features_l**2).sum
79
+ 0.5 * (partial_cost_calc(theta_l,features_l)**2).sum + @regularization/2 * (features_l**2).sum + @regularization/2 * (theta_l**2).sum
80
80
  }
81
81
  cost_df = Proc.new { |v, df|
82
82
  theta_l, features_l = unroll_params(v)
@@ -22,7 +22,7 @@ class CofiCostTest < Test::Unit::TestCase
22
22
 
23
23
  def test_happy_case
24
24
  @c.min_cost
25
- assert_equal 0.15929446605989878, @c.cost
25
+ assert_equal 0.07964723302994943, @c.cost
26
26
  # oddly the following fails, even though they are equal (not enough decimal places me thinks)
27
27
  # assert_equal NArray[[4.62547,3.91302,8.30084,1.59081],[2.96361,3.17939,1.88322,3.88434],[3.92356,4.32263,1.739,5.6172],[2.98132,3.06219,2.47359,3.3213],[2.93724,3.14111,1.33728,3.77855]], @c.predictions
28
28
  assert_equal 4.625468057637709, @c.predictions[0,0]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cofi_cost
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: