wandb 0.1.8 → 0.1.12

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: 17b68d037ed6930865fae0bd24437e1c41d3a746208c69237bf2cd9da3ed2c4e
4
- data.tar.gz: be8a03c3963951579dadd5397780cdd1d003f0b2e7e83f6a181b6dda491267de
3
+ metadata.gz: ed086eee277a0665a3281f93764c8042edf254c30bded00812f3f332085e0ece
4
+ data.tar.gz: 4c2e7443bbc914c38701eb3baa00f858f2e7a9d25afcef274c198404512681cc
5
5
  SHA512:
6
- metadata.gz: e7e1edea11690670d9d1af572c99caea8d6985fa31bd3e6255602352081d794bc00690a95042bf301588b160952de808be7f242b4f25cf6c54a8d146e966ccdb
7
- data.tar.gz: 1c3120cf18ba4ee4cc2cd3e26f61cccc296cc7059b823f0d8892a6b27571a7de120a8d3378151010793b42e99539e722c18a7aae363af465cbc53da26098b7a1
6
+ metadata.gz: 52c8315c8d711a06263cbd98d296b7fca5030ee1ed155e5603a607c04348a36115595cd2cfa9ea9b4a76547d3d31cce07f2835496bd26c78cbf6f3cb824253aa
7
+ data.tar.gz: caa96acc54494baf471d5b06dc74dfdde85fb7d54e35ebdfee485b3c02cbfca044c2c3793161b6eed2b0816b1e43a2568818d143e180a9af7697edfb7728b73c
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.8"
4
+ VERSION = "0.1.12"
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
@@ -48,6 +48,14 @@ module Wandb
48
48
  @current_run = Run.new(run)
49
49
  end
50
50
 
51
+ def latest_run=(run)
52
+ @latest_run = run
53
+ end
54
+
55
+ def latest_run
56
+ @latest_run
57
+ end
58
+
51
59
  # Get the current run
52
60
  attr_reader :current_run
53
61
 
@@ -73,6 +81,12 @@ module Wandb
73
81
  def plot
74
82
  Plot
75
83
  end
84
+
85
+ def run_url
86
+ raise "No active run. Call Wandb.init() first." unless @current_run
87
+
88
+ @current_run.url
89
+ end
76
90
  end
77
91
 
78
92
  # Run class
@@ -113,6 +127,11 @@ module Wandb
113
127
  def log_artifact(artifact)
114
128
  @run.log_artifact(artifact.__pyptr__)
115
129
  end
130
+
131
+ # Add this new method
132
+ def url
133
+ @run.get_url
134
+ end
116
135
  end
117
136
 
118
137
  # Artifact class
@@ -232,8 +251,14 @@ module Wandb
232
251
  # Plot class
233
252
  class Plot
234
253
  class << self
235
- def bar(table, x_key, y_key, title: nil)
236
- py_plot = Wandb.__pyptr__.plot.bar(table.__pyptr__, x_key, y_key, title: title)
254
+ def bar(table, label:, value:, title: nil, split_table: false)
255
+ py_plot = Wandb.__pyptr__.plot.bar(
256
+ table: table.__pyptr__,
257
+ label: label,
258
+ value: value,
259
+ title: title,
260
+ split_table: split_table,
261
+ )
237
262
  new(py_plot)
238
263
  end
239
264
 
@@ -258,7 +283,7 @@ module Wandb
258
283
  end
259
284
 
260
285
  def __pyptr__
261
- @plot
286
+ @plot.__pyptr__
262
287
  end
263
288
  end
264
289
  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.8
4
+ version: 0.1.12
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-20 00:00:00.000000000 Z
11
+ date: 2024-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pycall