wandb 0.1.9 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe07e6917e230a051db42ac9d95a887397818e5504cf505d836084749de8cee7
4
- data.tar.gz: 7d49ebf4b2f85ed7375e6e62fcadce06fe0b3f10aeac5c8d955ea2d4cd537150
3
+ metadata.gz: 5e6dee096b6320d21c642d18b3199c0f60aa6a8f8f8e8b6d3368d0b94eacde37
4
+ data.tar.gz: 8dc5c527be316fbeedaeb215ee0b17bb4849302bcd97ddb61b5f55447626e307
5
5
  SHA512:
6
- metadata.gz: 1538917b3ea0b8fd0a34af20bcd79c7683bbc70ca126a6ba192c6e8645d6810d6fe6e68f3e36018a19b4722173ee72792c47cb12edaa3ac6bfe86d0a7853363d
7
- data.tar.gz: b816436bb73da8935fa3b1c6c7824b1f7b00601da184b27eed806a7782d924c7531b095a4f7fb5d73a6de3f8d2615b7c2da33b1204922669cad29cfb23f04d61
6
+ metadata.gz: 0ecf5f1cfd8b0a6051bcf3e94eaf4a234e2165e897a8405c1499db33184613b8f7de02e35db35d9dcb7964c3157efe62ce320e57f4e9f3c1f38e0c33de82aded
7
+ data.tar.gz: 5cd3f0731a11b7931385b9d490ba682d9407f31292ccc0bb14cbdf4311c461bf0c0fc7a3b4813f49a0a44c4f0750d0fb63810c7a86b2094e9f1297dd56cd1a9a
data/lib/wandb/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Wandb
4
- VERSION = "0.1.9"
4
+ VERSION = "0.1.13"
5
5
  end
@@ -20,7 +20,9 @@ module Wandb
20
20
  end
21
21
  end
22
22
 
23
- attr_accessor :project_name, :api_key, :custom_loggers, :history, :sample
23
+ attr_accessor :project_name, :api_key, :custom_loggers, :history, :sample,
24
+ :log_model, :log_feature_importance, :importance_type, :define_metric,
25
+ :normalize_feature_importance
24
26
 
25
27
  def initialize(options = {})
26
28
  options = Opts.new(options)
@@ -35,6 +37,19 @@ module Wandb
35
37
  @custom_loggers = options.default(:custom_loggers, [])
36
38
  end
37
39
 
40
+ def as_json
41
+ {
42
+ log_model: @log_model,
43
+ log_feature_importance: @log_feature_importance,
44
+ importance_type: @importance_type,
45
+ define_metric: @define_metric,
46
+ normalize_feature_importance: @normalize_feature_importance,
47
+ sample: @sample,
48
+ project_name: @project_name,
49
+ callback_type: :wandb,
50
+ }
51
+ end
52
+
38
53
  def before_training(model)
39
54
  Wandb.login(api_key: api_key)
40
55
  Wandb.init(project: project_name)
@@ -42,10 +57,8 @@ module Wandb
42
57
  log_conf = {
43
58
  learning_rate: config.dig("learner", "gradient_booster", "tree_train_param", "learning_rate").to_f,
44
59
  max_depth: config.dig("learner", "gradient_booster", "tree_train_param", "max_depth").to_f,
45
- n_estimators: model.num_boosted_rounds
60
+ n_estimators: model.num_boosted_rounds,
46
61
  }
47
- Wandb.current_run.config = log_conf
48
-
49
62
  Wandb.log(log_conf)
50
63
  model
51
64
  end
@@ -65,7 +78,7 @@ module Wandb
65
78
 
66
79
  Wandb.log(
67
80
  "best_score" => model.best_score.to_f,
68
- "best_iteration" => model.best_iteration.to_i
81
+ "best_iteration" => model.best_iteration.to_i,
69
82
  )
70
83
  finish
71
84
 
@@ -93,9 +106,6 @@ module Wandb
93
106
  full_metric_name = "#{split}-#{metric}"
94
107
  Wandb.log({ full_metric_name => epoch_value })
95
108
  end
96
- @custom_loggers.each do |logger|
97
- logger.call(model, epoch, history)
98
- end
99
109
  Wandb.log("epoch" => epoch)
100
110
  end
101
111
  false
@@ -126,7 +136,7 @@ module Wandb
126
136
  fi_data = fi.map { |k, v| [k, v] }
127
137
 
128
138
  table = Wandb::Table.new(data: fi_data, columns: %w[Feature Importance])
129
- bar_plot = Wandb::Plot.bar(table.table, "Feature", "Importance", title: "Feature Importance")
139
+ bar_plot = Wandb::Plot.bar(table.table, label: "Feature", value: "Importance", title: "Feature Importance")
130
140
  Wandb.log({ "Feature Importance" => bar_plot.__pyptr__ })
131
141
  end
132
142
 
data/lib/wandb.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require_relative "wandb/version"
2
- require "pry"
3
2
  require "pycall/import"
4
3
 
5
4
  # Ensure wandb executable isn't set using Ruby context
@@ -48,6 +47,14 @@ module Wandb
48
47
  @current_run = Run.new(run)
49
48
  end
50
49
 
50
+ def latest_run=(run)
51
+ @latest_run = run
52
+ end
53
+
54
+ def latest_run
55
+ @latest_run
56
+ end
57
+
51
58
  # Get the current run
52
59
  attr_reader :current_run
53
60
 
@@ -74,7 +81,6 @@ module Wandb
74
81
  Plot
75
82
  end
76
83
 
77
- # Add this new method
78
84
  def run_url
79
85
  raise "No active run. Call Wandb.init() first." unless @current_run
80
86
 
@@ -244,8 +250,14 @@ module Wandb
244
250
  # Plot class
245
251
  class Plot
246
252
  class << self
247
- def bar(table, x_key, y_key, title: nil)
248
- py_plot = Wandb.__pyptr__.plot.bar(table.__pyptr__, x_key, y_key, title: title)
253
+ def bar(table, label:, value:, title: nil, split_table: false)
254
+ py_plot = Wandb.__pyptr__.plot.bar(
255
+ table: table.__pyptr__,
256
+ label: label,
257
+ value: value,
258
+ title: title,
259
+ split_table: split_table,
260
+ )
249
261
  new(py_plot)
250
262
  end
251
263
 
@@ -270,7 +282,7 @@ module Wandb
270
282
  end
271
283
 
272
284
  def __pyptr__
273
- @plot
285
+ @plot.__pyptr__
274
286
  end
275
287
  end
276
288
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wandb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Shollenberger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-29 00:00:00.000000000 Z
11
+ date: 2025-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pycall