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 +3 -0
- data/lib/cofi_cost.rb +1 -1
- data/test/unit/test_cofi_cost.rb +1 -1
- metadata +1 -1
data/README.textile
CHANGED
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)
|
data/test/unit/test_cofi_cost.rb
CHANGED
@@ -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.
|
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]
|