modelfox icon indicating copy to clipboard operation
modelfox copied to clipboard

Unwrap in Stats

Open isabella opened this issue 3 years ago • 2 comments

error: panicked at 'called `Option::unwrap()` on a `None` value', crates/core/stats.rs:365:48
   0: backtrace::capture::Backtrace::new
   1: tangram::train::train::{{closure}}
   2: std::panicking::rust_panic_with_hook
   3: std::panicking::begin_panic_handler::{{closure}}
   4: std::sys_common::backtrace::__rust_end_short_backtrace
   5: _rust_begin_unwind
   6: core::panicking::panic_fmt
   7: core::panicking::panic
   8: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
   9: tangram_core::stats::Stats::finalize
  10: tangram_core::train::Trainer::prepare
  11: tangram::main
  12: std::sys_common::backtrace::__rust_begin_short_backtrace
  13: _main

isabella avatar Feb 24 '22 15:02 isabella

This happens here:

let min = self.histogram.iter().next().unwrap().0.get();

https://github.com/tangramdotdev/tangram/blob/d3472c217f0177872d40628425ea0241bb3afb24/crates/core/stats.rs#L365

isabella avatar Feb 24 '22 15:02 isabella

Hey @isabella, do you happen to have the original training data that triggered this bug? Based on this comment, I would assume the issue was caused by the histogram size exceeding 100 as set here. However, when I trained using heart_disease.csv and selecting resting_blood_pressure as the target, the issue did not reoccur. I was able to confirm, the histogram size exceeded the limit but it did not panic when unwrapped.

MitchyGoodness avatar Dec 26 '22 19:12 MitchyGoodness