Files
redux-scraper/sorbet/rbi/gems/rumale-core@1.0.0.rbi
2025-07-10 19:24:41 +00:00

576 lines
22 KiB
Ruby
Generated

# typed: true
# DO NOT EDIT MANUALLY
# This is an autogenerated file for types exported from the `rumale-core` gem.
# Please instead update this file by running `bin/tapioca gem rumale-core`.
# Rumale is a machine learning library in Ruby.
#
# source://rumale-core//lib/rumale/core/version.rb#4
module Rumale; end
# This module consists of basic mix-in classes.
#
# source://rumale-core//lib/rumale/base/estimator.rb#7
module Rumale::Base; end
# Module for all classifiers in Rumale.
#
# source://rumale-core//lib/rumale/base/classifier.rb#10
module Rumale::Base::Classifier
# An abstract method for fitting a model.
#
# @raise [NotImplementedError]
#
# source://rumale-core//lib/rumale/base/classifier.rb#12
def fit; end
# An abstract method for predicting labels.
#
# @raise [NotImplementedError]
#
# source://rumale-core//lib/rumale/base/classifier.rb#17
def predict; end
# Calculate the mean accuracy of the given testing data.
#
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) Testing data.
# @param y [Numo::Int32] (shape: [n_samples]) True labels for testing data.
# @return [Float] Mean accuracy
#
# source://rumale-core//lib/rumale/base/classifier.rb#26
def score(x, y); end
end
# Module for all clustering algorithms in Rumale.
#
# source://rumale-core//lib/rumale/base/cluster_analyzer.rb#8
module Rumale::Base::ClusterAnalyzer
# An abstract method for analyzing clusters and predicting cluster indices.
#
# @raise [NotImplementedError]
#
# source://rumale-core//lib/rumale/base/cluster_analyzer.rb#10
def fit_predict; end
# Calculate purity of clustering result.
#
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) Testing data.
# @param y [Numo::Int32] (shape: [n_samples]) True labels for testing data.
# @return [Float] Purity
#
# source://rumale-core//lib/rumale/base/cluster_analyzer.rb#19
def score(x, y); end
end
# Base class for all estimators in Rumale.
#
# source://rumale-core//lib/rumale/base/estimator.rb#9
class Rumale::Base::Estimator
# Return parameters about an estimator.
#
# @return [Hash]
#
# source://rumale-core//lib/rumale/base/estimator.rb#12
def params; end
private
# @return [Boolean]
#
# source://rumale-core//lib/rumale/base/estimator.rb#16
def enable_linalg?(warning: T.unsafe(nil)); end
# @return [Boolean]
#
# source://rumale-core//lib/rumale/base/estimator.rb#34
def enable_parallel?(warning: T.unsafe(nil)); end
# source://rumale-core//lib/rumale/base/estimator.rb#47
def n_processes; end
# source://rumale-core//lib/rumale/base/estimator.rb#53
def parallel_map(n_outputs, &block); end
end
# Module for all evaluation measures in Rumale.
#
# source://rumale-core//lib/rumale/base/evaluator.rb#8
module Rumale::Base::Evaluator
# An abstract method for evaluation of model.
#
# @raise [NotImplementedError]
#
# source://rumale-core//lib/rumale/base/evaluator.rb#10
def score; end
end
# Module for all regressors in Rumale.
#
# source://rumale-core//lib/rumale/base/regressor.rb#8
module Rumale::Base::Regressor
# An abstract method for fitting a model.
#
# @raise [NotImplementedError]
#
# source://rumale-core//lib/rumale/base/regressor.rb#10
def fit; end
# An abstract method for predicting labels.
#
# @raise [NotImplementedError]
#
# source://rumale-core//lib/rumale/base/regressor.rb#15
def predict; end
# Calculate the coefficient of determination for the given testing data.
#
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) Testing data.
# @param y [Numo::DFloat] (shape: [n_samples, n_outputs]) Target values for testing data.
# @return [Float] Coefficient of determination
#
# source://rumale-core//lib/rumale/base/regressor.rb#24
def score(x, y); end
end
# Module for all validation methods in Rumale.
#
# source://rumale-core//lib/rumale/base/splitter.rb#8
module Rumale::Base::Splitter
# Return the number of splits.
#
# @return [Integer]
#
# source://rumale-core//lib/rumale/base/splitter.rb#11
def n_splits; end
# An abstract method for splitting dataset.
#
# @raise [NotImplementedError]
#
# source://rumale-core//lib/rumale/base/splitter.rb#14
def split; end
end
# Module for all transfomers in Rumale.
#
# source://rumale-core//lib/rumale/base/transformer.rb#8
module Rumale::Base::Transformer
# An abstract method for fitting a model.
#
# @raise [NotImplementedError]
#
# source://rumale-core//lib/rumale/base/transformer.rb#10
def fit; end
# An abstract method for fitting a model and transforming given data.
#
# @raise [NotImplementedError]
#
# source://rumale-core//lib/rumale/base/transformer.rb#15
def fit_transform; end
end
# source://rumale-core//lib/rumale/core/version.rb#6
module Rumale::Core; end
# source://rumale-core//lib/rumale/core/version.rb#8
Rumale::Core::VERSION = T.let(T.unsafe(nil), String)
# Module for loading and saving a dataset file.
#
# source://rumale-core//lib/rumale/dataset.rb#9
module Rumale::Dataset
class << self
# Dump the dataset with the libsvm file format.
#
# @param data [Numo::NArray] (shape: [n_samples, n_features]) matrix consisting of feature vectors.
# @param labels [Numo::NArray] (shape: [n_samples]) matrix consisting of labels or target values.
# @param filename [String] A path to the output libsvm file.
# @param zero_based [Boolean] Whether the column index starts from 0 (true) or 1 (false).
#
# source://rumale-core//lib/rumale/dataset.rb#43
def dump_libsvm_file(data, labels, filename, zero_based: T.unsafe(nil)); end
# Load a dataset with the libsvm file format into Numo::NArray.
#
# @param filename [String] A path to a dataset file.
# @param n_features [Integer/Nil] The number of features of data to load.
# If nil is given, it will be detected automatically from given file.
# @param zero_based [Boolean] Whether the column index starts from 0 (true) or 1 (false).
# @param dtype [Numo::NArray] Data type of Numo::NArray for features to be loaded.
# @return [Array<Numo::NArray>] Returns array containing the (n_samples x n_features) matrix for feature vectors
# and (n_samples) vector for labels or target values.
#
# source://rumale-core//lib/rumale/dataset.rb#22
def load_libsvm_file(filename, n_features: T.unsafe(nil), zero_based: T.unsafe(nil), dtype: T.unsafe(nil)); end
# Generate Gaussian blobs.
#
# @param n_samples [Integer] The total number of samples.
# @param n_features [Integer] The number of features.
# If "centers" parameter is given as a Numo::DFloat array, this parameter is ignored.
# @param centers [Integer/Numo::DFloat/Nil] The number of cluster centroids or the fixed cluster centroids.
# If nil is given, the number of cluster centroids is set to 3.
# @param cluster_std [Float] The standard deviation of the clusters.
# @param center_box [Array] The bounding box for each cluster centroids.
# If "centers" parameter is given as a Numo::DFloat array, this parameter is ignored.
# @param shuffle [Boolean] The flag indicating whether to shuffle the dataset
# @param random_seed [Integer] The seed value using to initialize the random generator.
#
# source://rumale-core//lib/rumale/dataset.rb#134
def make_blobs(n_samples = T.unsafe(nil), n_features = T.unsafe(nil), centers: T.unsafe(nil), cluster_std: T.unsafe(nil), center_box: T.unsafe(nil), shuffle: T.unsafe(nil), random_seed: T.unsafe(nil)); end
# Generate a two-dimensional data set consisting of an inner circle and an outer circle.
#
# @param n_samples [Integer] The number of samples.
# @param shuffle [Boolean] The flag indicating whether to shuffle the dataset
# @param noise [Float] The standard deviaion of gaussian noise added to the data.
# If nil is given, no noise is added.
# @param factor [Float] The scale factor between inner and outer circles. The interval of factor is (0, 1).
# @param random_seed [Integer] The seed value using to initialize the random generator.
#
# source://rumale-core//lib/rumale/dataset.rb#65
def make_circles(n_samples, shuffle: T.unsafe(nil), noise: T.unsafe(nil), factor: T.unsafe(nil), random_seed: T.unsafe(nil)); end
# Generate a two-dimensional data set consisting of two half circles shifted.
#
# @param n_samples [Integer] The number of samples.
# @param shuffle [Boolean] The flag indicating whether to shuffle the dataset
# @param noise [Float] The standard deviaion of gaussian noise added to the data.
# If nil is given, no noise is added.
# @param random_seed [Integer] The seed value using to initialize the random generator.
#
# source://rumale-core//lib/rumale/dataset.rb#97
def make_moons(n_samples, shuffle: T.unsafe(nil), noise: T.unsafe(nil), random_seed: T.unsafe(nil)); end
private
# source://rumale-core//lib/rumale/dataset.rb#196
def convert_to_matrix(data, n_features, dtype); end
# source://rumale-core//lib/rumale/dataset.rb#206
def detect_dtype(data); end
# source://rumale-core//lib/rumale/dataset.rb#224
def dump_label(label, label_type_str); end
# source://rumale-core//lib/rumale/dataset.rb#215
def dump_libsvm_line(label, ftvec, label_type, value_type, zero_based); end
# source://rumale-core//lib/rumale/dataset.rb#191
def parse_label(label); end
# source://rumale-core//lib/rumale/dataset.rb#176
def parse_libsvm_line(line, zero_based); end
end
end
# Module for calculating pairwise distances, similarities, and kernels.
#
# source://rumale-core//lib/rumale/pairwise_metric.rb#7
module Rumale::PairwiseMetric
private
# Calculate the pairwise cosine distances between x and y.
#
# @param x [Numo::DFloat] (shape: [n_samples_x, n_features])
# @param y [Numo::DFloat] (shape: [n_samples_y, n_features])
# @return [Numo::DFloat] (shape: [n_samples_x, n_samples_x] or [n_samples_x, n_samples_y] if y is given)
#
# source://rumale-core//lib/rumale/pairwise_metric.rb#74
def cosine_distance(x, y = T.unsafe(nil)); end
# Calculate the pairwise cosine simlarities between x and y.
#
# @param x [Numo::DFloat] (shape: [n_samples_x, n_features])
# @param y [Numo::DFloat] (shape: [n_samples_y, n_features])
# @return [Numo::DFloat] (shape: [n_samples_x, n_samples_x] or [n_samples_x, n_samples_y] if y is given)
#
# source://rumale-core//lib/rumale/pairwise_metric.rb#55
def cosine_similarity(x, y = T.unsafe(nil)); end
# Calculate the pairwise euclidean distances between x and y.
#
# @param x [Numo::DFloat] (shape: [n_samples_x, n_features])
# @param y [Numo::DFloat] (shape: [n_samples_y, n_features])
# @return [Numo::DFloat] (shape: [n_samples_x, n_samples_x] or [n_samples_x, n_samples_y] if y is given)
#
# source://rumale-core//lib/rumale/pairwise_metric.rb#15
def euclidean_distance(x, y = T.unsafe(nil)); end
# Calculate the linear kernel between x and y.
#
# @param x [Numo::DFloat] (shape: [n_samples_x, n_features])
# @param y [Numo::DFloat] (shape: [n_samples_y, n_features])
# @return [Numo::DFloat] (shape: [n_samples_x, n_samples_x] or [n_samples_x, n_samples_y] if y is given)
#
# source://rumale-core//lib/rumale/pairwise_metric.rb#97
def linear_kernel(x, y = T.unsafe(nil)); end
# Calculate the pairwise manhattan distances between x and y.
#
# @param x [Numo::DFloat] (shape: [n_samples_x, n_features])
# @param y [Numo::DFloat] (shape: [n_samples_y, n_features])
# @return [Numo::DFloat] (shape: [n_samples_x, n_samples_x] or [n_samples_x, n_samples_y] if y is given)
#
# source://rumale-core//lib/rumale/pairwise_metric.rb#24
def manhattan_distance(x, y = T.unsafe(nil)); end
# Calculate the polynomial kernel between x and y.
#
# @param x [Numo::DFloat] (shape: [n_samples_x, n_features])
# @param y [Numo::DFloat] (shape: [n_samples_y, n_features])
# @param degree [Integer] The parameter of polynomial kernel.
# @param gamma [Float] The parameter of polynomial kernel, if nil it is 1 / n_features.
# @param coef [Integer] The parameter of polynomial kernel.
# @return [Numo::DFloat] (shape: [n_samples_x, n_samples_x] or [n_samples_x, n_samples_y] if y is given)
#
# source://rumale-core//lib/rumale/pairwise_metric.rb#110
def polynomial_kernel(x, y = T.unsafe(nil), degree = T.unsafe(nil), gamma = T.unsafe(nil), coef = T.unsafe(nil)); end
# Calculate the rbf kernel between x and y.
#
# @param x [Numo::DFloat] (shape: [n_samples_x, n_features])
# @param y [Numo::DFloat] (shape: [n_samples_y, n_features])
# @param gamma [Float] The parameter of rbf kernel, if nil it is 1 / n_features.
# @return [Numo::DFloat] (shape: [n_samples_x, n_samples_x] or [n_samples_x, n_samples_y] if y is given)
#
# source://rumale-core//lib/rumale/pairwise_metric.rb#86
def rbf_kernel(x, y = T.unsafe(nil), gamma = T.unsafe(nil)); end
# Calculate the sigmoid kernel between x and y.
#
# @param x [Numo::DFloat] (shape: [n_samples_x, n_features])
# @param y [Numo::DFloat] (shape: [n_samples_y, n_features])
# @param gamma [Float] The parameter of polynomial kernel, if nil it is 1 / n_features.
# @param coef [Integer] The parameter of polynomial kernel.
# @return [Numo::DFloat] (shape: [n_samples_x, n_samples_x] or [n_samples_x, n_samples_y] if y is given)
#
# source://rumale-core//lib/rumale/pairwise_metric.rb#123
def sigmoid_kernel(x, y = T.unsafe(nil), gamma = T.unsafe(nil), coef = T.unsafe(nil)); end
# Calculate the pairwise squared errors between x and y.
#
# @param x [Numo::DFloat] (shape: [n_samples_x, n_features])
# @param y [Numo::DFloat] (shape: [n_samples_y, n_features])
# @return [Numo::DFloat] (shape: [n_samples_x, n_samples_x] or [n_samples_x, n_samples_y] if y is given)
#
# source://rumale-core//lib/rumale/pairwise_metric.rb#40
def squared_error(x, y = T.unsafe(nil)); end
class << self
# Calculate the pairwise cosine distances between x and y.
#
# @param x [Numo::DFloat] (shape: [n_samples_x, n_features])
# @param y [Numo::DFloat] (shape: [n_samples_y, n_features])
# @return [Numo::DFloat] (shape: [n_samples_x, n_samples_x] or [n_samples_x, n_samples_y] if y is given)
#
# source://rumale-core//lib/rumale/pairwise_metric.rb#74
def cosine_distance(x, y = T.unsafe(nil)); end
# Calculate the pairwise cosine simlarities between x and y.
#
# @param x [Numo::DFloat] (shape: [n_samples_x, n_features])
# @param y [Numo::DFloat] (shape: [n_samples_y, n_features])
# @return [Numo::DFloat] (shape: [n_samples_x, n_samples_x] or [n_samples_x, n_samples_y] if y is given)
#
# source://rumale-core//lib/rumale/pairwise_metric.rb#55
def cosine_similarity(x, y = T.unsafe(nil)); end
# Calculate the pairwise euclidean distances between x and y.
#
# @param x [Numo::DFloat] (shape: [n_samples_x, n_features])
# @param y [Numo::DFloat] (shape: [n_samples_y, n_features])
# @return [Numo::DFloat] (shape: [n_samples_x, n_samples_x] or [n_samples_x, n_samples_y] if y is given)
#
# source://rumale-core//lib/rumale/pairwise_metric.rb#15
def euclidean_distance(x, y = T.unsafe(nil)); end
# Calculate the linear kernel between x and y.
#
# @param x [Numo::DFloat] (shape: [n_samples_x, n_features])
# @param y [Numo::DFloat] (shape: [n_samples_y, n_features])
# @return [Numo::DFloat] (shape: [n_samples_x, n_samples_x] or [n_samples_x, n_samples_y] if y is given)
#
# source://rumale-core//lib/rumale/pairwise_metric.rb#97
def linear_kernel(x, y = T.unsafe(nil)); end
# Calculate the pairwise manhattan distances between x and y.
#
# @param x [Numo::DFloat] (shape: [n_samples_x, n_features])
# @param y [Numo::DFloat] (shape: [n_samples_y, n_features])
# @return [Numo::DFloat] (shape: [n_samples_x, n_samples_x] or [n_samples_x, n_samples_y] if y is given)
#
# source://rumale-core//lib/rumale/pairwise_metric.rb#24
def manhattan_distance(x, y = T.unsafe(nil)); end
# Calculate the polynomial kernel between x and y.
#
# @param x [Numo::DFloat] (shape: [n_samples_x, n_features])
# @param y [Numo::DFloat] (shape: [n_samples_y, n_features])
# @param degree [Integer] The parameter of polynomial kernel.
# @param gamma [Float] The parameter of polynomial kernel, if nil it is 1 / n_features.
# @param coef [Integer] The parameter of polynomial kernel.
# @return [Numo::DFloat] (shape: [n_samples_x, n_samples_x] or [n_samples_x, n_samples_y] if y is given)
#
# source://rumale-core//lib/rumale/pairwise_metric.rb#110
def polynomial_kernel(x, y = T.unsafe(nil), degree = T.unsafe(nil), gamma = T.unsafe(nil), coef = T.unsafe(nil)); end
# Calculate the rbf kernel between x and y.
#
# @param x [Numo::DFloat] (shape: [n_samples_x, n_features])
# @param y [Numo::DFloat] (shape: [n_samples_y, n_features])
# @param gamma [Float] The parameter of rbf kernel, if nil it is 1 / n_features.
# @return [Numo::DFloat] (shape: [n_samples_x, n_samples_x] or [n_samples_x, n_samples_y] if y is given)
#
# source://rumale-core//lib/rumale/pairwise_metric.rb#86
def rbf_kernel(x, y = T.unsafe(nil), gamma = T.unsafe(nil)); end
# Calculate the sigmoid kernel between x and y.
#
# @param x [Numo::DFloat] (shape: [n_samples_x, n_features])
# @param y [Numo::DFloat] (shape: [n_samples_y, n_features])
# @param gamma [Float] The parameter of polynomial kernel, if nil it is 1 / n_features.
# @param coef [Integer] The parameter of polynomial kernel.
# @return [Numo::DFloat] (shape: [n_samples_x, n_samples_x] or [n_samples_x, n_samples_y] if y is given)
#
# source://rumale-core//lib/rumale/pairwise_metric.rb#123
def sigmoid_kernel(x, y = T.unsafe(nil), gamma = T.unsafe(nil), coef = T.unsafe(nil)); end
# Calculate the pairwise squared errors between x and y.
#
# @param x [Numo::DFloat] (shape: [n_samples_x, n_features])
# @param y [Numo::DFloat] (shape: [n_samples_y, n_features])
# @return [Numo::DFloat] (shape: [n_samples_x, n_samples_x] or [n_samples_x, n_samples_y] if y is given)
#
# source://rumale-core//lib/rumale/pairwise_metric.rb#40
def squared_error(x, y = T.unsafe(nil)); end
end
end
# Module for calculating posterior class probabilities with SVM outputs.
# This module is used for internal processes.
#
# *Reference*
# - Platt, J C., "Probabilistic Outputs for Support Vector Machines and Comparisons to Regularized Likelihood Methods," Adv. Large Margin Classifiers, pp. 61--74, 2000.
# - Lin, H-T., Lin, C-J., and Weng, R C., "A Note on Platt's Probabilistic Outputs for Support Vector Machines," J. Machine Learning, Vol. 63 (3), pp. 267--276, 2007.
#
# @example
# estimator = Rumale::LinearModel::SVC.new
# estimator.fit(x, bin_y)
# df = estimator.decision_function(x)
# params = Rumale::ProbabilisticOutput.fit_sigmoid(df, bin_y)
# probs = 1 / (Numo::NMath.exp(params[0] * df + params[1]) + 1)
#
# source://rumale-core//lib/rumale/probabilistic_output.rb#19
module Rumale::ProbabilisticOutput
class << self
# Fit the probabilistic model for binary SVM outputs.
#
# @param df [Numo::DFloat] (shape: [n_samples]) The outputs of decision function to be used for fitting the model.
# @param bin_y [Numo::Int32] (shape: [n_samples]) The binary labels to be used for fitting the model.
# @param max_iter [Integer] The maximum number of iterations.
# @param min_step [Float] The minimum step of Newton's method.
# @param sigma [Float] The parameter to avoid hessian matrix from becoming singular matrix.
# @return [Numo::DFloat] (shape: 2) The parameters of the model.
#
# source://rumale-core//lib/rumale/probabilistic_output.rb#29
def fit_sigmoid(df, bin_y, max_iter = T.unsafe(nil), min_step = T.unsafe(nil), sigma = T.unsafe(nil)); end
private
# source://rumale-core//lib/rumale/probabilistic_output.rb#109
def directions(grad_vec, hess_mat); end
# source://rumale-core//lib/rumale/probabilistic_output.rb#76
def error_function(target_probs, df, alpha, beta); end
# source://rumale-core//lib/rumale/probabilistic_output.rb#96
def gradient(target_probs, probs, df); end
# source://rumale-core//lib/rumale/probabilistic_output.rb#101
def hessian_matrix(probs, df, sigma); end
# source://rumale-core//lib/rumale/probabilistic_output.rb#86
def predicted_probs(df, alpha, beta); end
end
end
# source://rumale-core//lib/rumale/utils.rb#7
module Rumale::Utils
private
# source://rumale-core//lib/rumale/utils.rb#45
def binarize_labels(labels); end
# source://rumale-core//lib/rumale/utils.rb#11
def choice_ids(size, probs, rng = T.unsafe(nil)); end
# source://rumale-core//lib/rumale/utils.rb#56
def normalize(x, norm); end
# source://rumale-core//lib/rumale/utils.rb#37
def rand_normal(shape, rng = T.unsafe(nil), mu = T.unsafe(nil), sigma = T.unsafe(nil)); end
# source://rumale-core//lib/rumale/utils.rb#26
def rand_uniform(shape, rng = T.unsafe(nil)); end
class << self
# source://rumale-core//lib/rumale/utils.rb#45
def binarize_labels(labels); end
# source://rumale-core//lib/rumale/utils.rb#11
def choice_ids(size, probs, rng = T.unsafe(nil)); end
# source://rumale-core//lib/rumale/utils.rb#56
def normalize(x, norm); end
# source://rumale-core//lib/rumale/utils.rb#37
def rand_normal(shape, rng = T.unsafe(nil), mu = T.unsafe(nil), sigma = T.unsafe(nil)); end
# source://rumale-core//lib/rumale/utils.rb#26
def rand_uniform(shape, rng = T.unsafe(nil)); end
end
end
# source://rumale-core//lib/rumale/validation.rb#5
module Rumale::Validation
private
# source://rumale-core//lib/rumale/validation.rb#17
def check_convert_label_array(y); end
# source://rumale-core//lib/rumale/validation.rb#9
def check_convert_sample_array(x); end
# source://rumale-core//lib/rumale/validation.rb#25
def check_convert_target_value_array(y); end
# source://rumale-core//lib/rumale/validation.rb#33
def check_sample_size(x, y); end
class << self
# @raise [ArgumentError]
#
# source://rumale-core//lib/rumale/validation.rb#17
def check_convert_label_array(y); end
# @raise [ArgumentError]
#
# source://rumale-core//lib/rumale/validation.rb#9
def check_convert_sample_array(x); end
# @raise [ArgumentError]
#
# source://rumale-core//lib/rumale/validation.rb#25
def check_convert_target_value_array(y); end
# @raise [ArgumentError]
#
# source://rumale-core//lib/rumale/validation.rb#33
def check_sample_size(x, y); end
end
end