Class: EasyML::Data::Dataset::Splits::InMemorySplit
- Includes:
- GlueGun::DSL
- Defined in:
- lib/easy_ml/data/dataset/splits/in_memory_split.rb
Instance Method Summary collapse
- #cleanup ⇒ Object
-
#initialize(options) ⇒ InMemorySplit
constructor
A new instance of InMemorySplit.
- #read(segment, split_ys: false, target: nil, drop_cols: [], &block) ⇒ Object
- #save(segment, df) ⇒ Object
- #split_at ⇒ Object
Methods inherited from Split
Methods included from Utils
#append_to_csv, #expand_dir, #null_check
Constructor Details
#initialize(options) ⇒ InMemorySplit
Returns a new instance of InMemorySplit.
9 10 11 12 |
# File 'lib/easy_ml/data/dataset/splits/in_memory_split.rb', line 9 def initialize() super @data = {} end |
Instance Method Details
#cleanup ⇒ Object
38 39 40 |
# File 'lib/easy_ml/data/dataset/splits/in_memory_split.rb', line 38 def cleanup @data.clear end |
#read(segment, split_ys: false, target: nil, drop_cols: [], &block) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/easy_ml/data/dataset/splits/in_memory_split.rb', line 18 def read(segment, split_ys: false, target: nil, drop_cols: [], &block) df = @data[segment] return nil if df.nil? df = sample_data(df) if sample < 1.0 drop_cols &= df.columns df = df.drop(drop_cols) unless drop_cols.empty? if block_given? if split_ys xs, ys = split_features_targets(df, true, target) process_block_with_split_ys(block, nil, xs, ys) else process_block_without_split_ys(block, nil, df) end else split_features_targets(df, split_ys, target) end end |
#save(segment, df) ⇒ Object
14 15 16 |
# File 'lib/easy_ml/data/dataset/splits/in_memory_split.rb', line 14 def save(segment, df) @data[segment] = df end |
#split_at ⇒ Object
42 43 44 |
# File 'lib/easy_ml/data/dataset/splits/in_memory_split.rb', line 42 def split_at @data.keys.empty? ? nil : Time.now end |