rumale 0.20.2 → 0.20.3

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: 5d8c93acbf38fbd07e5df224010abbdd4269a6ce3bbf8112a0eba652a606785d
4
- data.tar.gz: e7cb00a802420854835c92f011425f3054bfcc1052bf7b3664da1f95834ef435
3
+ metadata.gz: aaaacb965c722e93b75b835f21a870580c709b249829476247ad9b7849ee0ff4
4
+ data.tar.gz: 7de234d16943410e396551e42a7e45d436928e61c54834aab3f3d5d3448b058f
5
5
  SHA512:
6
- metadata.gz: f95fdd89b84dad02e516ee0479b1cddfb101cb96de897b6e7fa3fba546272a243cff5cfe954cb51942ec1ab23cf3028b183db86b52fab00a35d15be7eee5bf92
7
- data.tar.gz: e5f6235e88dd47b9002a2154cabd2c1e64afb6cbb5b0745b411c7e5559351e925c9db8ec332724e301b83215662b3582e79a9e997f0338846514b234dabf1fc3
6
+ metadata.gz: bd1b318abc92366f00c9e4183948f712e56bc25887f4117b4577ea8673537b2ddc9f91ff2244dfec51a94f9f992c4aff8468aa11553eafcdaa6f38ffd6e7b67d
7
+ data.tar.gz: 13450117456e31acb930026ae1a0a22ad7608dea0aba410fd8e030891a336948a2269058b9c7dbd79c57328f9a96c246d9d6d1836c37a0f2981f6c10e1869641
@@ -20,6 +20,9 @@ Layout/LineLength:
20
20
  Max: 145
21
21
  IgnoredPatterns: ['(\A|\s)#']
22
22
 
23
+ Lint/ConstantDefinitionInBlock:
24
+ Enabled: false
25
+
23
26
  Lint/MissingSuper:
24
27
  Enabled: false
25
28
 
@@ -70,6 +73,9 @@ Style/StringConcatenation:
70
73
  RSpec/MultipleExpectations:
71
74
  Enabled: false
72
75
 
76
+ RSpec/MultipleMemoizedHelpers:
77
+ Max: 25
78
+
73
79
  RSpec/NestedGroups:
74
80
  Max: 4
75
81
 
@@ -81,3 +87,6 @@ RSpec/InstanceVariable:
81
87
 
82
88
  RSpec/LeakyConstantDeclaration:
83
89
  Enabled: false
90
+
91
+ Performance/Sum:
92
+ Enabled: false
@@ -1,3 +1,8 @@
1
+ # 0.20.3
2
+ - Fix to use automatic solver of PCA in NeighbourhoodComponentAnalysis.
3
+ - Refactor some codes with Rubocop.
4
+ - Update README.
5
+
1
6
  # 0.20.2
2
7
  - Add cross-validator class for time-series data.
