rumale 0.23.3 → 0.24.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +5 -1
  3. data/README.md +3 -288
  4. data/lib/rumale/version.rb +1 -1
  5. data/lib/rumale.rb +20 -131
  6. metadata +252 -150
  7. data/CHANGELOG.md +0 -643
  8. data/CODE_OF_CONDUCT.md +0 -74
  9. data/ext/rumale/extconf.rb +0 -37
  10. data/ext/rumale/rumaleext.c +0 -545
  11. data/ext/rumale/rumaleext.h +0 -12
  12. data/lib/rumale/base/base_estimator.rb +0 -49
  13. data/lib/rumale/base/classifier.rb +0 -36
  14. data/lib/rumale/base/cluster_analyzer.rb +0 -31
  15. data/lib/rumale/base/evaluator.rb +0 -17
  16. data/lib/rumale/base/regressor.rb +0 -36
  17. data/lib/rumale/base/splitter.rb +0 -21
  18. data/lib/rumale/base/transformer.rb +0 -22
  19. data/lib/rumale/clustering/dbscan.rb +0 -123
  20. data/lib/rumale/clustering/gaussian_mixture.rb +0 -218
  21. data/lib/rumale/clustering/hdbscan.rb +0 -291
  22. data/lib/rumale/clustering/k_means.rb +0 -122
  23. data/lib/rumale/clustering/k_medoids.rb +0 -141
  24. data/lib/rumale/clustering/mini_batch_k_means.rb +0 -139
  25. data/lib/rumale/clustering/power_iteration.rb +0 -127
  26. data/lib/rumale/clustering/single_linkage.rb +0 -203
  27. data/lib/rumale/clustering/snn.rb +0 -76
  28. data/lib/rumale/clustering/spectral_clustering.rb +0 -115
  29. data/lib/rumale/dataset.rb +0 -246
  30. data/lib/rumale/decomposition/factor_analysis.rb +0 -150
  31. data/lib/rumale/decomposition/fast_ica.rb +0 -188
  32. data/lib/rumale/decomposition/nmf.rb +0 -124
  33. data/lib/rumale/decomposition/pca.rb +0 -159
  34. data/lib/rumale/ensemble/ada_boost_classifier.rb +0 -179
  35. data/lib/rumale/ensemble/ada_boost_regressor.rb +0 -160
  36. data/lib/rumale/ensemble/extra_trees_classifier.rb +0 -139
  37. data/lib/rumale/ensemble/extra_trees_regressor.rb +0 -125
  38. data/lib/rumale/ensemble/gradient_boosting_classifier.rb +0 -306
  39. data/lib/rumale/ensemble/gradient_boosting_regressor.rb +0 -237
  40. data/lib/rumale/ensemble/random_forest_classifier.rb +0 -189
  41. data/lib/rumale/ensemble/random_forest_regressor.rb +0 -153
  42. data/lib/rumale/ensemble/stacking_classifier.rb +0 -215
  43. data/lib/rumale/ensemble/stacking_regressor.rb +0 -163
  44. data/lib/rumale/ensemble/voting_classifier.rb +0 -126
  45. data/lib/rumale/ensemble/voting_regressor.rb +0 -82
  46. data/lib/rumale/evaluation_measure/accuracy.rb +0 -29
  47. data/lib/rumale/evaluation_measure/adjusted_rand_score.rb +0 -74
  48. data/lib/rumale/evaluation_measure/calinski_harabasz_score.rb +0 -56
  49. data/lib/rumale/evaluation_measure/davies_bouldin_score.rb +0 -53
  50. data/lib/rumale/evaluation_measure/explained_variance_score.rb +0 -39
  51. data/lib/rumale/evaluation_measure/f_score.rb +0 -50
  52. data/lib/rumale/evaluation_measure/function.rb +0 -147
  53. data/lib/rumale/evaluation_measure/log_loss.rb +0 -45
  54. data/lib/rumale/evaluation_measure/mean_absolute_error.rb +0 -29
  55. data/lib/rumale/evaluation_measure/mean_squared_error.rb +0 -29
  56. data/lib/rumale/evaluation_measure/mean_squared_log_error.rb +0 -29
  57. data/lib/rumale/evaluation_measure/median_absolute_error.rb +0 -30
  58. data/lib/rumale/evaluation_measure/mutual_information.rb +0 -49
  59. data/lib/rumale/evaluation_measure/normalized_mutual_information.rb +0 -53
  60. data/lib/rumale/evaluation_measure/precision.rb +0 -50
  61. data/lib/rumale/evaluation_measure/precision_recall.rb +0 -96
  62. data/lib/rumale/evaluation_measure/purity.rb +0 -40
  63. data/lib/rumale/evaluation_measure/r2_score.rb +0 -43
  64. data/lib/rumale/evaluation_measure/recall.rb +0 -50
  65. data/lib/rumale/evaluation_measure/roc_auc.rb +0 -130
  66. data/lib/rumale/evaluation_measure/silhouette_score.rb +0 -82
  67. data/lib/rumale/feature_extraction/feature_hasher.rb +0 -110
  68. data/lib/rumale/feature_extraction/hash_vectorizer.rb +0 -155
  69. data/lib/rumale/feature_extraction/tfidf_transformer.rb +0 -113
  70. data/lib/rumale/kernel_approximation/nystroem.rb +0 -126
  71. data/lib/rumale/kernel_approximation/rbf.rb +0 -102
  72. data/lib/rumale/kernel_machine/kernel_fda.rb +0 -120
  73. data/lib/rumale/kernel_machine/kernel_pca.rb +0 -97
  74. data/lib/rumale/kernel_machine/kernel_ridge.rb +0 -82
  75. data/lib/rumale/kernel_machine/kernel_ridge_classifier.rb +0 -92
  76. data/lib/rumale/kernel_machine/kernel_svc.rb +0 -193
  77. data/lib/rumale/linear_model/base_sgd.rb +0 -285
  78. data/lib/rumale/linear_model/elastic_net.rb +0 -119
  79. data/lib/rumale/linear_model/lasso.rb +0 -115
  80. data/lib/rumale/linear_model/linear_regression.rb +0 -201
  81. data/lib/rumale/linear_model/logistic_regression.rb +0 -275
  82. data/lib/rumale/linear_model/nnls.rb +0 -137
  83. data/lib/rumale/linear_model/ridge.rb +0 -209
  84. data/lib/rumale/linear_model/svc.rb +0 -213
  85. data/lib/rumale/linear_model/svr.rb +0 -132
  86. data/lib/rumale/manifold/mds.rb +0 -155
  87. data/lib/rumale/manifold/tsne.rb +0 -222
  88. data/lib/rumale/metric_learning/fisher_discriminant_analysis.rb +0 -113
  89. data/lib/rumale/metric_learning/mlkr.rb +0 -161
  90. data/lib/rumale/metric_learning/neighbourhood_component_analysis.rb +0 -167
  91. data/lib/rumale/model_selection/cross_validation.rb +0 -125
  92. data/lib/rumale/model_selection/function.rb +0 -42
  93. data/lib/rumale/model_selection/grid_search_cv.rb +0 -225
  94. data/lib/rumale/model_selection/group_k_fold.rb +0 -93
  95. data/lib/rumale/model_selection/group_shuffle_split.rb +0 -115
  96. data/lib/rumale/model_selection/k_fold.rb +0 -81
  97. data/lib/rumale/model_selection/shuffle_split.rb +0 -90
  98. data/lib/rumale/model_selection/stratified_k_fold.rb +0 -99
  99. data/lib/rumale/model_selection/stratified_shuffle_split.rb +0 -118
  100. data/lib/rumale/model_selection/time_series_split.rb +0 -91
  101. data/lib/rumale/multiclass/one_vs_rest_classifier.rb +0 -83
  102. data/lib/rumale/naive_bayes/base_naive_bayes.rb +0 -47
  103. data/lib/rumale/naive_bayes/bernoulli_nb.rb +0 -82
  104. data/lib/rumale/naive_bayes/complement_nb.rb +0 -85
  105. data/lib/rumale/naive_bayes/gaussian_nb.rb +0 -69
  106. data/lib/rumale/naive_bayes/multinomial_nb.rb +0 -74
  107. data/lib/rumale/naive_bayes/negation_nb.rb +0 -71
  108. data/lib/rumale/nearest_neighbors/k_neighbors_classifier.rb +0 -133
  109. data/lib/rumale/nearest_neighbors/k_neighbors_regressor.rb +0 -108
  110. data/lib/rumale/nearest_neighbors/vp_tree.rb +0 -132
  111. data/lib/rumale/neural_network/adam.rb +0 -56
  112. data/lib/rumale/neural_network/base_mlp.rb +0 -248
  113. data/lib/rumale/neural_network/mlp_classifier.rb +0 -120
  114. data/lib/rumale/neural_network/mlp_regressor.rb +0 -90
  115. data/lib/rumale/pairwise_metric.rb +0 -152
  116. data/lib/rumale/pipeline/feature_union.rb +0 -69
  117. data/lib/rumale/pipeline/pipeline.rb +0 -175
  118. data/lib/rumale/preprocessing/bin_discretizer.rb +0 -93
  119. data/lib/rumale/preprocessing/binarizer.rb +0 -60
  120. data/lib/rumale/preprocessing/kernel_calculator.rb +0 -92
  121. data/lib/rumale/preprocessing/l1_normalizer.rb +0 -62
  122. data/lib/rumale/preprocessing/l2_normalizer.rb +0 -63
  123. data/lib/rumale/preprocessing/label_binarizer.rb +0 -89
  124. data/lib/rumale/preprocessing/label_encoder.rb +0 -79
  125. data/lib/rumale/preprocessing/max_abs_scaler.rb +0 -61
  126. data/lib/rumale/preprocessing/max_normalizer.rb +0 -62
  127. data/lib/rumale/preprocessing/min_max_scaler.rb +0 -76
  128. data/lib/rumale/preprocessing/one_hot_encoder.rb +0 -100
  129. data/lib/rumale/preprocessing/ordinal_encoder.rb +0 -109
  130. data/lib/rumale/preprocessing/polynomial_features.rb +0 -109
  131. data/lib/rumale/preprocessing/standard_scaler.rb +0 -71
  132. data/lib/rumale/probabilistic_output.rb +0 -114
  133. data/lib/rumale/tree/base_decision_tree.rb +0 -150
  134. data/lib/rumale/tree/decision_tree_classifier.rb +0 -150
  135. data/lib/rumale/tree/decision_tree_regressor.rb +0 -116
  136. data/lib/rumale/tree/extra_tree_classifier.rb +0 -107
  137. data/lib/rumale/tree/extra_tree_regressor.rb +0 -94
  138. data/lib/rumale/tree/gradient_tree_regressor.rb +0 -202
  139. data/lib/rumale/tree/node.rb +0 -39
  140. data/lib/rumale/utils.rb +0 -42
  141. data/lib/rumale/validation.rb +0 -128
  142. data/lib/rumale/values.rb +0 -13
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Rumale
4
- module Tree
5
- # Node is a class that implements node used for construction of decision tree.
6
- # This class is used for internal data structures.
7
- class Node
8
- # @!visibility private
9
- attr_accessor :depth, :impurity, :n_samples, :probs, :leaf, :leaf_id, :left, :right, :feature_id, :threshold
10
-
11
- # Create a new node for decision tree.
12
- #
13
- # @param depth [Integer] The depth of the node in tree.
14
- # @param impurity [Float] The impurity of the node.
15
- # @param n_samples [Integer] The number of the samples in the node.
16
- # @param probs [Float] The probability of the node.
17
- # @param leaf [Boolean] The flag indicating whether the node is a leaf.
18
- # @param leaf_id [Integer] The leaf index of the node.
19
- # @param left [Node] The left node.
20
- # @param right [Node] The right node.
21
- # @param feature_id [Integer] The feature index used for evaluation.
22
- # @param threshold [Float] The threshold value of the feature for splitting the node.
23
- def initialize(depth: 0, impurity: 0.0, n_samples: 0, probs: 0.0,
24
- leaf: false, leaf_id: nil,
25
- left: nil, right: nil, feature_id: 0, threshold: 0.0)
26
- @depth = depth
27
- @impurity = impurity
28
- @n_samples = n_samples
29
- @probs = probs
30
- @leaf = leaf
31
- @leaf_id = leaf_id
32
- @left = left
33
- @right = right
34
- @feature_id = feature_id
35
- @threshold = threshold
36
- end
37
- end
38
- end
39
- end
data/lib/rumale/utils.rb DELETED
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Rumale
4
- # @!visibility private
5
- module Utils
6
- module_function
7
-
8
- # @!visibility private
9
- def choice_ids(size, probs, rng = nil)
10
- rng ||= Random.new
11
- Array.new(size) do
12
- target = rng.rand
13
- chosen = 0
14
- probs.each_with_index do |p, idx|
15
- break (chosen = idx) if target <= p
16
-
17
- target -= p
18
- end
19
- chosen
20
- end
21
- end
22
-
23
- # @!visibility private
24
- def rand_uniform(shape, rng = nil)
25
- rng ||= Random.new
26
- if shape.is_a?(Array)
27
- rnd_vals = Array.new(shape.inject(:*)) { rng.rand }
28
- Numo::DFloat.asarray(rnd_vals).reshape(shape[0], shape[1])
29
- else
30
- Numo::DFloat.asarray(Array.new(shape) { rng.rand })
31
- end
32
- end
33
-
34
- # @!visibility private
35
- def rand_normal(shape, rng = nil, mu = 0.0, sigma = 1.0)
36
- rng ||= Random.new
37
- a = rand_uniform(shape, rng)
38
- b = rand_uniform(shape, rng)
39
- (Numo::NMath.sqrt(Numo::NMath.log(a) * -2.0) * Numo::NMath.sin(b * 2.0 * Math::PI)) * sigma + mu
40
- end
41
- end
42
- end
@@ -1,128 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Rumale
4
- # @!visibility private
5
- module Validation
6
- module_function
7
-
8
- # @!visibility private
9
- def check_convert_sample_array(x)
10
- x = Numo::DFloat.cast(x) unless x.is_a?(Numo::DFloat)
11
- raise ArgumentError, 'Expect sample matrix to be 2-D array' unless x.ndim == 2
12
-
13
- x
14
- end
15
-
16
- # @!visibility private
17
- def check_convert_label_array(y)
18
- y = Numo::Int32.cast(y) unless y.is_a?(Numo::Int32)
19
- raise ArgumentError, 'Expect label vector to be 1-D arrray' unless y.ndim == 1
20
-
21
- y
22
- end
23
-
24
- # @!visibility private
25
- def check_convert_tvalue_array(y)
26
- y = Numo::DFloat.cast(y) unless y.is_a?(Numo::DFloat)
27
- y
28
- end
29
-
30
- # @deprecated Use check_convert_sample_array instead of this method.
31
- # @!visibility private
32
- def check_sample_array(x)
33
- raise TypeError, 'Expect class of sample matrix to be Numo::DFloat' unless x.is_a?(Numo::DFloat)
34
- raise ArgumentError, 'Expect sample matrix to be 2-D array' unless x.ndim == 2
35
-
36
- nil
37
- end
38
-
39
- # @deprecated Use check_convert_label_array instead of this method.
40
- # @!visibility private
41
- def check_label_array(y)
42
- raise TypeError, 'Expect class of label vector to be Numo::Int32' unless y.is_a?(Numo::Int32)
43
- raise ArgumentError, 'Expect label vector to be 1-D arrray' unless y.ndim == 1
44
-
45
- nil
46
- end
47
-
48
- # @deprecated Use check_convert_tvalue_array instead of this method.
49
- # @!visibility private
50
- def check_tvalue_array(y)
51
- raise TypeError, 'Expect class of target value vector to be Numo::DFloat' unless y.is_a?(Numo::DFloat)
52
-
53
- nil
54
- end
55
-
56
- # @!visibility private
57
- def check_sample_label_size(x, y)
58
- raise ArgumentError, 'Expect to have the same number of samples for sample matrix and label vector' unless x.shape[0] == y.shape[0]
59
-
60
- nil
61
- end
62
-
63
- # @!visibility private
64
- def check_sample_tvalue_size(x, y)
65
- raise ArgumentError, 'Expect to have the same number of samples for sample matrix and target value vector' unless x.shape[0] == y.shape[0]
66
-
67
- nil
68
- end
69
-
70
- # TODO: Better to replace with RBS in the future.
71
- # @!visibility private
72
- def check_params_type(type, params = {})
73
- params.each { |k, v| raise TypeError, "Expect class of #{k} to be #{type}" unless v.is_a?(type) }
74
- nil
75
- end
76
-
77
- # TODO: Better to replace with RBS in the future.
78
- # @!visibility private
79
- def check_params_type_or_nil(type, params = {})
80
- params.each { |k, v| raise TypeError, "Expect class of #{k} to be #{type} or nil" unless v.is_a?(type) || v.is_a?(NilClass) }
81
- nil
82
- end
83
-
84
- # TODO: Better to replace with RBS in the future.
85
- # @!visibility private
86
- def check_params_numeric(params = {})
87
- check_params_type(Numeric, params)
88
- end
89
-
90
- # TODO: Better to replace with RBS in the future.
91
- # @!visibility private
92
- def check_params_numeric_or_nil(params = {})
93
- check_params_type_or_nil(Numeric, params)
94
- end
95
-
96
- # @deprecated Use check_params_numeric instead of this method.
97
- # @!visibility private
98
- def check_params_float(params = {})
99
- check_params_type(Float, params)
100
- end
101
-
102
- # @deprecated Use check_params_numeric instead of this method.
103
- # @!visibility private
104
- def check_params_integer(params = {})
105
- check_params_type(Integer, params)
106
- end
107
-
108
- # TODO: Better to replace with RBS in the future.
109
- # @!visibility private
110
- def check_params_string(params = {})
111
- check_params_type(String, params)
112
- end
113
-
114
- # TODO: Better to replace with RBS in the future.
115
- # @!visibility private
116
- def check_params_boolean(params = {})
117
- params.each { |k, v| raise TypeError, "Expect class of #{k} to be Boolean" unless v.is_a?(FalseClass) || v.is_a?(TrueClass) }
118
- nil
119
- end
120
-
121
- # TODO: Better to replace with RBS in the future.
122
- # @!visibility private
123
- def check_params_positive(params = {})
124
- params.compact.each { |k, v| raise ArgumentError, "Expect #{k} to be positive value" if v.negative? }
125
- nil
126
- end
127
- end
128
- end
data/lib/rumale/values.rb DELETED
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Rumale
4
- # @!visibility private
5
- module Values
6
- module_function
7
-
8
- # @!visibility private
9
- def int_max
10
- @int_max ||= 2**([42].pack('i').size * 16 - 2) - 1
11
- end
12
- end
13
- end