rumale-clustering 1.0.0 → 2.0.0
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 +4 -4
- data/lib/rumale/clustering/dbscan.rb +5 -5
- data/lib/rumale/clustering/hdbscan.rb +3 -3
- data/lib/rumale/clustering/k_medoids.rb +3 -3
- data/lib/rumale/clustering/power_iteration.rb +3 -3
- data/lib/rumale/clustering/single_linkage.rb +3 -3
- data/lib/rumale/clustering/spectral_clustering.rb +3 -3
- data/lib/rumale/clustering/version.rb +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '09c110ecd3bc505addbf299a70a577abcba22b5df349c1e8b9ccd41f372e6e1f'
|
4
|
+
data.tar.gz: 68e76c6e5a18c62b1ac3ae13d16c0014ae71171434dd54e3545abb0bae9066c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6632b58767010a7aeac407215597c19be62d08e6c188b7d0709ef6898a096cbb4e66b545611667ad82850522a38071ae9488c9c8a03f841f07bd55ca87b5554b
|
7
|
+
data.tar.gz: e992ff5889c90843954df74bc19009705fc474acbeb13e18f6675a9313146451b1d9757aa57c450964a2e0a693d46868ed048a1abc79a559a6f51a5722d68d17
|
@@ -52,7 +52,7 @@ module Rumale
|
|
52
52
|
# @return [DBSCAN] The learned cluster analyzer itself.
|
53
53
|
def fit(x, _y = nil)
|
54
54
|
x = ::Rumale::Validation.check_convert_sample_array(x)
|
55
|
-
raise ArgumentError, 'the input distance matrix should be square' if check_invalid_array_shape(x)
|
55
|
+
raise ArgumentError, 'the input distance matrix should be square' if check_invalid_array_shape?(x)
|
56
56
|
|
57
57
|
partial_fit(x)
|
58
58
|
self
|
@@ -65,7 +65,7 @@ module Rumale
|
|
65
65
|
# @return [Numo::Int32] (shape: [n_samples]) Predicted cluster label per sample.
|
66
66
|
def fit_predict(x)
|
67
67
|
x = ::Rumale::Validation.check_convert_sample_array(x)
|
68
|
-
raise ArgumentError, 'the input distance matrix should be square' if check_invalid_array_shape(x)
|
68
|
+
raise ArgumentError, 'the input distance matrix should be square' if check_invalid_array_shape?(x)
|
69
69
|
|
70
70
|
partial_fit(x)
|
71
71
|
labels
|
@@ -73,7 +73,7 @@ module Rumale
|
|
73
73
|
|
74
74
|
private
|
75
75
|
|
76
|
-
def check_invalid_array_shape(x)
|
76
|
+
def check_invalid_array_shape?(x)
|
77
77
|
@params[:metric] == 'precomputed' && x.shape[0] != x.shape[1]
|
78
78
|
end
|
79
79
|
|
@@ -86,7 +86,7 @@ module Rumale
|
|
86
86
|
n_samples.times do |query_id|
|
87
87
|
next if @labels[query_id] >= -1
|
88
88
|
|
89
|
-
cluster_id += 1 if expand_cluster(metric_mat, query_id, cluster_id)
|
89
|
+
cluster_id += 1 if expand_cluster?(metric_mat, query_id, cluster_id)
|
90
90
|
end
|
91
91
|
@core_sample_ids = Numo::Int32[*@core_sample_ids.flatten]
|
92
92
|
nil
|
@@ -96,7 +96,7 @@ module Rumale
|
|
96
96
|
@params[:metric] == 'precomputed' ? x : ::Rumale::PairwiseMetric.euclidean_distance(x)
|
97
97
|
end
|
98
98
|
|
99
|
-
def expand_cluster(metric_mat, query_id, cluster_id)
|
99
|
+
def expand_cluster?(metric_mat, query_id, cluster_id)
|
100
100
|
target_ids = region_query(metric_mat[query_id, true])
|
101
101
|
if target_ids.size < @params[:min_samples]
|
102
102
|
@labels[query_id] = -1
|
@@ -51,7 +51,7 @@ module Rumale
|
|
51
51
|
# @return [HDBSCAN] The learned cluster analyzer itself.
|
52
52
|
def fit(x, _y = nil)
|
53
53
|
x = ::Rumale::Validation.check_convert_sample_array(x)
|
54
|
-
raise ArgumentError, 'the input distance matrix should be square' if check_invalid_array_shape(x)
|
54
|
+
raise ArgumentError, 'the input distance matrix should be square' if check_invalid_array_shape?(x)
|
55
55
|
|
56
56
|
fit_predict(x)
|
57
57
|
self
|
@@ -64,7 +64,7 @@ module Rumale
|
|
64
64
|
# @return [Numo::Int32] (shape: [n_samples]) Predicted cluster label per sample.
|
65
65
|
def fit_predict(x)
|
66
66
|
x = ::Rumale::Validation.check_convert_sample_array(x)
|
67
|
-
raise ArgumentError, 'the input distance matrix should be square' if check_invalid_array_shape(x)
|
67
|
+
raise ArgumentError, 'the input distance matrix should be square' if check_invalid_array_shape?(x)
|
68
68
|
|
69
69
|
distance_mat = @params[:metric] == 'precomputed' ? x : ::Rumale::PairwiseMetric.euclidean_distance(x)
|
70
70
|
@labels = partial_fit(distance_mat)
|
@@ -72,7 +72,7 @@ module Rumale
|
|
72
72
|
|
73
73
|
private
|
74
74
|
|
75
|
-
def check_invalid_array_shape(x)
|
75
|
+
def check_invalid_array_shape?(x)
|
76
76
|
@params[:metric] == 'precomputed' && x.shape[0] != x.shape[1]
|
77
77
|
end
|
78
78
|
|
@@ -58,7 +58,7 @@ module Rumale
|
|
58
58
|
# @return [KMedoids] The learned cluster analyzer itself.
|
59
59
|
def fit(x, _y = nil)
|
60
60
|
x = ::Rumale::Validation.check_convert_sample_array(x)
|
61
|
-
raise ArgumentError, 'the input distance matrix should be square' if check_invalid_array_shape(x)
|
61
|
+
raise ArgumentError, 'the input distance matrix should be square' if check_invalid_array_shape?(x)
|
62
62
|
|
63
63
|
# initialize some varibales.
|
64
64
|
distance_mat = @params[:metric] == 'precomputed' ? x : ::Rumale::PairwiseMetric.euclidean_distance(x)
|
@@ -102,7 +102,7 @@ module Rumale
|
|
102
102
|
# @return [Numo::Int32] (shape: [n_samples]) Predicted cluster label per sample.
|
103
103
|
def fit_predict(x)
|
104
104
|
x = ::Rumale::Validation.check_convert_sample_array(x)
|
105
|
-
raise ArgumentError, 'the input distance matrix should be square' if check_invalid_array_shape(x)
|
105
|
+
raise ArgumentError, 'the input distance matrix should be square' if check_invalid_array_shape?(x)
|
106
106
|
|
107
107
|
fit(x)
|
108
108
|
if @params[:metric] == 'precomputed'
|
@@ -114,7 +114,7 @@ module Rumale
|
|
114
114
|
|
115
115
|
private
|
116
116
|
|
117
|
-
def check_invalid_array_shape(x)
|
117
|
+
def check_invalid_array_shape?(x)
|
118
118
|
@params[:metric] == 'precomputed' && x.shape[0] != x.shape[1]
|
119
119
|
end
|
120
120
|
|
@@ -67,7 +67,7 @@ module Rumale
|
|
67
67
|
# @return [PowerIteration] The learned cluster analyzer itself.
|
68
68
|
def fit(x, _y = nil)
|
69
69
|
x = ::Rumale::Validation.check_convert_sample_array(x)
|
70
|
-
raise ArgumentError, 'the input affinity matrix should be square' if check_invalid_array_shape(x)
|
70
|
+
raise ArgumentError, 'the input affinity matrix should be square' if check_invalid_array_shape?(x)
|
71
71
|
|
72
72
|
fit_predict(x)
|
73
73
|
self
|
@@ -80,7 +80,7 @@ module Rumale
|
|
80
80
|
# @return [Numo::Int32] (shape: [n_samples]) Predicted cluster label per sample.
|
81
81
|
def fit_predict(x)
|
82
82
|
x = ::Rumale::Validation.check_convert_sample_array(x)
|
83
|
-
raise ArgumentError, 'the input affinity matrix should be square' if check_invalid_array_shape(x)
|
83
|
+
raise ArgumentError, 'the input affinity matrix should be square' if check_invalid_array_shape?(x)
|
84
84
|
|
85
85
|
affinity_mat = @params[:affinity] == 'precomputed' ? x : ::Rumale::PairwiseMetric.rbf_kernel(x, nil, @params[:gamma])
|
86
86
|
@embedding, @n_iter = embedded_space(affinity_mat, @params[:max_iter], @params[:tol].fdiv(affinity_mat.shape[0]))
|
@@ -89,7 +89,7 @@ module Rumale
|
|
89
89
|
|
90
90
|
private
|
91
91
|
|
92
|
-
def check_invalid_array_shape(x)
|
92
|
+
def check_invalid_array_shape?(x)
|
93
93
|
@params[:affinity] == 'precomputed' && x.shape[0] != x.shape[1]
|
94
94
|
end
|
95
95
|
|
@@ -51,7 +51,7 @@ module Rumale
|
|
51
51
|
# @return [SingleLinkage] The learned cluster analyzer itself.
|
52
52
|
def fit(x, _y = nil)
|
53
53
|
x = ::Rumale::Validation.check_convert_sample_array(x)
|
54
|
-
raise ArgumentError, 'the input distance matrix should be square' if check_invalid_array_shape(x)
|
54
|
+
raise ArgumentError, 'the input distance matrix should be square' if check_invalid_array_shape?(x)
|
55
55
|
|
56
56
|
fit_predict(x)
|
57
57
|
self
|
@@ -64,7 +64,7 @@ module Rumale
|
|
64
64
|
# @return [Numo::Int32] (shape: [n_samples]) Predicted cluster label per sample.
|
65
65
|
def fit_predict(x)
|
66
66
|
x = ::Rumale::Validation.check_convert_sample_array(x)
|
67
|
-
raise ArgumentError, 'the input distance matrix should be square' if check_invalid_array_shape(x)
|
67
|
+
raise ArgumentError, 'the input distance matrix should be square' if check_invalid_array_shape?(x)
|
68
68
|
|
69
69
|
distance_mat = @params[:metric] == 'precomputed' ? x : ::Rumale::PairwiseMetric.euclidean_distance(x)
|
70
70
|
@labels = partial_fit(distance_mat)
|
@@ -72,7 +72,7 @@ module Rumale
|
|
72
72
|
|
73
73
|
private
|
74
74
|
|
75
|
-
def check_invalid_array_shape(x)
|
75
|
+
def check_invalid_array_shape?(x)
|
76
76
|
@params[:metric] == 'precomputed' && x.shape[0] != x.shape[1]
|
77
77
|
end
|
78
78
|
|
@@ -65,7 +65,7 @@ module Rumale
|
|
65
65
|
# @return [SpectralClustering] The learned cluster analyzer itself.
|
66
66
|
def fit(x, _y = nil)
|
67
67
|
x = ::Rumale::Validation.check_convert_sample_array(x)
|
68
|
-
raise ArgumentError, 'the input affinity matrix should be square' if check_invalid_array_shape(x)
|
68
|
+
raise ArgumentError, 'the input affinity matrix should be square' if check_invalid_array_shape?(x)
|
69
69
|
|
70
70
|
raise 'SpectralClustering#fit requires Numo::Linalg but that is not loaded' unless enable_linalg?(warning: false)
|
71
71
|
|
@@ -81,7 +81,7 @@ module Rumale
|
|
81
81
|
# @return [Numo::Int32] (shape: [n_samples]) Predicted cluster label per sample.
|
82
82
|
def fit_predict(x)
|
83
83
|
x = ::Rumale::Validation.check_convert_sample_array(x)
|
84
|
-
raise ArgumentError, 'the input affinity matrix should be square' if check_invalid_array_shape(x)
|
84
|
+
raise ArgumentError, 'the input affinity matrix should be square' if check_invalid_array_shape?(x)
|
85
85
|
|
86
86
|
unless enable_linalg?(warning: false)
|
87
87
|
raise 'SpectralClustering#fit_predict requires Numo::Linalg but that is not loaded'
|
@@ -95,7 +95,7 @@ module Rumale
|
|
95
95
|
|
96
96
|
private
|
97
97
|
|
98
|
-
def check_invalid_array_shape(x)
|
98
|
+
def check_invalid_array_shape?(x)
|
99
99
|
@params[:affinity] == 'precomputed' && x.shape[0] != x.shape[1]
|
100
100
|
end
|
101
101
|
|
metadata
CHANGED
@@ -1,42 +1,42 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rumale-clustering
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yoshoku
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
|
-
name: numo-narray
|
13
|
+
name: numo-narray-alt
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
15
15
|
requirements:
|
16
|
-
- - "
|
16
|
+
- - "~>"
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: 0.9.
|
18
|
+
version: 0.9.4
|
19
19
|
type: :runtime
|
20
20
|
prerelease: false
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
22
22
|
requirements:
|
23
|
-
- - "
|
23
|
+
- - "~>"
|
24
24
|
- !ruby/object:Gem::Version
|
25
|
-
version: 0.9.
|
25
|
+
version: 0.9.4
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rumale-core
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
29
29
|
requirements:
|
30
30
|
- - "~>"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
32
|
+
version: 2.0.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
39
|
+
version: 2.0.0
|
40
40
|
description: |
|
41
41
|
Rumale::Clustering provides cluster analysis algorithms,
|
42
42
|
such as K-Means, Gaussian Mixture Model, DBSCAN, and Spectral Clustering,
|
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
85
|
- !ruby/object:Gem::Version
|
86
86
|
version: '0'
|
87
87
|
requirements: []
|
88
|
-
rubygems_version: 3.6.
|
88
|
+
rubygems_version: 3.6.9
|
89
89
|
specification_version: 4
|
90
90
|
summary: Rumale::Clustering provides cluster analysis algorithms with Rumale interface.
|
91
91
|
test_files: []
|