Crate sklears_neighbors

Crate sklears_neighbors 

Source
Expand description

Neighbor-based algorithms for machine learning

This crate provides k-nearest neighbors (k-NN) and related algorithms for classification, regression, and outlier detection.

§Examples

use sklears_neighbors::KNeighborsClassifier;
use sklears_core::traits::{Fit, Predict};
use scirs2_core::ndarray::{array, Array2};

// Create training data
let X = Array2::from_shape_vec((4, 2), vec![
    1.0, 2.0,
    2.0, 3.0,
    3.0, 1.0,
    4.0, 2.0,
]).unwrap();
let y = array![0, 0, 1, 1];

// Train classifier
let classifier = KNeighborsClassifier::new(3);
let fitted = classifier.fit(&X, &y).unwrap();

// Make predictions
let X_test = Array2::from_shape_vec((2, 2), vec![
    1.5, 2.5,
    3.5, 1.5,
]).unwrap();
let predictions = fitted.predict(&X_test).unwrap();

Re-exports§

pub use abod::AngleBasedOutlierDetection;
pub use adaptive_distance::AdaptiveDensityDistance;
pub use adaptive_distance::CombinationMethod;
pub use adaptive_distance::ContextDependentDistance;
pub use adaptive_distance::EnsembleDistance;
pub use adaptive_distance::OnlineAdaptiveDistance;
pub use advanced_outliers::ConnectivityBasedOutlierFactor;
pub use advanced_outliers::IsolationForest;
pub use advanced_outliers::LocalCorrelationIntegral;
pub use approximate_distance::ApproximateDistance;
pub use batch_processing::BatchConfiguration;
pub use batch_processing::BatchNeighborSearch;
pub use batch_processing::BatchProcessable;
pub use batch_processing::BatchProcessor;
pub use batch_processing::BatchResult;
pub use batch_processing::BatchStatistics;
pub use batch_processing::MemoryMonitor;
pub use bayesian_neighbors::BayesianKNeighborsClassifier;
pub use bayesian_neighbors::BayesianKNeighborsRegressor;
pub use bayesian_neighbors::BayesianPrediction;
pub use bayesian_neighbors::BayesianRegressionPrediction;
pub use bayesian_neighbors::CredibleNeighborSet;
pub use bayesian_neighbors::UncertaintyMethod;
pub use bioinformatics::BioSearchConfig;
pub use bioinformatics::GeneExpressionNeighbors;
pub use bioinformatics::GeneExpressionResult;
pub use bioinformatics::GeneMetadata;
pub use bioinformatics::KmerIndex;
pub use bioinformatics::ProteinMetadata;
pub use bioinformatics::ProteinSearchResult;
pub use bioinformatics::ProteinStructure;
pub use bioinformatics::ProteinStructureSearch;
pub use bioinformatics::ScoringScheme;
pub use bioinformatics::SequenceAligner;
pub use bioinformatics::SequenceAlignment;
pub use bioinformatics::SequenceMetadata;
pub use bioinformatics::SequenceSearchResult;
pub use bioinformatics::SequenceSimilaritySearch;
pub use bioinformatics::SequenceType;
pub use compressed_distance::CompressedDistanceMatrix;
pub use compressed_distance::CompressionMethod;
pub use compressed_distance::CompressionStats;
pub use computer_vision::ColorHistogramExtractor;
pub use computer_vision::DescriptorMatch;
pub use computer_vision::FeatureDescriptorMatcher;
pub use computer_vision::FeatureExtractor;
pub use computer_vision::FeatureType;
pub use computer_vision::HistogramOfGradientsExtractor;
pub use computer_vision::ImageMetadata;
pub use computer_vision::ImageSearchConfig;
pub use computer_vision::ImageSearchResult;
pub use computer_vision::ImageSimilaritySearch;
pub use computer_vision::Keypoint;
pub use computer_vision::LocalBinaryPatternExtractor;
pub use computer_vision::PatchBasedMatching;
pub use computer_vision::VisualWordRecognizer;
pub use cross_validation::CVFoldResult;
pub use cross_validation::CVResults;
pub use cross_validation::CVStrategy;
pub use cross_validation::NeighborCrossValidator;
pub use density_estimation::BandwidthMethod;
pub use density_estimation::DensityBasedClustering;
pub use density_estimation::KNeighborsDensityEstimator;
pub use density_estimation::KernelType;
pub use density_estimation::LocalDensityEstimator;
pub use density_estimation::VariableBandwidthKDE;
pub use distance::Distance;
pub use distributed_neighbors::DataPartitioner;
pub use distributed_neighbors::DistributedConfiguration;
pub use distributed_neighbors::DistributedNeighborSearch;
pub use distributed_neighbors::DistributedNeighborSearchResult;
pub use distributed_neighbors::DistributedWorker;
pub use distributed_neighbors::LoadBalanceStrategy;
pub use distributed_neighbors::PartitionInfo;
pub use distributed_neighbors::PartitionStats;
pub use federated_neighbors::FederatedConfig;
pub use federated_neighbors::FederatedNeighborCoordinator;
pub use federated_neighbors::FederatedParticipant;
pub use federated_neighbors::NoiseStrategy;
pub use federated_neighbors::PrivacyLevel;
pub use federated_neighbors::PrivacyPreservingProtocol;
pub use gpu_distance::GpuBackend;
pub use gpu_distance::GpuComputationStats;
pub use gpu_distance::GpuConfig;
pub use gpu_distance::GpuDeviceInfo;
pub use gpu_distance::GpuDistanceCalculator;
pub use gpu_distance::GpuDistanceResult;
pub use gpu_distance::GpuKNeighborsSearch;
pub use gpu_distance::GpuMemoryEstimator;
pub use gpu_distance::GpuMemoryStrategy;
pub use graph_methods::EpsilonGraph;
pub use graph_methods::GabrielGraph;
pub use graph_methods::GraphEdge;
pub use graph_methods::GraphNeighborSearch;
pub use graph_methods::GraphStatistics;
pub use graph_methods::KNearestNeighborGraph;
pub use graph_methods::MutualKNearestNeighbors;
pub use graph_methods::NeighborhoodGraph;
pub use graph_methods::RelativeNeighborhoodGraph;
pub use incremental_index::IncrementalIndexBuilder;
pub use incremental_index::IncrementalIndexType;
pub use incremental_index::IncrementalNeighborIndex;
pub use incremental_index::IndexPerformanceMetrics;
pub use incremental_index::UpdateStrategy;
pub use interpretability::InfluenceAnalysis;
pub use interpretability::LocalImportanceExplanation;
pub use interpretability::NeighborExplainer;
pub use interpretability::NeighborExplanation;
pub use interpretability::Prototype;
pub use knn::KNeighborsClassifier;
pub use knn::KNeighborsRegressor;
pub use local_outlier_factor::LocalOutlierFactor;
pub use lsh::HashFamily;
pub use lsh::LshIndex;
pub use lsh::LshKNeighborsClassifier;
pub use manifold_learning::Isomap;
pub use manifold_learning::LaplacianEigenmaps;
pub use manifold_learning::LocallyLinearEmbedding;
pub use manifold_learning::TSNENeighbors;
pub use mapreduce_neighbors::DistributedMapReduce;
pub use mapreduce_neighbors::MapReduceConfig;
pub use mapreduce_neighbors::MapReduceNeighborSearch;
pub use mapreduce_neighbors::PartitionStrategy;
pub use mapreduce_neighbors::ReduceStrategy;
pub use memory_constrained::CacheObliviousNeighbors;
pub use memory_constrained::ExternalMemoryKNN;
pub use memory_constrained::MemoryBoundedApproximateNeighbors;
pub use memory_mapped::MmapNeighborIndex;
pub use memory_mapped::MmapNeighborIndexBuilder;
pub use metric_learning::EnhancedLMNN;
pub use metric_learning::InformationTheoreticMetricLearning;
pub use metric_learning::LargeMarginNearestNeighbor;
pub use metric_learning::NeighborhoodComponentsAnalysis;
pub use metric_learning::OnlineMetricLearning;
pub use multi_view_learning::ConsensusAnalysis;
pub use multi_view_learning::FusionStrategy;
pub use multi_view_learning::MultiViewKNeighborsClassifier;
pub use multi_view_learning::MultiViewKNeighborsRegressor;
pub use multi_view_learning::RegressionFusionStrategy;
pub use multi_view_learning::ViewConfig;
pub use nearest_centroid::CentroidType;
pub use nearest_centroid::ClassConfig;
pub use nearest_centroid::NearestCentroid;
pub use nearest_neighbors::kneighbors_graph;
pub use nearest_neighbors::radius_neighbors_graph;
pub use nearest_neighbors::NearestNeighbors;
pub use nlp::DocumentFeatureExtractor;
pub use nlp::DocumentMetadata;
pub use nlp::DocumentSearchResult;
pub use nlp::DocumentSimilaritySearch;
pub use nlp::NlpSearchConfig;
pub use nlp::SentenceSimilaritySearch;
pub use nlp::TextFeatureType;
pub use nlp::TextPreprocessor;
pub use nlp::TfIdfExtractor;
pub use nlp::WordEmbeddingSearch;
pub use online_learning::AdaptiveKNeighborsClassifier;
pub use online_learning::DriftDetectionMethod;
pub use online_learning::DriftDetector;
pub use online_learning::StreamingOutlierDetector;
pub use parallel_tree::ParallelBuildStrategy;
pub use parallel_tree::ParallelTreeBuilder;
pub use parallel_tree::ParallelTreeIndex;
pub use parallel_tree::WorkUnit;
pub use performance::BenchmarkConfig;
pub use performance::BenchmarkResult;
pub use performance::NeighborBenchmark;
pub use performance::PerformanceMetrics;
pub use performance::QuickProfiler;
pub use radius_neighbors::AdaptiveRadiusNeighborsClassifier;
pub use radius_neighbors::AdaptiveRadiusNeighborsRegressor;
pub use radius_neighbors::RadiusNeighborsClassifier;
pub use radius_neighbors::RadiusNeighborsRegressor;
pub use radius_neighbors::RadiusStrategy;
pub use simd_distance::batch_euclidean_distances;
pub use simd_distance::pairwise_distances_simd;
pub use simd_distance::SimdCapability;
pub use simd_distance::SimdDistanceCalculator;
pub use sparse_neighbors::SparseIndexType;
pub use sparse_neighbors::SparseNeighborBuilder;
pub use sparse_neighbors::SparseNeighborMatrix;
pub use spatial::OctPoint;
pub use spatial::OctTree;
pub use spatial::QuadPoint;
pub use spatial::QuadTree;
pub use spatial::RTree;
pub use spatial::Rectangle;
pub use spatial::SpatialHash;
pub use spatial::SpatialHashStats;
pub use specialized_distances::CategoricalDistance;
pub use specialized_distances::GraphDistance;
pub use specialized_distances::ProbabilisticDistance;
pub use specialized_distances::SetDistance;
pub use specialized_distances::SimpleGraph;
pub use specialized_distances::StringDistance;
pub use streaming::IncrementalKNeighborsClassifier;
pub use streaming::IncrementalKNeighborsRegressor;
pub use streaming::MemoryStrategy;
pub use time_series_neighbors::DtwDistance;
pub use time_series_neighbors::DtwStepPattern;
pub use time_series_neighbors::Shapelet;
pub use time_series_neighbors::ShapeletDiscovery;
pub use time_series_neighbors::StreamingTimeSeriesNeighbors;
pub use time_series_neighbors::SubsequenceSearch;
pub use time_series_neighbors::TemporalNeighborSearch;
pub use transformers::KNeighborsTransformer;
pub use transformers::RadiusNeighborsTransformer;
pub use type_safe_distance::ChebyshevMetric;
pub use type_safe_distance::ComputeDistance;
pub use type_safe_distance::CosineMetric;
pub use type_safe_distance::EuclideanMetric;
pub use type_safe_distance::ManhattanMetric;
pub use type_safe_distance::MetricDistance;
pub use type_safe_distance::MinkowskiMetric;
pub use type_safe_distance::NonMetricDistance;
pub use type_safe_distance::NormalizedDistance;
pub use type_safe_distance::TypeSafeDistance;
pub use type_safe_distance::TypeSafeKnnConfig;
pub use validation::BootstrapResult;
pub use validation::BootstrapValidator;
pub use validation::ClassificationMetric;
pub use validation::CrossValidationResult;
pub use validation::GridSearchCV;
pub use validation::GridSearchResult;
pub use validation::KFoldValidator;
pub use validation::RegressionMetric;

