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

210 lines
8.8 KiB
Ruby
Generated

# typed: true
# DO NOT EDIT MANUALLY
# This is an autogenerated file for types exported from the `rumale-pipeline` gem.
# Please instead update this file by running `bin/tapioca gem rumale-pipeline`.
# Rumale is a machine learning library in Ruby.
#
# source://rumale-pipeline//lib/rumale/pipeline/feature_union.rb#5
module Rumale; end
# Module implements utilities of pipeline that cosists of a chain of transfomers and estimators.
#
# source://rumale-pipeline//lib/rumale/pipeline/feature_union.rb#6
module Rumale::Pipeline; end
# FeatureUnion is a class that implements the function concatenating the multi-transformer results.
#
# @example
# require 'rumale/kernel_approximation/rbf'
# require 'rumale/decomposition/pca'
# require 'rumale/pipeline/feature_union'
#
# fu = Rumale::Pipeline::FeatureUnion.new(
# transformers: {
# 'rbf': Rumale::KernelApproximation::RBF.new(gamma: 1.0, n_components: 96, random_seed: 1),
# 'pca': Rumale::Decomposition::PCA.new(n_components: 32)
# }
# )
# fu.fit(training_samples, traininig_labels)
# results = fu.predict(testing_samples)
#
# # > p results.shape[1]
# # > 128
#
# source://rumale-pipeline//lib/rumale/pipeline/feature_union.rb#26
class Rumale::Pipeline::FeatureUnion < ::Rumale::Base::Estimator
# Create a new feature union.
#
# @param transformers [Hash] List of transformers. The order of transforms follows the insertion order of hash keys.
# @return [FeatureUnion] a new instance of FeatureUnion
#
# source://rumale-pipeline//lib/rumale/pipeline/feature_union.rb#34
def initialize(transformers:); end
# Fit the model with given training data.
#
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The training data to be used for fitting the transformers.
# @param y [Numo::NArray/Nil] (shape: [n_samples, n_outputs]) The target values or labels to be used for fitting the transformers.
# @return [FeatureUnion] The learned feature union itself.
#
# source://rumale-pipeline//lib/rumale/pipeline/feature_union.rb#45
def fit(x, y = T.unsafe(nil)); end
# Fit the model with training data, and then transform them with the learned model.
#
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The training data to be used for fitting the transformers.
# @param y [Numo::NArray/Nil] (shape: [n_samples, n_outputs]) The target values or labels to be used for fitting the transformers.
# @return [Numo::DFloat] (shape: [n_samples, sum_n_components]) The transformed and concatenated data.
#
# source://rumale-pipeline//lib/rumale/pipeline/feature_union.rb#55
def fit_transform(x, y = T.unsafe(nil)); end
# Transform the given data with the learned model.
#
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The data to be transformed with the learned transformers.
# @return [Numo::DFloat] (shape: [n_samples, sum_n_components]) The transformed and concatenated data.
#
# source://rumale-pipeline//lib/rumale/pipeline/feature_union.rb#63
def transform(x); end
# Return the transformers
#
# @return [Hash]
#
# source://rumale-pipeline//lib/rumale/pipeline/feature_union.rb#29
def transformers; end
end
# Pipeline is a class that implements the function to perform the transformers and estimators sequencially.
#
# @example
# require 'rumale/kernel_approximation/rbf'
# require 'rumale/linear_model/svc'
# require 'rumale/pipeline/pipeline'
#
# rbf = Rumale::KernelApproximation::RBF.new(gamma: 1.0, n_components: 128, random_seed: 1)
# svc = Rumale::LinearModel::SVC.new(reg_param: 1.0, fit_bias: true, max_iter: 5000)
# pipeline = Rumale::Pipeline::Pipeline.new(steps: { trs: rbf, est: svc })
# pipeline.fit(training_samples, traininig_labels)
# results = pipeline.predict(testing_samples)
#
# source://rumale-pipeline//lib/rumale/pipeline/pipeline.rb#21
class Rumale::Pipeline::Pipeline < ::Rumale::Base::Estimator
# Create a new pipeline.
#
# @param steps [Hash] List of transformers and estimators. The order of transforms follows the insertion order of hash keys.
# The last entry is considered an estimator.
# @return [Pipeline] a new instance of Pipeline
#
# source://rumale-pipeline//lib/rumale/pipeline/pipeline.rb#30
def initialize(steps:); end
# Call the decision_function method of last estimator after applying all transforms.
#
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The samples to compute the scores.
# @return [Numo::DFloat] (shape: [n_samples]) Confidence score per sample.
#
# source://rumale-pipeline//lib/rumale/pipeline/pipeline.rb#72
def decision_function(x); end
# Fit the model with given training data.
#
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The training data to be transformed and used for fitting the model.
# @param y [Numo::NArray] (shape: [n_samples, n_outputs]) The target values or labels to be used for fitting the model.
# @return [Pipeline] The learned pipeline itself.
#
# source://rumale-pipeline//lib/rumale/pipeline/pipeline.rb#42
def fit(x, y); end
# Call the fit_predict method of last estimator after applying all transforms.
#
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The training data to be transformed and used for fitting the model.
# @param y [Numo::NArray] (shape: [n_samples, n_outputs], default: nil) The target values or labels to be used for fitting the model.
# @return [Numo::NArray] The predicted results by last estimator.
#
# source://rumale-pipeline//lib/rumale/pipeline/pipeline.rb#53
def fit_predict(x, y = T.unsafe(nil)); end
# Call the fit_transform method of last estimator after applying all transforms.
#
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The training data to be transformed and used for fitting the model.
# @param y [Numo::NArray] (shape: [n_samples, n_outputs], default: nil) The target values or labels to be used for fitting the model.
# @return [Numo::NArray] The predicted results by last estimator.
#
# source://rumale-pipeline//lib/rumale/pipeline/pipeline.rb#63
def fit_transform(x, y = T.unsafe(nil)); end
# Call the inverse_transform method in reverse order.
#
# @param z [Numo::DFloat] (shape: [n_samples, n_components]) The transformed samples to be restored into original space.
# @return [Numo::DFloat] (shape: [n_samples, n_featuress]) The restored samples.
#
# source://rumale-pipeline//lib/rumale/pipeline/pipeline.rb#117
def inverse_transform(z); end
# Call the predict method of last estimator after applying all transforms.
#
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The samples to obtain prediction result.
# @return [Numo::NArray] The predicted results by last estimator.
#
# source://rumale-pipeline//lib/rumale/pipeline/pipeline.rb#81
def predict(x); end
# Call the predict_log_proba method of last estimator after applying all transforms.
#
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The samples to predict the log-probailities.
# @return [Numo::DFloat] (shape: [n_samples, n_classes]) Predicted log-probability of each class per sample.
#
# source://rumale-pipeline//lib/rumale/pipeline/pipeline.rb#90
def predict_log_proba(x); end
# Call the predict_proba method of last estimator after applying all transforms.
#
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The samples to predict the probailities.
# @return [Numo::DFloat] (shape: [n_samples, n_classes]) Predicted probability of each class per sample.
#
# source://rumale-pipeline//lib/rumale/pipeline/pipeline.rb#99
def predict_proba(x); end
# Call the score method of last estimator after applying all transforms.
#
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) Testing data.
# @param y [Numo::NArray] (shape: [n_samples, n_outputs]) True target values or labels for testing data.
# @return [Float] The score of last estimator
#
# source://rumale-pipeline//lib/rumale/pipeline/pipeline.rb#133
def score(x, y); end
# Return the steps.
#
# @return [Hash]
#
# source://rumale-pipeline//lib/rumale/pipeline/pipeline.rb#24
def steps; end
# Call the transform method of last estimator after applying all transforms.
#
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The samples to be transformed.
# @return [Numo::DFloat] (shape: [n_samples, n_components]) The transformed samples.
#
# source://rumale-pipeline//lib/rumale/pipeline/pipeline.rb#108
def transform(x); end
private
# source://rumale-pipeline//lib/rumale/pipeline/pipeline.rb#158
def apply_transforms(x, y = T.unsafe(nil), fit: T.unsafe(nil)); end
# source://rumale-pipeline//lib/rumale/pipeline/pipeline.rb#170
def last_estimator; end
# source://rumale-pipeline//lib/rumale/pipeline/pipeline.rb#140
def validate_steps(steps); end
end
# source://rumale-pipeline//lib/rumale/pipeline/version.rb#8
Rumale::Pipeline::VERSION = T.let(T.unsafe(nil), String)