pub struct Umap { /* private fields */ }Expand description
UMAP configuration.
Holds hyperparameters for the UMAP algorithm. Calling Fit::fit
computes the embedding and returns a FittedUmap.
Implementations§
Source§impl Umap
impl Umap
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new Umap with default parameters.
Defaults: n_components=2, n_neighbors=15, min_dist=0.1,
spread=1.0, learning_rate=1.0, n_epochs=200, metric=Euclidean,
negative_sample_rate=5.
Sourcepub fn with_n_components(self, n: usize) -> Self
pub fn with_n_components(self, n: usize) -> Self
Set the number of embedding dimensions.
Sourcepub fn with_n_neighbors(self, k: usize) -> Self
pub fn with_n_neighbors(self, k: usize) -> Self
Set the number of nearest neighbors.
Sourcepub fn with_min_dist(self, d: f64) -> Self
pub fn with_min_dist(self, d: f64) -> Self
Set the minimum distance in the embedding.
Sourcepub fn with_spread(self, s: f64) -> Self
pub fn with_spread(self, s: f64) -> Self
Set the spread.
Sourcepub fn with_learning_rate(self, lr: f64) -> Self
pub fn with_learning_rate(self, lr: f64) -> Self
Set the learning rate.
Sourcepub fn with_n_epochs(self, n: usize) -> Self
pub fn with_n_epochs(self, n: usize) -> Self
Set the number of SGD epochs.
Sourcepub fn with_metric(self, m: UmapMetric) -> Self
pub fn with_metric(self, m: UmapMetric) -> Self
Set the distance metric.
Sourcepub fn with_negative_sample_rate(self, rate: usize) -> Self
pub fn with_negative_sample_rate(self, rate: usize) -> Self
Set the negative sample rate.
Sourcepub fn with_random_state(self, seed: u64) -> Self
pub fn with_random_state(self, seed: u64) -> Self
Set the random seed.
Sourcepub fn n_components(&self) -> usize
pub fn n_components(&self) -> usize
Return the configured number of components.
Sourcepub fn n_neighbors(&self) -> usize
pub fn n_neighbors(&self) -> usize
Return the configured number of neighbors.
Sourcepub fn learning_rate(&self) -> f64
pub fn learning_rate(&self) -> f64
Return the configured learning rate.
Sourcepub fn metric(&self) -> UmapMetric
pub fn metric(&self) -> UmapMetric
Return the configured metric.
Sourcepub fn negative_sample_rate(&self) -> usize
pub fn negative_sample_rate(&self) -> usize
Return the configured negative sample rate.
Sourcepub fn random_state(&self) -> Option<u64>
pub fn random_state(&self) -> Option<u64>
Return the configured random state, if any.
Trait Implementations§
Source§impl Fit<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ()> for Umap
impl Fit<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ()> for Umap
Source§fn fit(&self, x: &Array2<f64>, _y: &()) -> Result<FittedUmap, FerroError>
fn fit(&self, x: &Array2<f64>, _y: &()) -> Result<FittedUmap, FerroError>
Fit UMAP by computing the fuzzy simplicial set and optimising the low-dimensional embedding via SGD.
§Errors
FerroError::InvalidParameterifn_componentsis zero,n_neighborsis zero or too large,min_distis negative,spreadis non-positive, orlearning_rateis non-positive.FerroError::InsufficientSamplesif there are fewer samples thann_neighbors + 1.
Source§type Fitted = FittedUmap
type Fitted = FittedUmap
fit.Source§type Error = FerroError
type Error = FerroError
fit.Auto Trait Implementations§
impl Freeze for Umap
impl RefUnwindSafe for Umap
impl Send for Umap
impl Sync for Umap
impl Unpin for Umap
impl UnsafeUnpin for Umap
impl UnwindSafe for Umap
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more