Skip to content

Commit

Permalink
Added float division to get same results with python 2. and 3
Browse files Browse the repository at this point in the history
  • Loading branch information
ONordander committed Apr 28, 2017
1 parent 5d3f38b commit 93e8bf7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion id3/splitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def _info_numerical(self, x, y):
min_attribute_counts[SplitRecord.LESS] = n - i
min_attribute_counts[SplitRecord.GREATER] = i
min_info = tmp_info
min_info_pivot = (sorted_x[i - 1] + sorted_x[i]) / 2
min_info_pivot = (sorted_x[i - 1] + sorted_x[i]) / 2.0
return CalcRecord(CalcRecord.NUM,
min_info * np.true_divide(1, n),
pivot=min_info_pivot,
Expand Down
2 changes: 1 addition & 1 deletion id3/tests/test_id3.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_info_numerical():
record = test_splitter._info_numerical(x_numerical_col, y)
assert_equal(record.split_type, 0)
assert_equal(record.attribute_counts.size, 2)
assert_almost_equal(record.pivot, 3)
assert_almost_equal(record.pivot, 3.5, 2)
assert_almost_equal(record.info, 0.95, 2)


Expand Down

0 comments on commit 93e8bf7

Please sign in to comment.