scout-essentials 1.6.0 → 1.6.1

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: 24500b0c2c21f23844c3eb87ce87ed1ea4fd6f0e9ee635ef474b29d919baffdf
4
- data.tar.gz: b54836819a0a394bf3b2907d641b6ae34b7b4c4b9ced9b2dd0b78b3d22d30cc9
3
+ metadata.gz: 2fe20bd6954a0372235430a8baa5990efbd23d00b5ebd37048dbeb253ebdb78d
4
+ data.tar.gz: 41ba7642cc7c683d482e1173c27d0f23a632c3651856d8adaf9d150b81904e2e
5
5
  SHA512:
6
- metadata.gz: 12c4740363f2e5d64e3c3f691dfa0ca6086617d84a82b666d25d683e0d0e36c3fe062bcc3f210b3c38358a0a36f0b1a2ab6b3c7c6628a9b74fa4ebb2b92afb1e
7
- data.tar.gz: 86df3be0b64051d8aa0007d061f181f281835a241c1cbeeb113dd53d0595b0c52adf7bfa269b91c70bdf2233c0fef7b0ca3064c3763fb2a49e5ca3f6e7e0d5ad
6
+ metadata.gz: 1badc3ef7083453c39ff6778c1a1f516865ea3e59d7c01c7f0e1047bda5e9835d7ee490db35de6ac684b85d63bdac3369a442e669a32cc14b3242f6f1ee1092d
7
+ data.tar.gz: 671d77a07f9d9b847bc6397e365b9f944a85261818edd70aaf9a6cc5c75beef3d4e255b52081bc01b3762bb68df5632a5e10cf0041bb4472e360c8eea774d6c6
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.6.0
1
+ 1.6.1
@@ -106,4 +106,17 @@ module Misc
106
106
  sd = Misc.sd(list)
107
107
  (e.to_f - m) / sd
108
108
  end
109
+
110
+ def self.softmax(array)
111
+ # Compute the exponentials of the input array elements
112
+ exp_array = array.map { |x| Math.exp(x) }
113
+
114
+ # Sum of all exponentials
115
+ sum_exp = exp_array.sum
116
+
117
+ # Compute the softmax values by dividing each exponential by the sum of exponentials
118
+ softmax_array = exp_array.map { |x| x / sum_exp }
119
+
120
+ return softmax_array
121
+ end
109
122
  end
@@ -84,9 +84,18 @@ module NamedArray
84
84
 
85
85
 
86
86
  def concat(other)
87
- super(other)
88
- self.fields.concat(other.fields) if NamedArray === other
89
- self
87
+ if Hash === other
88
+ new_fields = []
89
+ other.each do |k,v|
90
+ new_fields << k
91
+ self << v
92
+ end
93
+ self.fields.concat(new_fields)
94
+ else
95
+ super(other)
96
+ self.fields.concat(other.fields) if NamedArray === other
97
+ self
98
+ end
90
99
  end
91
100
 
92
101
  def to_hash
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: scout-essentials 1.6.0 ruby lib
5
+ # stub: scout-essentials 1.6.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "scout-essentials".freeze
9
- s.version = "1.6.0".freeze
9
+ s.version = "1.6.1".freeze
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Miguel Vazquez".freeze]
14
- s.date = "2024-06-05"
14
+ s.date = "2024-06-17"
15
15
  s.description = "Things a scout can use anywhere".freeze
16
16
  s.email = "mikisvaz@gmail.com".freeze
17
17
  s.extra_rdoc_files = [
@@ -5,5 +5,11 @@ class TestMiscMath < Test::Unit::TestCase
5
5
  def test_mean
6
6
  assert_equal 4, Misc.mean([6,2])
7
7
  end
8
+
9
+ def test_softmax
10
+ assert_equal 0.5, Misc.softmax([1,1]).first
11
+ assert Misc.softmax([1,2]).first < 0.5
12
+ assert Misc.softmax([2,1]).first > 0.5
13
+ end
8
14
  end
9
15
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scout-essentials
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-05 00:00:00.000000000 Z
11
+ date: 2024-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shoulda