igrigorik / decisiontree

ID3-based implementation of the ML Decision Tree algorithm
1.44k stars 130 forks source link

Undefined method `sum' #33

Open ruby232 opened 7 years ago

ruby232 commented 7 years ago

I'm try run examples/simple.rb in master but throw this error:

entropy': undefined method `sum' for [2, 3, 1]:Array (NoMethodError)

Try gem version 0.5.0 and work find, maybe it introduced in pull request #32

ruby232 commented 7 years ago

Fix add

require 'active_support'
require 'active_support/core_ext'

but i guess it not best solution

igrigorik commented 7 years ago

Guessing, you're on an older version of ruby?

This was introduced in https://github.com/igrigorik/decisiontree/commit/13aed0b2ae57e994e3366fedf15530d86c47bccd. /cc @cheerfulstoic

ruby232 commented 7 years ago

My version of ruby is 2.3.1

└─ $ ▶ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
igrigorik commented 7 years ago

Right, figures... Sum is 2.4+ http://blog.bigbinary.com/2016/11/02/ruby-2-4-introduces-enumerable-sum.html.

@cheerfulstoic I propose we revert the sum update until 2.3 is deprecated.

cheerfulstoic commented 7 years ago

Yep, sorry about that! Just created #34 and #35

cheerfulstoic commented 7 years ago

(Was editing in the UI and I couldn't see a way to do it in one PR)