Class: EasyML::Data::Datasource::PolarsDatasource
- Inherits:
-
EasyML::Data::Datasource
- Object
- EasyML::Data::Datasource
- EasyML::Data::Datasource::PolarsDatasource
- Includes:
- GlueGun::DSL
- Defined in:
- lib/easy_ml/data/datasource/polars_datasource.rb
Instance Attribute Summary collapse
-
#last_updated_at ⇒ Object
Returns the value of attribute last_updated_at.
Instance Method Summary collapse
- #data ⇒ Object
- #df_is_dataframe ⇒ Object
- #files ⇒ Object
- #in_batches(of: 10_000) ⇒ Object
-
#initialize(options) ⇒ PolarsDatasource
constructor
A new instance of PolarsDatasource.
- #refresh! ⇒ Object
Constructor Details
#initialize(options) ⇒ PolarsDatasource
Returns a new instance of PolarsDatasource.
15 16 17 18 |
# File 'lib/easy_ml/data/datasource/polars_datasource.rb', line 15 def initialize() super @last_updated_at = Time.now end |
Instance Attribute Details
#last_updated_at ⇒ Object
Returns the value of attribute last_updated_at.
13 14 15 |
# File 'lib/easy_ml/data/datasource/polars_datasource.rb', line 13 def last_updated_at @last_updated_at end |
Instance Method Details
#data ⇒ Object
36 37 38 |
# File 'lib/easy_ml/data/datasource/polars_datasource.rb', line 36 def data df end |
#df_is_dataframe ⇒ Object
8 9 10 11 12 |
# File 'lib/easy_ml/data/datasource/polars_datasource.rb', line 8 def df_is_dataframe return if df.nil? || df.is_a?(Polars::DataFrame) errors.add(:df, "Must be an instance of Polars::DataFrame") end |
#files ⇒ Object
28 29 30 |
# File 'lib/easy_ml/data/datasource/polars_datasource.rb', line 28 def files [] # No files, as this is in-memory end |
#in_batches(of: 10_000) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/easy_ml/data/datasource/polars_datasource.rb', line 20 def in_batches(of: 10_000) total_rows = df.shape[0] (0...total_rows).step(of) do |start| end_index = [start + of, total_rows].min yield df.slice(start, end_index - start) end end |
#refresh! ⇒ Object
32 33 34 |
# File 'lib/easy_ml/data/datasource/polars_datasource.rb', line 32 def refresh! # No need to refresh for in-memory datasource end |