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

159 lines
7.2 KiB
Ruby
Generated

# typed: true
# DO NOT EDIT MANUALLY
# This is an autogenerated file for types exported from the `rumale-nearest_neighbors` gem.
# Please instead update this file by running `bin/tapioca gem rumale-nearest_neighbors`.
# Rumale is a machine learning library in Ruby.
#
# source://rumale-nearest_neighbors//lib/rumale/nearest_neighbors/k_neighbors_classifier.rb#8
module Rumale; end
# This module consists of the classes that implement estimators based on nearest neighbors rule.
#
# source://rumale-nearest_neighbors//lib/rumale/nearest_neighbors/k_neighbors_classifier.rb#10
module Rumale::NearestNeighbors; end
# KNeighborsClassifier is a class that implements the classifier with the k-nearest neighbors rule.
# The current implementation uses the Euclidean distance for finding the neighbors.
#
# @example
# require 'rumale/nearest_neighbors/k_neighbors_classifier'
#
# estimator =
# Rumale::NearestNeighbors::KNeighborsClassifier.new(n_neighbors: 5)
# estimator.fit(training_samples, traininig_labels)
# results = estimator.predict(testing_samples)
#
# source://rumale-nearest_neighbors//lib/rumale/nearest_neighbors/k_neighbors_classifier.rb#22
class Rumale::NearestNeighbors::KNeighborsClassifier < ::Rumale::Base::Estimator
include ::Rumale::Base::Classifier
# Create a new classifier with the nearest neighbor rule.
#
# @param n_neighbors [Integer] The number of neighbors.
# @param metric [String] The metric to calculate the distances.
# If metric is 'euclidean', Euclidean distance is calculated for distance between points.
# If metric is 'precomputed', the fit and predict methods expect to be given a distance matrix.
# @return [KNeighborsClassifier] a new instance of KNeighborsClassifier
#
# source://rumale-nearest_neighbors//lib/rumale/nearest_neighbors/k_neighbors_classifier.rb#44
def initialize(n_neighbors: T.unsafe(nil), metric: T.unsafe(nil)); end
# Return the class labels.
#
# @return [Numo::Int32] (size: n_classes)
#
# source://rumale-nearest_neighbors//lib/rumale/nearest_neighbors/k_neighbors_classifier.rb#36
def classes; end
# Calculate confidence scores for samples.
#
# @param x [Numo::DFloat] (shape: [n_testing_samples, n_features]) The samples to compute the scores.
# If the metric is 'precomputed', x must be a square distance matrix (shape: [n_testing_samples, n_training_samples]).
# @return [Numo::DFloat] (shape: [n_testing_samples, n_classes]) Confidence scores per sample for each class.
#
# source://rumale-nearest_neighbors//lib/rumale/nearest_neighbors/k_neighbors_classifier.rb#77
def decision_function(x); end
# Fit the model with given training data.
#
# @param x [Numo::DFloat] (shape: [n_training_samples, n_features]) The training data to be used for fitting the model.
# If the metric is 'precomputed', x must be a square distance matrix (shape: [n_training_samples, n_training_samples]).
# @param y [Numo::Int32] (shape: [n_training_samples]) The labels to be used for fitting the model.
# @return [KNeighborsClassifier] The learned classifier itself.
#
# source://rumale-nearest_neighbors//lib/rumale/nearest_neighbors/k_neighbors_classifier.rb#58
def fit(x, y); end
# Return the labels of the prototypes
#
# @return [Numo::Int32] (size: n_training_samples)
#
# source://rumale-nearest_neighbors//lib/rumale/nearest_neighbors/k_neighbors_classifier.rb#32
def labels; end
# Predict class labels for samples.
#
# @param x [Numo::DFloat] (shape: [n_testing_samples, n_features]) The samples to predict the labels.
# If the metric is 'precomputed', x must be a square distance matrix (shape: [n_testing_samples, n_training_samples]).
# @return [Numo::Int32] (shape: [n_testing_samples]) Predicted class label per sample.
#
# source://rumale-nearest_neighbors//lib/rumale/nearest_neighbors/k_neighbors_classifier.rb#103
def predict(x); end
# Return the prototypes for the nearest neighbor classifier.
# If the metric is 'precomputed', that returns nil.
#
# @return [Numo::DFloat] (shape: [n_training_samples, n_features])
#
# source://rumale-nearest_neighbors//lib/rumale/nearest_neighbors/k_neighbors_classifier.rb#28
def prototypes; end
end
# KNeighborsRegressor is a class that implements the regressor with the k-nearest neighbors rule.
# The current implementation uses the Euclidean distance for finding the neighbors.
#
# @example
# require 'rumale/nearest_neighbors/k_neighbors_regressor'
#
# estimator =
# Rumale::NearestNeighbors::KNeighborsRegressor.new(n_neighbors: 5)
# estimator.fit(training_samples, traininig_target_values)
# results = estimator.predict(testing_samples)
#
# source://rumale-nearest_neighbors//lib/rumale/nearest_neighbors/k_neighbors_regressor.rb#21
class Rumale::NearestNeighbors::KNeighborsRegressor < ::Rumale::Base::Estimator
include ::Rumale::Base::Regressor
# Create a new regressor with the nearest neighbor rule.
#
# @param n_neighbors [Integer] The number of neighbors.
# @param metric [String] The metric to calculate the distances.
# If metric is 'euclidean', Euclidean distance is calculated for distance between points.
# If metric is 'precomputed', the fit and predict methods expect to be given a distance matrix.
# @return [KNeighborsRegressor] a new instance of KNeighborsRegressor
#
# source://rumale-nearest_neighbors//lib/rumale/nearest_neighbors/k_neighbors_regressor.rb#40
def initialize(n_neighbors: T.unsafe(nil), metric: T.unsafe(nil)); end
# Fit the model with given training data.
#
# @param x [Numo::DFloat] (shape: [n_training_samples, n_features]) The training data to be used for fitting the model.
# If the metric is 'precomputed', x must be a square distance matrix (shape: [n_training_samples, n_training_samples]).
# @param y [Numo::DFloat] (shape: [n_training_samples, n_outputs]) The target values to be used for fitting the model.
# @return [KNeighborsRegressor] The learned regressor itself.
#
# source://rumale-nearest_neighbors//lib/rumale/nearest_neighbors/k_neighbors_regressor.rb#54
def fit(x, y); end
# Predict values for samples.
#
# @param x [Numo::DFloat] (shape: [n_testing_samples, n_features]) The samples to predict the values.
# If the metric is 'precomputed', x must be a square distance matrix (shape: [n_testing_samples, n_training_samples]).
# @return [Numo::DFloat] (shape: [n_testing_samples, n_outputs]) Predicted values per sample.
#
# source://rumale-nearest_neighbors//lib/rumale/nearest_neighbors/k_neighbors_regressor.rb#72
def predict(x); end
# Return the prototypes for the nearest neighbor regressor.
# If the metric is 'precomputed', that returns nil.
# If the algorithm is 'vptree', that returns Rumale::NearestNeighbors::VPTree.
#
# @return [Numo::DFloat] (shape: [n_training_samples, n_features])
#
# source://rumale-nearest_neighbors//lib/rumale/nearest_neighbors/k_neighbors_regressor.rb#28
def prototypes; end
# Return the values of the prototypes
#
# @return [Numo::DFloat] (shape: [n_training_samples, n_outputs])
#
# source://rumale-nearest_neighbors//lib/rumale/nearest_neighbors/k_neighbors_regressor.rb#32
def values; end
end
# source://rumale-nearest_neighbors//lib/rumale/nearest_neighbors/version.rb#8
Rumale::NearestNeighbors::VERSION = T.let(T.unsafe(nil), String)