Modules§

abod
Angle-Based Outlier Detection (ABOD)
adaptive_distance
Adaptive distance metrics that adjust based on data characteristics
advanced_outliers
Advanced outlier detection algorithms
approximate_distance
Approximate distance computations for faster neighbor search
batch_processing
bayesian_neighbors
Bayesian Nearest Neighbors with Uncertainty Quantification
bioinformatics
Bioinformatics Neighbor-Based Methods
compressed_distance
Compressed distance matrices for memory-efficient neighbor storage
computer_vision
Computer Vision Neighbor-Based Methods
cross_validation
Advanced cross-validation techniques for neighbor-based algorithms
density_estimation
Density estimation algorithms using nearest neighbors
distance
Distance metrics for neighbor-based algorithms
distributed_neighbors
federated_neighbors
Federated neighbor computation for privacy-preserving machine learning
gpu_distance
GPU-accelerated distance computations for high-performance neighbor search
graph_methods
Graph-based neighbor methods for machine learning
incremental_index
Incremental index construction for dynamic neighbor search
interpretability
Interpretability and explainability tools for neighbor-based algorithms
knn
K-Nearest Neighbors algorithms for classification and regression
local_outlier_factor
Local Outlier Factor for anomaly detection
lsh
Locality-Sensitive Hashing (LSH) for approximate nearest neighbor search
manifold_learning
Manifold learning algorithms for dimensionality reduction using neighbor-based methods
mapreduce_neighbors
MapReduce-style neighbor search for distributed computing
memory_constrained
Memory-constrained algorithms for neighbor search with limited memory
memory_mapped
Memory-mapped neighbor indices for large datasets
metric_learning
Metric learning algorithms for adaptive distance computation
multi_view_learning
Multi-View Learning for Neighbor-Based Methods
nearest_centroid
Nearest Centroid Classifier
nearest_neighbors
Unsupervised Nearest Neighbors learner
nlp
Natural Language Processing Neighbor-Based Methods
online_learning
Online Learning with Concept Drift Detection
parallel_tree
Parallel tree construction for neighbor search indices
performance
Performance analysis and benchmarking tools for neighbor algorithms
radius_neighbors
Radius-based neighbor algorithms for classification and regression
simd_distance
sparse_neighbors
Sparse neighbor representations for memory-efficient storage
spatial
Spatial data structures for efficient nearest neighbor search
specialized_distances
Specialized distance metrics for various data types
streaming
Incremental and streaming nearest neighbor algorithms
time_series_neighbors
Time series neighbor search methods
transformers
Neighbor-based transformers for building graphs and embeddings
tree
Tree-based data structures for efficient neighbor search
type_safe_distance
Type-safe distance metrics using phantom types
validation
Validation Framework for Neighbor-Based Methods

Enums§

NeighborsError
Common error type for neighbors algorithms

Type Aliases§

NeighborsResult
Type alias for neighbors results