rumale 0.18.6 → 0.19.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +80 -3
- data/CHANGELOG.md +45 -0
- data/Gemfile +2 -0
- data/README.md +5 -36
- data/lib/rumale.rb +5 -0
- data/lib/rumale/base/base_estimator.rb +2 -0
- data/lib/rumale/clustering/dbscan.rb +4 -0
- data/lib/rumale/clustering/gaussian_mixture.rb +2 -0
- data/lib/rumale/clustering/hdbscan.rb +3 -1
- data/lib/rumale/clustering/k_means.rb +2 -1
- data/lib/rumale/clustering/k_medoids.rb +5 -1
- data/lib/rumale/clustering/mini_batch_k_means.rb +139 -0
- data/lib/rumale/clustering/power_iteration.rb +2 -0
- data/lib/rumale/clustering/single_linkage.rb +2 -0
- data/lib/rumale/dataset.rb +5 -3
- data/lib/rumale/decomposition/factor_analysis.rb +2 -0
- data/lib/rumale/decomposition/pca.rb +24 -5
- data/lib/rumale/ensemble/ada_boost_classifier.rb +3 -0
- data/lib/rumale/ensemble/ada_boost_regressor.rb +3 -0
- data/lib/rumale/evaluation_measure/function.rb +2 -1
- data/lib/rumale/evaluation_measure/normalized_mutual_information.rb +2 -0
- data/lib/rumale/evaluation_measure/precision_recall.rb +5 -0
- data/lib/rumale/evaluation_measure/roc_auc.rb +3 -0
- data/lib/rumale/evaluation_measure/silhouette_score.rb +2 -0
- data/lib/rumale/feature_extraction/feature_hasher.rb +14 -1
- data/lib/rumale/feature_extraction/hash_vectorizer.rb +1 -0
- data/lib/rumale/feature_extraction/tfidf_transformer.rb +113 -0
- data/lib/rumale/kernel_approximation/nystroem.rb +1 -1
- data/lib/rumale/kernel_machine/kernel_ridge.rb +2 -0
- data/lib/rumale/kernel_machine/kernel_svc.rb +1 -1
- data/lib/rumale/linear_model/base_linear_model.rb +3 -1
- data/lib/rumale/linear_model/base_sgd.rb +1 -1
- data/lib/rumale/linear_model/linear_regression.rb +1 -0
- data/lib/rumale/linear_model/ridge.rb +1 -0
- data/lib/rumale/manifold/mds.rb +2 -0
- data/lib/rumale/manifold/tsne.rb +4 -0
- data/lib/rumale/metric_learning/neighbourhood_component_analysis.rb +14 -1
- data/lib/rumale/model_selection/cross_validation.rb +3 -2
- data/lib/rumale/model_selection/grid_search_cv.rb +1 -0
- data/lib/rumale/model_selection/k_fold.rb +1 -1
- data/lib/rumale/model_selection/shuffle_split.rb +1 -1
- data/lib/rumale/multiclass/one_vs_rest_classifier.rb +2 -2
- data/lib/rumale/nearest_neighbors/k_neighbors_classifier.rb +1 -0
- data/lib/rumale/nearest_neighbors/k_neighbors_regressor.rb +2 -0
- data/lib/rumale/nearest_neighbors/vp_tree.rb +1 -1
- data/lib/rumale/neural_network/adam.rb +1 -1
- data/lib/rumale/neural_network/base_mlp.rb +2 -1
- data/lib/rumale/optimizer/ada_grad.rb +3 -0
- data/lib/rumale/optimizer/adam.rb +3 -0
- data/lib/rumale/optimizer/nadam.rb +5 -0
- data/lib/rumale/optimizer/rmsprop.rb +3 -0
- data/lib/rumale/optimizer/sgd.rb +3 -0
- data/lib/rumale/optimizer/yellow_fin.rb +3 -0
- data/lib/rumale/pipeline/pipeline.rb +3 -0
- data/lib/rumale/polynomial_model/base_factorization_machine.rb +6 -1
- data/lib/rumale/polynomial_model/factorization_machine_classifier.rb +5 -0
- data/lib/rumale/polynomial_model/factorization_machine_regressor.rb +5 -0
- data/lib/rumale/preprocessing/binarizer.rb +60 -0
- data/lib/rumale/preprocessing/l1_normalizer.rb +62 -0
- data/lib/rumale/preprocessing/l2_normalizer.rb +2 -1
- data/lib/rumale/preprocessing/max_normalizer.rb +62 -0
- data/lib/rumale/preprocessing/one_hot_encoder.rb +3 -0
- data/lib/rumale/preprocessing/ordinal_encoder.rb +2 -0
- data/lib/rumale/preprocessing/polynomial_features.rb +1 -0
- data/lib/rumale/probabilistic_output.rb +2 -0
- data/lib/rumale/tree/base_decision_tree.rb +2 -0
- data/lib/rumale/tree/decision_tree_classifier.rb +1 -0
- data/lib/rumale/tree/gradient_tree_regressor.rb +1 -0
- data/lib/rumale/utils.rb +1 -0
- data/lib/rumale/validation.rb +7 -0
- data/lib/rumale/version.rb +1 -1
- data/rumale.gemspec +1 -3
- metadata +11 -34
@@ -10,6 +10,10 @@ module Rumale
|
|
10
10
|
# with stochastic gradient descent (SGD) optimization.
|
11
11
|
# For multiclass classification problem, it uses one-vs-the-rest strategy.
|
12
12
|
#
|
13
|
+
# @deprecated
|
14
|
+
# FactorizationMachineClassifier will be deleted in version 0.20.0.
|
15
|
+
# The Ruamle author recommends using the xlearn gem instead.
|
16
|
+
#
|
13
17
|
# @example
|
14
18
|
# estimator =
|
15
19
|
# Rumale::PolynomialModel::FactorizationMachineClassifier.new(
|
@@ -65,6 +69,7 @@ module Rumale
|
|
65
69
|
def initialize(n_factors: 2, loss: 'hinge', reg_param_linear: 1.0, reg_param_factor: 1.0,
|
66
70
|
max_iter: 200, batch_size: 50, tol: 1e-4,
|
67
71
|
optimizer: nil, n_jobs: nil, verbose: false, random_seed: nil)
|
72
|
+
warn 'warning: FactorizationMachineClassifier is deprecated. This class will be deleted in version 0.20.0.'
|
68
73
|
check_params_numeric(reg_param_linear: reg_param_linear, reg_param_factor: reg_param_factor,
|
69
74
|
n_factors: n_factors, max_iter: max_iter, batch_size: batch_size, tol: tol)
|
70
75
|
check_params_string(loss: loss)
|
@@ -8,6 +8,10 @@ module Rumale
|
|
8
8
|
# FactorizationMachineRegressor is a class that implements Factorization Machine
|
9
9
|
# with stochastic gradient descent (SGD) optimization.
|
10
10
|
#
|
11
|
+
# @deprecated
|
12
|
+
# FactorizationMachineRegressor will be deleted in version 0.20.0.
|
13
|
+
# The Ruamle author recommends using the xlearn gem instead.
|
14
|
+
#
|
11
15
|
# @example
|
12
16
|
# estimator =
|
13
17
|
# Rumale::PolynomialModel::FactorizationMachineRegressor.new(
|
@@ -58,6 +62,7 @@ module Rumale
|
|
58
62
|
def initialize(n_factors: 2, reg_param_linear: 1.0, reg_param_factor: 1.0,
|
59
63
|
max_iter: 200, batch_size: 50, tol: 1e-4,
|
60
64
|
optimizer: nil, n_jobs: nil, verbose: false, random_seed: nil)
|
65
|
+
warn 'warning: FactorizationMachineClassifier is deprecated. This class will be deleted in version 0.20.0.'
|
61
66
|
check_params_numeric(reg_param_linear: reg_param_linear, reg_param_factor: reg_param_factor,
|
62
67
|
n_factors: n_factors, max_iter: max_iter, batch_size: batch_size, tol: tol)
|
63
68
|
check_params_boolean(verbose: verbose)
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rumale/base/base_estimator'
|
4
|
+
require 'rumale/base/transformer'
|
5
|
+
|
6
|
+
module Rumale
|
7
|
+
module Preprocessing
|
8
|
+
# Binarize samples according to a threshold
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
# binarizer = Rumale::Preprocessing::Binarizer.new
|
12
|
+
# x = Numo::DFloat[[-1.2, 3.2], [2.4, -0.5], [4.5, 0.8]]
|
13
|
+
# b = binarizer.transform(x)
|
14
|
+
# p b
|
15
|
+
#
|
16
|
+
# # Numo::DFloat#shape=[3, 2]
|
17
|
+
# # [[0, 1],
|
18
|
+
# # [1, 0],
|
19
|
+
# # [1, 1]]
|
20
|
+
class Binarizer
|
21
|
+
include Base::BaseEstimator
|
22
|
+
include Base::Transformer
|
23
|
+
|
24
|
+
# Create a new transformer for binarization.
|
25
|
+
# @param threshold [Float] The threshold value for binarization.
|
26
|
+
def initialize(threshold: 0.0)
|
27
|
+
check_params_numeric(threshold: threshold)
|
28
|
+
@params = { threshold: threshold }
|
29
|
+
end
|
30
|
+
|
31
|
+
# This method does nothing and returns the object itself.
|
32
|
+
# For compatibility with other transformer, this method exists.
|
33
|
+
#
|
34
|
+
# @overload fit() -> Binarizer
|
35
|
+
#
|
36
|
+
# @return [Binarizer]
|
37
|
+
def fit(_x = nil, _y = nil)
|
38
|
+
self
|
39
|
+
end
|
40
|
+
|
41
|
+
# Binarize each sample.
|
42
|
+
#
|
43
|
+
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The samples to be binarized.
|
44
|
+
# @return [Numo::DFloat] The binarized samples.
|
45
|
+
def transform(x)
|
46
|
+
x = check_convert_sample_array(x)
|
47
|
+
x.class.cast(x.gt(@params[:threshold]))
|
48
|
+
end
|
49
|
+
|
50
|
+
# The output of this method is the same as that of the transform method.
|
51
|
+
# For compatibility with other transformer, this method exists.
|
52
|
+
#
|
53
|
+
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The samples to be binarized.
|
54
|
+
# @return [Numo::DFloat] The binarized samples.
|
55
|
+
def fit_transform(x, _y = nil)
|
56
|
+
fit(x).transform(x)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rumale/base/base_estimator'
|
4
|
+
require 'rumale/base/transformer'
|
5
|
+
|
6
|
+
module Rumale
|
7
|
+
module Preprocessing
|
8
|
+
# Normalize samples to unit L1-norm.
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
# normalizer = Rumale::Preprocessing::L1Normalizer.new
|
12
|
+
# new_samples = normalizer.fit_transform(samples)
|
13
|
+
class L1Normalizer
|
14
|
+
include Base::BaseEstimator
|
15
|
+
include Base::Transformer
|
16
|
+
|
17
|
+
# Return the vector consists of L1-norm for each sample.
|
18
|
+
# @return [Numo::DFloat] (shape: [n_samples])
|
19
|
+
attr_reader :norm_vec # :nodoc:
|
20
|
+
|
21
|
+
# Create a new normalizer for normaliing to L1-norm.
|
22
|
+
def initialize
|
23
|
+
@params = {}
|
24
|
+
@norm_vec = nil
|
25
|
+
end
|
26
|
+
|
27
|
+
# Calculate L1-norms of each sample.
|
28
|
+
#
|
29
|
+
# @overload fit(x) -> L1Normalizer
|
30
|
+
#
|
31
|
+
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The samples to calculate L1-norms.
|
32
|
+
# @return [L1Normalizer]
|
33
|
+
def fit(x, _y = nil)
|
34
|
+
x = check_convert_sample_array(x)
|
35
|
+
@norm_vec = x.abs.sum(1)
|
36
|
+
@norm_vec[@norm_vec.eq(0)] = 1
|
37
|
+
self
|
38
|
+
end
|
39
|
+
|
40
|
+
# Calculate L1-norms of each sample, and then normalize samples to L1-norm.
|
41
|
+
#
|
42
|
+
# @overload fit_transform(x) -> Numo::DFloat
|
43
|
+
#
|
44
|
+
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The samples to calculate L1-norms.
|
45
|
+
# @return [Numo::DFloat] The normalized samples.
|
46
|
+
def fit_transform(x, _y = nil)
|
47
|
+
x = check_convert_sample_array(x)
|
48
|
+
fit(x)
|
49
|
+
x / @norm_vec.expand_dims(1)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Calculate L1-norms of each sample, and then normalize samples to L1-norm.
|
53
|
+
# This method calls the fit_transform method. This method exists for the Pipeline class.
|
54
|
+
#
|
55
|
+
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The samples to calculate L1-norms.
|
56
|
+
# @return [Numo::DFloat] The normalized samples.
|
57
|
+
def transform(x)
|
58
|
+
fit_transform(x)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -34,6 +34,7 @@ module Rumale
|
|
34
34
|
def fit(x, _y = nil)
|
35
35
|
x = check_convert_sample_array(x)
|
36
36
|
@norm_vec = Numo::NMath.sqrt((x**2).sum(1))
|
37
|
+
@norm_vec[@norm_vec.eq(0)] = 1
|
37
38
|
self
|
38
39
|
end
|
39
40
|
|
@@ -46,7 +47,7 @@ module Rumale
|
|
46
47
|
def fit_transform(x, _y = nil)
|
47
48
|
x = check_convert_sample_array(x)
|
48
49
|
fit(x)
|
49
|
-
x / @norm_vec.
|
50
|
+
x / @norm_vec.expand_dims(1)
|
50
51
|
end
|
51
52
|
|
52
53
|
# Calculate L2-norms of each sample, and then normalize samples to unit L2-norm.
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rumale/base/base_estimator'
|
4
|
+
require 'rumale/base/transformer'
|
5
|
+
|
6
|
+
module Rumale
|
7
|
+
module Preprocessing
|
8
|
+
# Normalize samples with the maximum of the absolute values.
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
# normalizer = Rumale::Preprocessing::MaxNormalizer.new
|
12
|
+
# new_samples = normalizer.fit_transform(samples)
|
13
|
+
class MaxNormalizer
|
14
|
+
include Base::BaseEstimator
|
15
|
+
include Base::Transformer
|
16
|
+
|
17
|
+
# Return the vector consists of the maximum norm for each sample.
|
18
|
+
# @return [Numo::DFloat] (shape: [n_samples])
|
19
|
+
attr_reader :norm_vec # :nodoc:
|
20
|
+
|
21
|
+
# Create a new normalizer for normaliing to max-norm.
|
22
|
+
def initialize
|
23
|
+
@params = {}
|
24
|
+
@norm_vec = nil
|
25
|
+
end
|
26
|
+
|
27
|
+
# Calculate the maximum norms of each sample.
|
28
|
+
#
|
29
|
+
# @overload fit(x) -> MaxNormalizer
|
30
|
+
#
|
31
|
+
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The samples to calculate the maximum norms.
|
32
|
+
# @return [MaxNormalizer]
|
33
|
+
def fit(x, _y = nil)
|
34
|
+
x = check_convert_sample_array(x)
|
35
|
+
@norm_vec = x.abs.max(1)
|
36
|
+
@norm_vec[@norm_vec.eq(0)] = 1
|
37
|
+
self
|
38
|
+
end
|
39
|
+
|
40
|
+
# Calculate the maximums norm of each sample, and then normalize samples with the norms.
|
41
|
+
#
|
42
|
+
# @overload fit_transform(x) -> Numo::DFloat
|
43
|
+
#
|
44
|
+
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The samples to calculate maximum norms.
|
45
|
+
# @return [Numo::DFloat] The normalized samples.
|
46
|
+
def fit_transform(x, _y = nil)
|
47
|
+
x = check_convert_sample_array(x)
|
48
|
+
fit(x)
|
49
|
+
x / @norm_vec.expand_dims(1)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Calculate the maximum norms of each sample, and then normalize samples with the norms.
|
53
|
+
# This method calls the fit_transform method. This method exists for the Pipeline class.
|
54
|
+
#
|
55
|
+
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The samples to calculate maximum norms.
|
56
|
+
# @return [Numo::DFloat] The normalized samples.
|
57
|
+
def transform(x)
|
58
|
+
fit_transform(x)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -51,6 +51,7 @@ module Rumale
|
|
51
51
|
def fit(x, _y = nil)
|
52
52
|
x = Numo::Int32.cast(x) unless x.is_a?(Numo::Int32)
|
53
53
|
raise ArgumentError, 'Expected the input samples only consists of non-negative integer values.' if x.lt(0).any?
|
54
|
+
|
54
55
|
@n_values = x.max(0) + 1
|
55
56
|
@feature_indices = Numo::Int32.hstack([[0], @n_values]).cumsum
|
56
57
|
@active_features = encode(x, @feature_indices).sum(0).ne(0).where
|
@@ -67,6 +68,7 @@ module Rumale
|
|
67
68
|
x = Numo::Int32.cast(x) unless x.is_a?(Numo::Int32)
|
68
69
|
raise ArgumentError, 'Expected the input samples only consists of non-negative integer values.' if x.lt(0).any?
|
69
70
|
raise ArgumentError, 'Expected the input samples only consists of non-negative integer values.' if x.lt(0).any?
|
71
|
+
|
70
72
|
fit(x).transform(x)
|
71
73
|
end
|
72
74
|
|
@@ -77,6 +79,7 @@ module Rumale
|
|
77
79
|
def transform(x)
|
78
80
|
x = Numo::Int32.cast(x) unless x.is_a?(Numo::Int32)
|
79
81
|
raise ArgumentError, 'Expected the input samples only consists of non-negative integer values.' if x.lt(0).any?
|
82
|
+
|
80
83
|
codes = encode(x, @feature_indices)
|
81
84
|
codes[true, @active_features].dup
|
82
85
|
end
|
@@ -51,6 +51,7 @@ module Rumale
|
|
51
51
|
def fit(x, _y = nil)
|
52
52
|
raise TypeError, 'Expect class of sample matrix to be Numo::NArray' unless x.is_a?(Numo::NArray)
|
53
53
|
raise ArgumentError, 'Expect sample matrix to be 2-D array' unless x.shape.size == 2
|
54
|
+
|
54
55
|
n_features = x.shape[1]
|
55
56
|
@categories = Array.new(n_features) { |n| x[true, n].to_a.uniq.sort }
|
56
57
|
self
|
@@ -65,6 +66,7 @@ module Rumale
|
|
65
66
|
def fit_transform(x, _y = nil)
|
66
67
|
raise TypeError, 'Expect class of sample matrix to be Numo::NArray' unless x.is_a?(Numo::NArray)
|
67
68
|
raise ArgumentError, 'Expect sample matrix to be 2-D array' unless x.shape.size == 2
|
69
|
+
|
68
70
|
fit(x).transform(x)
|
69
71
|
end
|
70
72
|
|
@@ -41,6 +41,7 @@ module Rumale
|
|
41
41
|
def initialize(degree: 2)
|
42
42
|
check_params_numeric(degree: degree)
|
43
43
|
raise ArgumentError, 'Expect the value of degree parameter greater than or eqaul to 1.' if degree < 1
|
44
|
+
|
44
45
|
@params = {}
|
45
46
|
@params[:degree] = degree
|
46
47
|
@n_output_features = nil
|
@@ -47,6 +47,7 @@ module Rumale
|
|
47
47
|
hess_mat = hessian_matrix(probs, df, sigma)
|
48
48
|
break if grad_vec.abs.lt(1e-5).count == 2
|
49
49
|
break if (old_grad_vec - grad_vec).abs.sum < 1e-5
|
50
|
+
|
50
51
|
old_grad_vec = grad_vec
|
51
52
|
# Calculate Newton directions.
|
52
53
|
dirs_vec = directions(grad_vec, hess_mat)
|
@@ -58,6 +59,7 @@ module Rumale
|
|
58
59
|
new_beta = beta + stepsize * dirs_vec[1]
|
59
60
|
new_err = error_function(target_probs, df, new_alpha, new_beta)
|
60
61
|
next unless new_err < err + 0.0001 * stepsize * grad_dir
|
62
|
+
|
61
63
|
alpha = new_alpha
|
62
64
|
beta = new_beta
|
63
65
|
err = new_err
|
@@ -53,6 +53,7 @@ module Rumale
|
|
53
53
|
return node.leaf_id if node.leaf
|
54
54
|
return apply_at_node(node.left, sample) if node.right.nil?
|
55
55
|
return apply_at_node(node.right, sample) if node.left.nil?
|
56
|
+
|
56
57
|
if sample[node.feature_id] <= node.threshold
|
57
58
|
apply_at_node(node.left, sample)
|
58
59
|
else
|
@@ -138,6 +139,7 @@ module Rumale
|
|
138
139
|
def eval_importance_at_node(node)
|
139
140
|
return nil if node.leaf
|
140
141
|
return nil if node.left.nil? || node.right.nil?
|
142
|
+
|
141
143
|
gain = node.n_samples * node.impurity -
|
142
144
|
node.left.n_samples * node.left.impurity -
|
143
145
|
node.right.n_samples * node.right.impurity
|
@@ -110,6 +110,7 @@ module Rumale
|
|
110
110
|
return node.probs if node.leaf
|
111
111
|
return predict_proba_at_node(node.left, sample) if node.right.nil?
|
112
112
|
return predict_proba_at_node(node.right, sample) if node.left.nil?
|
113
|
+
|
113
114
|
if sample[node.feature_id] <= node.threshold
|
114
115
|
predict_proba_at_node(node.left, sample)
|
115
116
|
else
|
@@ -123,6 +123,7 @@ module Rumale
|
|
123
123
|
return node.leaf_id if node.leaf
|
124
124
|
return apply_at_node(node.left, sample) if node.right.nil?
|
125
125
|
return apply_at_node(node.right, sample) if node.left.nil?
|
126
|
+
|
126
127
|
if sample[node.feature_id] <= node.threshold
|
127
128
|
apply_at_node(node.left, sample)
|
128
129
|
else
|
data/lib/rumale/utils.rb
CHANGED
data/lib/rumale/validation.rb
CHANGED
@@ -9,6 +9,7 @@ module Rumale
|
|
9
9
|
def check_convert_sample_array(x)
|
10
10
|
x = Numo::DFloat.cast(x) unless x.is_a?(Numo::DFloat)
|
11
11
|
raise ArgumentError, 'Expect sample matrix to be 2-D array' unless x.ndim == 2
|
12
|
+
|
12
13
|
x
|
13
14
|
end
|
14
15
|
|
@@ -16,6 +17,7 @@ module Rumale
|
|
16
17
|
def check_convert_label_array(y)
|
17
18
|
y = Numo::Int32.cast(y) unless y.is_a?(Numo::Int32)
|
18
19
|
raise ArgumentError, 'Expect label vector to be 1-D arrray' unless y.ndim == 1
|
20
|
+
|
19
21
|
y
|
20
22
|
end
|
21
23
|
|
@@ -29,6 +31,7 @@ module Rumale
|
|
29
31
|
def check_sample_array(x)
|
30
32
|
raise TypeError, 'Expect class of sample matrix to be Numo::DFloat' unless x.is_a?(Numo::DFloat)
|
31
33
|
raise ArgumentError, 'Expect sample matrix to be 2-D array' unless x.ndim == 2
|
34
|
+
|
32
35
|
nil
|
33
36
|
end
|
34
37
|
|
@@ -36,24 +39,28 @@ module Rumale
|
|
36
39
|
def check_label_array(y)
|
37
40
|
raise TypeError, 'Expect class of label vector to be Numo::Int32' unless y.is_a?(Numo::Int32)
|
38
41
|
raise ArgumentError, 'Expect label vector to be 1-D arrray' unless y.ndim == 1
|
42
|
+
|
39
43
|
nil
|
40
44
|
end
|
41
45
|
|
42
46
|
# @!visibility private
|
43
47
|
def check_tvalue_array(y)
|
44
48
|
raise TypeError, 'Expect class of target value vector to be Numo::DFloat' unless y.is_a?(Numo::DFloat)
|
49
|
+
|
45
50
|
nil
|
46
51
|
end
|
47
52
|
|
48
53
|
# @!visibility private
|
49
54
|
def check_sample_label_size(x, y)
|
50
55
|
raise ArgumentError, 'Expect to have the same number of samples for sample matrix and label vector' unless x.shape[0] == y.shape[0]
|
56
|
+
|
51
57
|
nil
|
52
58
|
end
|
53
59
|
|
54
60
|
# @!visibility private
|
55
61
|
def check_sample_tvalue_size(x, y)
|
56
62
|
raise ArgumentError, 'Expect to have the same number of samples for sample matrix and target value vector' unless x.shape[0] == y.shape[0]
|
63
|
+
|
57
64
|
nil
|
58
65
|
end
|
59
66
|
|
data/lib/rumale/version.rb
CHANGED
data/rumale.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
Rumale is a machine learning library in Ruby.
|
17
17
|
Rumale provides machine learning algorithms with interfaces similar to Scikit-Learn in Python.
|
18
18
|
Rumale supports Support Vector Machine,
|
19
|
-
Logistic Regression, Ridge, Lasso,
|
19
|
+
Logistic Regression, Ridge, Lasso,
|
20
20
|
Multi-layer Perceptron,
|
21
21
|
Naive Bayes, Decision Tree, Gradient Tree Boosting, Random Forest,
|
22
22
|
K-Means, Gaussian Mixture Model, DBSCAN, Spectral Clustering,
|
@@ -45,6 +45,4 @@ Gem::Specification.new do |spec|
|
|
45
45
|
}
|
46
46
|
|
47
47
|
spec.add_runtime_dependency 'numo-narray', '>= 0.9.1'
|
48
|
-
spec.add_runtime_dependency 'mopti', '>= 0.1.0'
|
49
|
-
spec.add_runtime_dependency 'mmh3', '>= 0.1.0'
|
50
48
|
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.
|
4
|
+
version: 0.19.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yoshoku
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: numo-narray
|
@@ -24,39 +24,11 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.9.1
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: mopti
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 0.1.0
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 0.1.0
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: mmh3
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 0.1.0
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 0.1.0
|
55
27
|
description: |
|
56
28
|
Rumale is a machine learning library in Ruby.
|
57
29
|
Rumale provides machine learning algorithms with interfaces similar to Scikit-Learn in Python.
|
58
30
|
Rumale supports Support Vector Machine,
|
59
|
-
Logistic Regression, Ridge, Lasso,
|
31
|
+
Logistic Regression, Ridge, Lasso,
|
60
32
|
Multi-layer Perceptron,
|
61
33
|
Naive Bayes, Decision Tree, Gradient Tree Boosting, Random Forest,
|
62
34
|
K-Means, Gaussian Mixture Model, DBSCAN, Spectral Clustering,
|
@@ -100,6 +72,7 @@ files:
|
|
100
72
|
- lib/rumale/clustering/hdbscan.rb
|
101
73
|
- lib/rumale/clustering/k_means.rb
|
102
74
|
- lib/rumale/clustering/k_medoids.rb
|
75
|
+
- lib/rumale/clustering/mini_batch_k_means.rb
|
103
76
|
- lib/rumale/clustering/power_iteration.rb
|
104
77
|
- lib/rumale/clustering/single_linkage.rb
|
105
78
|
- lib/rumale/clustering/snn.rb
|
@@ -140,6 +113,7 @@ files:
|
|
140
113
|
- lib/rumale/evaluation_measure/silhouette_score.rb
|
141
114
|
- lib/rumale/feature_extraction/feature_hasher.rb
|
142
115
|
- lib/rumale/feature_extraction/hash_vectorizer.rb
|
116
|
+
- lib/rumale/feature_extraction/tfidf_transformer.rb
|
143
117
|
- lib/rumale/kernel_approximation/nystroem.rb
|
144
118
|
- lib/rumale/kernel_approximation/rbf.rb
|
145
119
|
- lib/rumale/kernel_machine/kernel_fda.rb
|
@@ -193,10 +167,13 @@ files:
|
|
193
167
|
- lib/rumale/polynomial_model/factorization_machine_classifier.rb
|
194
168
|
- lib/rumale/polynomial_model/factorization_machine_regressor.rb
|
195
169
|
- lib/rumale/preprocessing/bin_discretizer.rb
|
170
|
+
- lib/rumale/preprocessing/binarizer.rb
|
171
|
+
- lib/rumale/preprocessing/l1_normalizer.rb
|
196
172
|
- lib/rumale/preprocessing/l2_normalizer.rb
|
197
173
|
- lib/rumale/preprocessing/label_binarizer.rb
|
198
174
|
- lib/rumale/preprocessing/label_encoder.rb
|
199
175
|
- lib/rumale/preprocessing/max_abs_scaler.rb
|
176
|
+
- lib/rumale/preprocessing/max_normalizer.rb
|
200
177
|
- lib/rumale/preprocessing/min_max_scaler.rb
|
201
178
|
- lib/rumale/preprocessing/one_hot_encoder.rb
|
202
179
|
- lib/rumale/preprocessing/ordinal_encoder.rb
|
@@ -224,7 +201,7 @@ metadata:
|
|
224
201
|
source_code_uri: https://github.com/yoshoku/rumale
|
225
202
|
documentation_uri: https://yoshoku.github.io/rumale/doc/
|
226
203
|
bug_tracker_uri: https://github.com/yoshoku/rumale/issues
|
227
|
-
post_install_message:
|
204
|
+
post_install_message:
|
228
205
|
rdoc_options: []
|
229
206
|
require_paths:
|
230
207
|
- lib
|
@@ -240,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
240
217
|
version: '0'
|
241
218
|
requirements: []
|
242
219
|
rubygems_version: 3.1.2
|
243
|
-
signing_key:
|
220
|
+
signing_key:
|
244
221
|
specification_version: 4
|
245
222
|
summary: Rumale is a machine learning library in Ruby. Rumale provides machine learning
|
246
223
|
algorithms with interfaces similar to Scikit-Learn in Python.
|