175 lines
6.7 KiB
Ruby
Generated
175 lines
6.7 KiB
Ruby
Generated
# typed: true
|
|
|
|
# DO NOT EDIT MANUALLY
|
|
# This is an autogenerated file for types exported from the `rumale-kernel_approximation` gem.
|
|
# Please instead update this file by running `bin/tapioca gem rumale-kernel_approximation`.
|
|
|
|
|
|
# Rumale is a machine learning library in Ruby.
|
|
#
|
|
# source://rumale-kernel_approximation//lib/rumale/kernel_approximation/nystroem.rb#8
|
|
module Rumale; end
|
|
|
|
# Module for kernel approximation algorithms.
|
|
#
|
|
# source://rumale-kernel_approximation//lib/rumale/kernel_approximation/nystroem.rb#9
|
|
module Rumale::KernelApproximation; end
|
|
|
|
# Nystroem is a class that implements feature mapping with Nystroem method.
|
|
#
|
|
# *Reference*
|
|
# - Yang, T., Li, Y., Mahdavi, M., Jin, R., and Zhou, Z-H., "Nystrom Method vs Random Fourier Features: A Theoretical and Empirical Comparison," Advances in NIPS'12, Vol. 1, pp. 476--484, 2012.
|
|
#
|
|
# @example
|
|
# require 'numo/linalg/autoloader'
|
|
# require 'rumale/kernel_approximation/nystroem'
|
|
#
|
|
# transformer = Rumale::KernelApproximation::Nystroem.new(kernel: 'rbf', gamma: 1, n_components: 128, random_seed: 1)
|
|
# new_training_samples = transformer.fit_transform(training_samples)
|
|
# new_testing_samples = transformer.transform(testing_samples)
|
|
#
|
|
# source://rumale-kernel_approximation//lib/rumale/kernel_approximation/nystroem.rb#22
|
|
class Rumale::KernelApproximation::Nystroem < ::Rumale::Base::Estimator
|
|
include ::Rumale::Base::Transformer
|
|
|
|
# Create a new transformer for mapping to kernel feature space with Nystrom method.
|
|
#
|
|
# @param kernel [String] The type of kernel function ('rbf', 'linear', 'poly', and 'sigmoid)
|
|
# @param gamma [Float] The gamma parameter in rbf/poly/sigmoid kernel function.
|
|
# @param degree [Integer] The degree parameter in polynomial kernel function.
|
|
# @param coef [Float] The coefficient in poly/sigmoid kernel function.
|
|
# @param n_components [Integer] The number of dimensions of the kernel feature space.
|
|
# @param random_seed [Integer] The seed value using to initialize the random generator.
|
|
# @return [Nystroem] a new instance of Nystroem
|
|
#
|
|
# source://rumale-kernel_approximation//lib/rumale/kernel_approximation/nystroem.rb#49
|
|
def initialize(kernel: T.unsafe(nil), gamma: T.unsafe(nil), degree: T.unsafe(nil), coef: T.unsafe(nil), n_components: T.unsafe(nil), random_seed: T.unsafe(nil)); end
|
|
|
|
# Returns the indices sampled training data.
|
|
#
|
|
# @return [Numo::Int32] (shape: [n_components])
|
|
#
|
|
# source://rumale-kernel_approximation//lib/rumale/kernel_approximation/nystroem.rb#31
|
|
def component_indices; end
|
|
|
|
# Returns the randomly sampled training data for feature mapping.
|
|
#
|
|
# @return [Numo::DFloat] (shape: n_components, n_features])
|
|
#
|
|
# source://rumale-kernel_approximation//lib/rumale/kernel_approximation/nystroem.rb#27
|
|
def components; end
|
|
|
|
# Fit the model with given training data.
|
|
#
|
|
# @overload fit
|
|
#
|
|
# source://rumale-kernel_approximation//lib/rumale/kernel_approximation/nystroem.rb#67
|
|
def fit(x, _y = T.unsafe(nil)); end
|
|
|
|
# Fit the model with training data, and then transform them with the learned model.
|
|
#
|
|
# @overload fit_transform
|
|
#
|
|
# source://rumale-kernel_approximation//lib/rumale/kernel_approximation/nystroem.rb#95
|
|
def fit_transform(x, _y = T.unsafe(nil)); end
|
|
|
|
# Returns the normalizing factors.
|
|
#
|
|
# @return [Numo::DFloat] (shape: [n_components, n_components])
|
|
#
|
|
# source://rumale-kernel_approximation//lib/rumale/kernel_approximation/nystroem.rb#35
|
|
def normalizer; end
|
|
|
|
# Return the random generator for transformation.
|
|
#
|
|
# @return [Random]
|
|
#
|
|
# source://rumale-kernel_approximation//lib/rumale/kernel_approximation/nystroem.rb#39
|
|
def rng; 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 model.
|
|
# @return [Numo::DFloat] (shape: [n_samples, n_components]) The transformed data.
|
|
#
|
|
# source://rumale-kernel_approximation//lib/rumale/kernel_approximation/nystroem.rb#105
|
|
def transform(x); end
|
|
|
|
private
|
|
|
|
# source://rumale-kernel_approximation//lib/rumale/kernel_approximation/nystroem.rb#114
|
|
def kernel_mat(x, y = T.unsafe(nil)); end
|
|
end
|
|
|
|
# Class for RBF kernel feature mapping.
|
|
#
|
|
# *Refernce*:
|
|
# - Rahimi, A., and Recht, B., "Random Features for Large-Scale Kernel Machines," Proc. NIPS'07, pp.1177--1184, 2007.
|
|
#
|
|
# @example
|
|
# require 'rumale/kernel_approximation/rbf'
|
|
#
|
|
# transformer = Rumale::KernelApproximation::RBF.new(gamma: 1.0, n_components: 128, random_seed: 1)
|
|
# new_training_samples = transformer.fit_transform(training_samples)
|
|
# new_testing_samples = transformer.transform(testing_samples)
|
|
#
|
|
# source://rumale-kernel_approximation//lib/rumale/kernel_approximation/rbf.rb#21
|
|
class Rumale::KernelApproximation::RBF < ::Rumale::Base::Estimator
|
|
include ::Rumale::Base::Transformer
|
|
|
|
# Create a new transformer for mapping to RBF kernel feature space.
|
|
#
|
|
# @param gamma [Float] The parameter of RBF kernel: exp(-gamma * x^2).
|
|
# @param n_components [Integer] The number of dimensions of the RBF kernel feature space.
|
|
# @param random_seed [Integer] The seed value using to initialize the random generator.
|
|
# @return [RBF] a new instance of RBF
|
|
#
|
|
# source://rumale-kernel_approximation//lib/rumale/kernel_approximation/rbf.rb#41
|
|
def initialize(gamma: T.unsafe(nil), n_components: T.unsafe(nil), random_seed: T.unsafe(nil)); end
|
|
|
|
# Fit the model with given training data.
|
|
#
|
|
# @overload fit
|
|
#
|
|
# source://rumale-kernel_approximation//lib/rumale/kernel_approximation/rbf.rb#57
|
|
def fit(x, _y = T.unsafe(nil)); end
|
|
|
|
# Fit the model with training data, and then transform them with the learned model.
|
|
#
|
|
# @overload fit_transform
|
|
#
|
|
# source://rumale-kernel_approximation//lib/rumale/kernel_approximation/rbf.rb#76
|
|
def fit_transform(x, _y = T.unsafe(nil)); end
|
|
|
|
# Return the random matrix for transformation.
|
|
#
|
|
# @return [Numo::DFloat] (shape: [n_features, n_components])
|
|
#
|
|
# source://rumale-kernel_approximation//lib/rumale/kernel_approximation/rbf.rb#26
|
|
def random_mat; end
|
|
|
|
# Return the random vector for transformation.
|
|
#
|
|
# @return [Numo::DFloat] (shape: [n_components])
|
|
#
|
|
# source://rumale-kernel_approximation//lib/rumale/kernel_approximation/rbf.rb#30
|
|
def random_vec; end
|
|
|
|
# Return the random generator for transformation.
|
|
#
|
|
# @return [Random]
|
|
#
|
|
# source://rumale-kernel_approximation//lib/rumale/kernel_approximation/rbf.rb#34
|
|
def rng; end
|
|
|
|
# Transform the given data with the learned model.
|
|
#
|
|
# @overload transform
|
|
#
|
|
# source://rumale-kernel_approximation//lib/rumale/kernel_approximation/rbf.rb#87
|
|
def transform(x); end
|
|
end
|
|
|
|
# source://rumale-kernel_approximation//lib/rumale/kernel_approximation/version.rb#8
|
|
Rumale::KernelApproximation::VERSION = T.let(T.unsafe(nil), String)
|