ankane / prophet-ruby

Time series forecasting for Ruby
MIT License
396 stars 11 forks source link

Using holidays and add_regressor at the same time results in error #14

Closed zacharyedwardbull closed 1 year ago

zacharyedwardbull commented 1 year ago

Hey! First off, thanks for writing such a handy library.

I'm using ruby 3.0.3, prophet-rb 0.4.2, and rover-df 0.3.4.

I'm trying to use both holidays, and add_regressor in the same forecast, but get the following error:

/Users/zachary/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/prophet-rb-0.4.2/lib/prophet/forecaster.rb:139:in `validate_column_name': undefined method `include?' for #<Rover::Vector ["New Year's Day", "New Year Holiday [Scotland]", "New Year's Day (Observed)", "New Year Holiday [Scotland] (Observed)", "St. Patrick's Day [Northern Ireland]", ...]> (NoMethodError)

Here is a minimum reproducer:

m = Prophet.new()
m.add_country_holidays('GB')
m.add_regressor('precipitation_intensity')

Another one which produces a similar outcome:

m = Prophet.new(holidays: holidays)
m.add_regressor('precipitation_intensity')

The issue seems to be forecaster.rb#L137 and forecaster.rb#L140 where .include? is called on a Rover::Vector. Adding a to_a to the chain seems to work as a hacky workaround.