Sha256: 8edc9363df2ba292d8199cac0a84fc5d468a54103cf09100805cb692585c187e
Contents?: true
Size: 1.24 KB
Versions: 27
Compression:
Stored size: 1.24 KB
Contents
module EasyML module Data module Splits class InMemorySplit < Split attr_accessor :dataset def initialize(options = {}) @data = {} @dataset = options[:dataset] end # We don't backup in-memory splits to s3 def download; end def upload; end def files [] end def save(segment, df) @data[segment] = df end def read(segment, split_ys: false, target: nil, drop_cols: [], filter: nil, limit: nil, select: nil, unique: nil) return nil if @data.keys.none? df = if segment.to_s == "all" Polars.concat(EasyML::Dataset::SPLIT_ORDER.map { |segment| @data[segment] }.compact) else @data[segment] end return nil if df.nil? df = df.filter(filter) if filter.present? drop_cols &= df.columns df = df.drop(drop_cols) unless drop_cols.empty? df = df.unique if unique split_features_targets(df, split_ys, target) end def cleanup @data.clear end def split_at @data.keys.empty? ? nil : Time.now end end end end end
Version data entries
27 entries across 27 versions & 1 rubygems