3
8
  - [TimeSeriesSplit](https://yoshoku.github.io/rumale/doc/Rumale/ModelSelection/TimeSeriesSplit.html)
data/Gemfile CHANGED
@@ -11,3 +11,6 @@ gem 'parallel', '>= 1.17.0'
11
11
  gem 'rake', '~> 12.0'
12
12
  gem 'rake-compiler', '~> 1.0'
13
13
  gem 'rspec', '~> 3.0'
14
+ gem 'rubocop', '~> 0.91'
15
+ gem 'rubocop-performance', '~> 1.8'
16
+ gem 'rubocop-rspec', '~> 1.43'
data/README.md CHANGED
@@ -228,6 +228,10 @@ When -1 is given to n_jobs parameter, all processors are used.
228
228
  estimator = Rumale::Ensemble::RandomForestClassifier.new(n_jobs: -1, random_seed: 1)
229
229
  ```
230
230
 
231
+ ## Novelties
232
+
233
+ * [Rumale SHOP](https://suzuri.jp/yoshoku)
234
+
231
235
  ## Contributing
232
236
 
233
237
  Bug reports and pull requests are welcome on GitHub at https://github.com/yoshoku/rumale.
@@ -51,7 +51,7 @@ module Rumale
51
51
  # @param x [Numo::DFloat] (shape: [n_samples, n_features]) The samples to be used for cluster analysis.
52
52
  # If the metric is 'precomputed', x must be a square distance matrix (shape: [n_samples, n_samples]).
53
53
  # @return [Numo::Int32] (shape: [n_samples]) Predicted cluster label per sample.
54
- def fit_predict(x)
54
+ def fit_predict(x) # rubocop:disable Lint/UselessMethodDefinition
55
55
  super
56
56
  end
57
57
 
@@ -75,9 +75,12 @@ module Rumale
75
75
  false_pos, true_pos, thresholds = binary_roc_curve(y_true, y_score, pos_label)
76
76
 
77
77
  if true_pos.size.zero? || false_pos[0] != 0 || true_pos[0] != 0
78
+ # NOTE: Numo::NArray#insert is not a destructive method.
79
+ # rubocop:disable Style/RedundantSelfAssignment
78
80
  true_pos = true_pos.insert(0, 0)
79
81
  false_pos = false_pos.insert(0, 0)
80
82
  thresholds = thresholds.insert(0, thresholds[0] + 1)
83
+ # rubocop:enable Style/RedundantSelfAssignment
81
84
  end
82
85
 
83
86
  tpr = true_pos / true_pos[-1].to_f
@@ -112,7 +112,7 @@ module Rumale
112
112
 
113
113
  def init_components(x, n_features, n_components)
114
114
  if @params[:init] == 'pca'
115
- pca = Rumale::Decomposition::PCA.new(n_components: n_components, solver: 'evd')
115
+ pca = Rumale::Decomposition::PCA.new(n_components: n_components)
116
116
  pca.fit(x).components.flatten.dup
117
117
  else
118
118
  Rumale::Utils.rand_normal([n_features, n_components], @rng.dup).flatten.dup
@@ -140,7 +140,7 @@ module Rumale
140
140
  def validate_steps(steps)
141
141
  steps.keys[0...-1].each do |name|
142
142
  transformer = steps[name]
143
- next if transformer.nil? || %i[fit transform].all? { |m| transformer.class.method_defined?(m) }
143
+ next if transformer.nil? || (transformer.class.method_defined?(:fit) && transformer.class.method_defined?(:transform))
144
144
 
145
145
  raise TypeError,
146
146
  'Class of intermediate step in pipeline should be implemented fit and transform methods: ' \
@@ -75,17 +75,10 @@ module Rumale
75
75
  node = Node.new(depth: depth, impurity: impurity, n_samples: n_samples)
76
76
 
77
77
  # terminate growing.
78
- unless @params[:max_leaf_nodes].nil?
79
- return nil if @n_leaves >= @params[:max_leaf_nodes]
80
- end
81
-
78
+ return nil if !@params[:max_leaf_nodes].nil? && @n_leaves >= @params[:max_leaf_nodes]
82
79
  return nil if n_samples < @params[:min_samples_leaf]
83
80
  return put_leaf(node, y) if n_samples == @params[:min_samples_leaf]
84
-
85
- unless @params[:max_depth].nil?
86
- return put_leaf(node, y) if depth == @params[:max_depth]
87
- end
88
-
81
+ return put_leaf(node, y) if !@params[:max_depth].nil? && depth == @params[:max_depth]
89
82
  return put_leaf(node, y) if stop_growing?(y)
90
83
 
91
84
  # calculate optimal parameters.
@@ -138,7 +138,7 @@ module Rumale
138
138
  nil
139
139
  end
140
140
 
141
- def grow_node(depth, x, y, g, h)
141
+ def grow_node(depth, x, y, g, h) # rubocop:disable Metrics/AbcSize
142
142
  # intialize some variables.
143
143
  sum_g = g.sum
144
144
  sum_h = h.sum
@@ -146,17 +146,10 @@ module Rumale
146
146
  node = Node.new(depth: depth, n_samples: n_samples)
147
147
 
148
148
  # terminate growing.
149
- unless @params[:max_leaf_nodes].nil?
150
- return nil if @n_leaves >= @params[:max_leaf_nodes]
151
- end
152
-
149
+ return nil if !@params[:max_leaf_nodes].nil? && @n_leaves >= @params[:max_leaf_nodes]
153
150
  return nil if n_samples < @params[:min_samples_leaf]
154
151
  return put_leaf(node, sum_g, sum_h) if n_samples == @params[:min_samples_leaf]
155
-
156
- unless @params[:max_depth].nil?
157
- return put_leaf(node, sum_g, sum_h) if depth == @params[:max_depth]
158
- end
159
-
152
+ return put_leaf(node, sum_g, sum_h) if !@params[:max_depth].nil? && depth == @params[:max_depth]
160
153
  return put_leaf(node, sum_g, sum_h) if stop_growing?(y)
161
154
 
162
155
  # calculate optimal parameters.
@@ -3,5 +3,5 @@
3
3
  # Rumale is a machine learning library in Ruby.
4
4
  module Rumale
5
5
  # The version of Rumale you are using.
6
- VERSION = '0.20.2'
6
+ VERSION = '0.20.3'
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rumale
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.2
4
+ version: 0.20.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - yoshoku
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-05 00:00:00.000000000 Z
11
+ date: 2020-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: numo-narray