Expand description
Facade crate exposing the main FuzzyRough APIs.
§Examples
Classification pipeline on synthetic data:
use frlearn_api::{default_frnn_pipeline, Metric};
let x_train = frlearn_api::core::Matrix::from_shape_vec(
(6, 2),
vec![0.0, 0.0, 0.2, 0.1, 4.8, 5.0, 5.1, 4.9, 9.9, 10.2, 10.1, 9.8],
)?;
let y_train = vec![0usize, 0, 1, 1, 2, 2];
let x_query = frlearn_api::core::Matrix::from_shape_vec(
(3, 2),
vec![0.1, 0.0, 5.0, 5.0, 10.0, 10.0],
)?;
let pipeline = default_frnn_pipeline(3, Metric::Euclidean);
let model = pipeline.fit(&x_train, &y_train)?;
let labels = model.predict(&x_query)?;
let probabilities = model.predict_proba(&x_query)?;
assert_eq!(labels.len(), x_query.nrows());
assert_eq!(probabilities.nrows(), x_query.nrows());Novelty scoring example:
use frlearn_api::{descriptors::NND, Metric};
let inliers = frlearn_api::core::Matrix::from_shape_vec(
(4, 2),
vec![0.0, 0.1, 0.2, -0.1, -0.1, 0.0, 0.1, 0.2],
)?;
let mixed = frlearn_api::core::Matrix::from_shape_vec(
(4, 2),
vec![0.0, 0.0, 0.3, -0.2, 4.0, 4.2, 5.5, 5.1],
)?;
let descriptor = NND { k: 2, metric: Metric::Euclidean };
let model = descriptor.fit(&inliers)?;
let scores = model.predict_anomaly_scores(&mixed)?;
assert_eq!(scores.len(), mixed.nrows());
assert!(scores.iter().all(|value| value.is_finite()));Re-exports§
pub use frlearn_core as core;pub use frlearn_descriptors as descriptors;pub use frlearn_math as math;pub use frlearn_neighbor as neighbor;pub use frlearn_neighbours as neighbours;pub use frlearn_preprocess as preprocess;