wandb 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6f0f0909ffdfe53479bf0c6a09f09f96c7e0aec1dc846f16d9b42c1b1e7f4fae
4
- data.tar.gz: f1ffc1d2cdabc05964ef0187f5ab168a71ef38077591e3a07bf960da3b5ae8b5
3
+ metadata.gz: 17b68d037ed6930865fae0bd24437e1c41d3a746208c69237bf2cd9da3ed2c4e
4
+ data.tar.gz: be8a03c3963951579dadd5397780cdd1d003f0b2e7e83f6a181b6dda491267de
5
5
  SHA512:
6
- metadata.gz: 93b0f7df5f4bb660a9d566b3492a75690336eeddbfbe0aad15fc100c292499f5fb93a543f1f9f72b6120b2682d8ee25dd3b5ead6906500efd1f5ccc29f6a7219
7
- data.tar.gz: 95e7472bfa9e0322bb353d6ee77bd76a7b6f1c09edd6ef23f10f294ef982b35bae279b5ccbb4beee44991decf774b3bac45ab708ebbab4dbb0dda47917715545
6
+ metadata.gz: e7e1edea11690670d9d1af572c99caea8d6985fa31bd3e6255602352081d794bc00690a95042bf301588b160952de808be7f242b4f25cf6c54a8d146e966ccdb
7
+ data.tar.gz: 1c3120cf18ba4ee4cc2cd3e26f61cccc296cc7059b823f0d8892a6b27571a7de120a8d3378151010793b42e99539e722c18a7aae363af465cbc53da26098b7a1
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.7"
4
+ VERSION = "0.1.8"
5
5
  end
@@ -20,16 +20,18 @@ module Wandb
20
20
  end
21
21
  end
22
22
 
23
- attr_accessor :project_name, :api_key, :custom_loggers
23
+ attr_accessor :project_name, :api_key, :custom_loggers, :history, :sample
24
24
 
25
25
  def initialize(options = {})
26
26
  options = Opts.new(options)
27
27
  @log_model = options.default(:log_model, false)
28
28
  @log_feature_importance = options.default(:log_feature_importance, true)
29
29
  @importance_type = options.default(:importance_type, "gain")
30
+ @normalize_feature_importance = options.default(:normalize_feature_importance, true)
30
31
  @define_metric = options.default(:define_metric, true)
31
32
  @api_key = options.default(:api_key, ENV["WANDB_API_KEY"])
32
33
  @project_name = options.default(:project_name, nil)
34
+ @sample = options.default(:sample, 1.0)
33
35
  @custom_loggers = options.default(:custom_loggers, [])
34
36
  end
35
37
 
@@ -80,19 +82,22 @@ module Wandb
80
82
  end
81
83
 
82
84
  def after_iteration(model, epoch, history)
83
- history.each do |split, metric_scores|
84
- metric = metric_scores.keys.first
85
- values = metric_scores.values.last
86
- epoch_value = values[epoch]
87
-
88
- define_metric(split, metric) if @define_metric && epoch == 0
89
- full_metric_name = "#{split}-#{metric}"
90
- Wandb.log({ full_metric_name => epoch_value })
85
+ log_frequency = (1.0 / @sample).round
86
+ if epoch % log_frequency == 0
87
+ history.to_h.each do |split, metric_scores|
88
+ metric = metric_scores.keys.first
89
+ values = metric_scores.values.last
90
+ epoch_value = values[epoch]
91
+
92
+ define_metric(split, metric) if @define_metric && epoch == 0
93
+ full_metric_name = "#{split}-#{metric}"
94
+ Wandb.log({ full_metric_name => epoch_value })
95
+ end
96
+ @custom_loggers.each do |logger|
97
+ logger.call(model, epoch, history)
98
+ end
99
+ Wandb.log("epoch" => epoch)
91
100
  end
92
- @custom_loggers.each do |logger|
93
- logger.call(model, epoch, history)
94
- end
95
- Wandb.log("epoch" => epoch)
96
101
  false
97
102
  end
98
103
 
@@ -112,6 +117,12 @@ module Wandb
112
117
 
113
118
  def log_feature_importance(model)
114
119
  fi = model.score(importance_type: @importance_type)
120
+
121
+ if @normalize_feature_importance
122
+ total_importance = fi.values.sum
123
+ fi = fi.transform_values { |v| v / total_importance }
124
+ end
125
+
115
126
  fi_data = fi.map { |k, v| [k, v] }
116
127
 
117
128
  table = Wandb::Table.new(data: fi_data, columns: %w[Feature Importance])
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.7
4
+ version: 0.1.8
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-18 00:00:00.000000000 Z
11
+ date: 2024-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pycall