rumale 0.13.8 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -0
- data/README.md +8 -10
- data/lib/rumale.rb +3 -0
- data/lib/rumale/base/classifier.rb +2 -2
- data/lib/rumale/base/cluster_analyzer.rb +2 -2
- data/lib/rumale/base/regressor.rb +2 -2
- data/lib/rumale/clustering/dbscan.rb +3 -4
- data/lib/rumale/clustering/gaussian_mixture.rb +5 -6
- data/lib/rumale/clustering/hdbscan.rb +4 -4
- data/lib/rumale/clustering/k_means.rb +5 -6
- data/lib/rumale/clustering/k_medoids.rb +5 -6
- data/lib/rumale/clustering/power_iteration.rb +4 -6
- data/lib/rumale/clustering/single_linkage.rb +3 -3
- data/lib/rumale/clustering/snn.rb +1 -1
- data/lib/rumale/clustering/spectral_clustering.rb +4 -6
- data/lib/rumale/dataset.rb +6 -10
- data/lib/rumale/decomposition/factor_analysis.rb +4 -4
- data/lib/rumale/decomposition/fast_ica.rb +6 -7
- data/lib/rumale/decomposition/nmf.rb +6 -7
- data/lib/rumale/decomposition/pca.rb +6 -7
- data/lib/rumale/ensemble/ada_boost_classifier.rb +8 -8
- data/lib/rumale/ensemble/ada_boost_regressor.rb +7 -7
- data/lib/rumale/ensemble/extra_trees_classifier.rb +8 -8
- data/lib/rumale/ensemble/extra_trees_regressor.rb +7 -7
- data/lib/rumale/ensemble/gradient_boosting_classifier.rb +8 -8
- data/lib/rumale/ensemble/gradient_boosting_regressor.rb +8 -8
- data/lib/rumale/ensemble/random_forest_classifier.rb +8 -8
- data/lib/rumale/ensemble/random_forest_regressor.rb +7 -7
- data/lib/rumale/evaluation_measure/accuracy.rb +2 -2
- data/lib/rumale/evaluation_measure/adjusted_rand_score.rb +2 -2
- data/lib/rumale/evaluation_measure/calinski_harabasz_score.rb +2 -2
- data/lib/rumale/evaluation_measure/davies_bouldin_score.rb +2 -2
- data/lib/rumale/evaluation_measure/explained_variance_score.rb +2 -2
- data/lib/rumale/evaluation_measure/f_score.rb +2 -2
- data/lib/rumale/evaluation_measure/log_loss.rb +2 -2
- data/lib/rumale/evaluation_measure/mean_absolute_error.rb +2 -2
- data/lib/rumale/evaluation_measure/mean_squared_error.rb +2 -2
- data/lib/rumale/evaluation_measure/mean_squared_log_error.rb +2 -2
- data/lib/rumale/evaluation_measure/median_absolute_error.rb +2 -2
- data/lib/rumale/evaluation_measure/mutual_information.rb +2 -2
- data/lib/rumale/evaluation_measure/normalized_mutual_information.rb +2 -2
- data/lib/rumale/evaluation_measure/precision.rb +2 -2
- data/lib/rumale/evaluation_measure/purity.rb +2 -2
- data/lib/rumale/evaluation_measure/r2_score.rb +2 -2
- data/lib/rumale/evaluation_measure/recall.rb +2 -2
- data/lib/rumale/evaluation_measure/roc_auc.rb +6 -3
- data/lib/rumale/evaluation_measure/silhouette_score.rb +2 -2
- data/lib/rumale/kernel_approximation/rbf.rb +5 -6
- data/lib/rumale/kernel_machine/kernel_pca.rb +4 -4
- data/lib/rumale/kernel_machine/kernel_ridge.rb +3 -3
- data/lib/rumale/kernel_machine/kernel_svc.rb +7 -8
- data/lib/rumale/linear_model/lasso.rb +5 -6
- data/lib/rumale/linear_model/linear_regression.rb +5 -6
- data/lib/rumale/linear_model/logistic_regression.rb +16 -15
- data/lib/rumale/linear_model/ridge.rb +5 -6
- data/lib/rumale/linear_model/svc.rb +34 -28
- data/lib/rumale/linear_model/svr.rb +5 -6
- data/lib/rumale/manifold/mds.rb +3 -4
- data/lib/rumale/manifold/tsne.rb +3 -5
- data/lib/rumale/model_selection/cross_validation.rb +6 -5
- data/lib/rumale/model_selection/grid_search_cv.rb +6 -6
- data/lib/rumale/model_selection/k_fold.rb +3 -3
- data/lib/rumale/model_selection/shuffle_split.rb +3 -5
- data/lib/rumale/model_selection/stratified_k_fold.rb +4 -4
- data/lib/rumale/model_selection/stratified_shuffle_split.rb +4 -6
- data/lib/rumale/multiclass/one_vs_rest_classifier.rb +4 -4
- data/lib/rumale/naive_bayes/naive_bayes.rb +14 -14
- data/lib/rumale/nearest_neighbors/k_neighbors_classifier.rb +5 -5
- data/lib/rumale/nearest_neighbors/k_neighbors_regressor.rb +4 -4
- data/lib/rumale/neural_network/base_mlp.rb +244 -0
- data/lib/rumale/neural_network/mlp_classifier.rb +119 -0
- data/lib/rumale/neural_network/mlp_regressor.rb +89 -0
- data/lib/rumale/optimizer/ada_grad.rb +1 -1
- data/lib/rumale/optimizer/adam.rb +3 -3
- data/lib/rumale/optimizer/nadam.rb +1 -1
- data/lib/rumale/optimizer/rmsprop.rb +1 -1
- data/lib/rumale/optimizer/sgd.rb +1 -1
- data/lib/rumale/optimizer/yellow_fin.rb +1 -2
- data/lib/rumale/pairwise_metric.rb +17 -19
- data/lib/rumale/pipeline/pipeline.rb +10 -10
- data/lib/rumale/polynomial_model/factorization_machine_classifier.rb +29 -21
- data/lib/rumale/polynomial_model/factorization_machine_regressor.rb +6 -6
- data/lib/rumale/preprocessing/bin_discretizer.rb +3 -3
- data/lib/rumale/preprocessing/l2_normalizer.rb +2 -2
- data/lib/rumale/preprocessing/label_binarizer.rb +2 -2
- data/lib/rumale/preprocessing/label_encoder.rb +1 -1
- data/lib/rumale/preprocessing/max_abs_scaler.rb +3 -3
- data/lib/rumale/preprocessing/min_max_scaler.rb +3 -3
- data/lib/rumale/preprocessing/one_hot_encoder.rb +4 -3
- data/lib/rumale/preprocessing/ordinal_encoder.rb +1 -1
- data/lib/rumale/preprocessing/standard_scaler.rb +3 -3
- data/lib/rumale/tree/base_decision_tree.rb +1 -1
- data/lib/rumale/tree/decision_tree_classifier.rb +7 -7
- data/lib/rumale/tree/decision_tree_regressor.rb +6 -6
- data/lib/rumale/tree/extra_tree_classifier.rb +7 -7
- data/lib/rumale/tree/extra_tree_regressor.rb +6 -6
- data/lib/rumale/tree/gradient_tree_regressor.rb +9 -9
- data/lib/rumale/validation.rb +32 -2
- data/lib/rumale/version.rb +1 -1
- data/rumale.gemspec +7 -7
- metadata +11 -7
@@ -46,9 +46,9 @@ module Rumale
|
|
46
46
|
# It is used to randomly determine the order of features when deciding spliting point.
|
47
47
|
def initialize(criterion: 'mse', max_depth: nil, max_leaf_nodes: nil, min_samples_leaf: 1, max_features: nil,
|
48
48
|
random_seed: nil)
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
check_params_numeric_or_nil(max_depth: max_depth, max_leaf_nodes: max_leaf_nodes,
|
50
|
+
max_features: max_features, random_seed: random_seed)
|
51
|
+
check_params_numeric(min_samples_leaf: min_samples_leaf)
|
52
52
|
check_params_string(criterion: criterion)
|
53
53
|
check_params_positive(max_depth: max_depth, max_leaf_nodes: max_leaf_nodes,
|
54
54
|
min_samples_leaf: min_samples_leaf, max_features: max_features)
|
@@ -61,8 +61,8 @@ module Rumale
|
|
61
61
|
# @param y [Numo::DFloat] (shape: [n_samples, n_outputs]) The taget values to be used for fitting the model.
|
62
62
|
# @return [ExtraTreeRegressor] The learned regressor itself.
|
63
63
|
def fit(x, y)
|
64
|
-
|
65
|
-
|
64
|
+
x = check_convert_sample_array(x)
|
65
|
+
y = check_convert_tvalue_array(y)
|
66
66
|
check_sample_tvalue_size(x, y)
|
67
67
|
super
|
68
68
|
end
|
@@ -72,7 +72,7 @@ module Rumale
|
|
72
72
|
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The samples to predict the values.
|
73
73
|
# @return [Numo::DFloat] (shape: [n_samples, n_outputs]) Predicted values per sample.
|
74
74
|
def predict(x)
|
75
|
-
|
75
|
+
x = check_convert_sample_array(x)
|
76
76
|
super
|
77
77
|
end
|
78
78
|
|
@@ -52,10 +52,9 @@ module Rumale
|
|
52
52
|
# It is used to randomly determine the order of features when deciding spliting point.
|
53
53
|
def initialize(reg_lambda: 0.0, shrinkage_rate: 1.0,
|
54
54
|
max_depth: nil, max_leaf_nodes: nil, min_samples_leaf: 1, max_features: nil, random_seed: nil)
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
check_params_integer(min_samples_leaf: min_samples_leaf)
|
55
|
+
check_params_numeric_or_nil(max_depth: max_depth, max_leaf_nodes: max_leaf_nodes,
|
56
|
+
max_features: max_features, random_seed: random_seed)
|
57
|
+
check_params_numeric(reg_lambda: reg_lambda, shrinkage_rate: shrinkage_rate, min_samples_leaf: min_samples_leaf)
|
59
58
|
check_params_positive(reg_lambda: reg_lambda, shrinkage_rate: shrinkage_rate,
|
60
59
|
max_depth: max_depth, max_leaf_nodes: max_leaf_nodes,
|
61
60
|
min_samples_leaf: min_samples_leaf, max_features: max_features)
|
@@ -83,10 +82,11 @@ module Rumale
|
|
83
82
|
# @param h [Numo::DFloat] (shape: [n_samples]) The hessian of loss function.
|
84
83
|
# @return [GradientTreeRegressor] The learned regressor itself.
|
85
84
|
def fit(x, y, g, h)
|
86
|
-
|
87
|
-
|
85
|
+
x = check_convert_sample_array(x)
|
86
|
+
y = check_convert_tvalue_array(y)
|
87
|
+
g = check_convert_tvalue_array(g)
|
88
|
+
h = check_convert_tvalue_array(h)
|
88
89
|
check_sample_tvalue_size(x, y)
|
89
|
-
check_params_type(Numo::DFloat, g: g, h: g)
|
90
90
|
# Initialize some variables.
|
91
91
|
n_features = x.shape[1]
|
92
92
|
@params[:max_features] ||= n_features
|
@@ -105,7 +105,7 @@ module Rumale
|
|
105
105
|
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The samples to predict the values.
|
106
106
|
# @return [Numo::DFloat] (size: n_samples) Predicted values per sample.
|
107
107
|
def predict(x)
|
108
|
-
|
108
|
+
x = check_convert_sample_array(x)
|
109
109
|
@leaf_weights[apply(x)].dup
|
110
110
|
end
|
111
111
|
|
@@ -114,7 +114,7 @@ module Rumale
|
|
114
114
|
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The samples to predict the labels.
|
115
115
|
# @return [Numo::Int32] (shape: [n_samples]) Leaf index for sample.
|
116
116
|
def apply(x)
|
117
|
-
|
117
|
+
x = check_convert_sample_array(x)
|
118
118
|
Numo::Int32[*(Array.new(x.shape[0]) { |n| apply_at_node(@tree, x[n, true]) })]
|
119
119
|
end
|
120
120
|
|
data/lib/rumale/validation.rb
CHANGED
@@ -5,17 +5,37 @@ module Rumale
|
|
5
5
|
module Validation
|
6
6
|
module_function
|
7
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
|
+
x
|
13
|
+
end
|
14
|
+
|
15
|
+
# @!visibility private
|
16
|
+
def check_convert_label_array(y)
|
17
|
+
y = Numo::Int32.cast(y) unless y.is_a?(Numo::Int32)
|
18
|
+
raise ArgumentError, 'Expect label vector to be 1-D arrray' unless y.ndim == 1
|
19
|
+
y
|
20
|
+
end
|
21
|
+
|
22
|
+
# @!visibility private
|
23
|
+
def check_convert_tvalue_array(y)
|
24
|
+
y = Numo::DFloat.cast(y) unless y.is_a?(Numo::DFloat)
|
25
|
+
y
|
26
|
+
end
|
27
|
+
|
8
28
|
# @!visibility private
|
9
29
|
def check_sample_array(x)
|
10
30
|
raise TypeError, 'Expect class of sample matrix to be Numo::DFloat' unless x.is_a?(Numo::DFloat)
|
11
|
-
raise ArgumentError, 'Expect sample matrix to be 2-D array' unless x.
|
31
|
+
raise ArgumentError, 'Expect sample matrix to be 2-D array' unless x.ndim == 2
|
12
32
|
nil
|
13
33
|
end
|
14
34
|
|
15
35
|
# @!visibility private
|
16
36
|
def check_label_array(y)
|
17
37
|
raise TypeError, 'Expect class of label vector to be Numo::Int32' unless y.is_a?(Numo::Int32)
|
18
|
-
raise ArgumentError, 'Expect label vector to be 1-D arrray' unless y.
|
38
|
+
raise ArgumentError, 'Expect label vector to be 1-D arrray' unless y.ndim == 1
|
19
39
|
nil
|
20
40
|
end
|
21
41
|
|
@@ -49,6 +69,16 @@ module Rumale
|
|
49
69
|
nil
|
50
70
|
end
|
51
71
|
|
72
|
+
# @!visibility private
|
73
|
+
def check_params_numeric(params = {})
|
74
|
+
check_params_type(Numeric, params)
|
75
|
+
end
|
76
|
+
|
77
|
+
# @!visibility private
|
78
|
+
def check_params_numeric_or_nil(params = {})
|
79
|
+
check_params_type_or_nil(Numeric, params)
|
80
|
+
end
|
81
|
+
|
52
82
|
# @!visibility private
|
53
83
|
def check_params_float(params = {})
|
54
84
|
check_params_type(Float, params)
|
data/lib/rumale/version.rb
CHANGED
data/rumale.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
lib = File.expand_path('lib', __dir__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'rumale/version'
|
@@ -13,14 +12,15 @@ Gem::Specification.new do |spec|
|
|
13
12
|
Rumale is a machine learning library in Ruby.
|
14
13
|
Rumale provides machine learning algorithms with interfaces similar to Scikit-Learn in Python.
|
15
14
|
MSG
|
16
|
-
spec.description
|
15
|
+
spec.description = <<~MSG
|
17
16
|
Rumale is a machine learning library in Ruby.
|
18
17
|
Rumale provides machine learning algorithms with interfaces similar to Scikit-Learn in Python.
|
19
|
-
Rumale
|
20
|
-
Logistic Regression,
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
Rumale supports Support Vector Machine,
|
19
|
+
Logistic Regression, Ridge, Lasso, Factorization Machine,
|
20
|
+
Multi-layer Perceptron,
|
21
|
+
Naive Bayes, Decision Tree, Gradient Tree Boosting, Random Forest,
|
22
|
+
K-Means, Gaussian Mixture Model, DBSCAN, Spectral Clustering,
|
23
|
+
Mutidimensional Scaling, t-SNE, Principal Component Analysis, and Non-negative Matrix Factorization.
|
24
24
|
MSG
|
25
25
|
spec.homepage = 'https://github.com/yoshoku/rumale'
|
26
26
|
spec.license = 'BSD-2-Clause'
|
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.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yoshoku
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: numo-narray
|
@@ -125,11 +125,12 @@ dependencies:
|
|
125
125
|
description: |
|
126
126
|
Rumale is a machine learning library in Ruby.
|
127
127
|
Rumale provides machine learning algorithms with interfaces similar to Scikit-Learn in Python.
|
128
|
-
Rumale
|
129
|
-
Logistic Regression,
|
130
|
-
|
131
|
-
|
132
|
-
|
128
|
+
Rumale supports Support Vector Machine,
|
129
|
+
Logistic Regression, Ridge, Lasso, Factorization Machine,
|
130
|
+
Multi-layer Perceptron,
|
131
|
+
Naive Bayes, Decision Tree, Gradient Tree Boosting, Random Forest,
|
132
|
+
K-Means, Gaussian Mixture Model, DBSCAN, Spectral Clustering,
|
133
|
+
Mutidimensional Scaling, t-SNE, Principal Component Analysis, and Non-negative Matrix Factorization.
|
133
134
|
email:
|
134
135
|
- yoshoku@outlook.com
|
135
136
|
executables: []
|
@@ -226,6 +227,9 @@ files:
|
|
226
227
|
- lib/rumale/naive_bayes/naive_bayes.rb
|
227
228
|
- lib/rumale/nearest_neighbors/k_neighbors_classifier.rb
|
228
229
|
- lib/rumale/nearest_neighbors/k_neighbors_regressor.rb
|
230
|
+
- lib/rumale/neural_network/base_mlp.rb
|
231
|
+
- lib/rumale/neural_network/mlp_classifier.rb
|
232
|
+
- lib/rumale/neural_network/mlp_regressor.rb
|
229
233
|
- lib/rumale/optimizer/ada_grad.rb
|
230
234
|
- lib/rumale/optimizer/adam.rb
|
231
235
|
- lib/rumale/optimizer/nadam.rb
|