pub struct RandomProjectionFeatures { /* private fields */ }Expand description
Random Projection Feature Extractor
Performs dimensionality reduction using random projections while preserving approximate distances between data points (Johnson-Lindenstrauss lemma). Useful for high-dimensional data preprocessing and approximate similarity search.
§Parameters
n_components- Number of dimensions in the projected spacerandom_state- Random seed for reproducibilitydensity- Density of random projection matrix (for sparse projections)eps- Distortion parameter for auto-sizing components
§Examples
use sklears_feature_extraction::streaming_projection::RandomProjectionFeatures;
use scirs2_core::ndarray::Array2;
let X = Array2::from_elem((100, 1000), 1.0);
let mut rp = RandomProjectionFeatures::new()
.n_components(50)
.random_state(42);
let X_projected = rp.fit_transform(&X.view())?;
assert_eq!(X_projected.ncols(), 50);Implementations§
Source§impl RandomProjectionFeatures
impl RandomProjectionFeatures
Sourcepub fn n_components(self, n_components: usize) -> Self
pub fn n_components(self, n_components: usize) -> Self
Set number of components in projected space
Sourcepub fn random_state(self, random_state: u64) -> Self
pub fn random_state(self, random_state: u64) -> Self
Set random state for reproducibility
Sourcepub fn fit(&mut self, X: &ArrayView2<'_, Float>) -> SklResult<()>
pub fn fit(&mut self, X: &ArrayView2<'_, Float>) -> SklResult<()>
Fit the random projection to data
Sourcepub fn transform(&self, X: &ArrayView2<'_, Float>) -> SklResult<Array2<Float>>
pub fn transform(&self, X: &ArrayView2<'_, Float>) -> SklResult<Array2<Float>>
Transform data using fitted random projection
Sourcepub fn fit_transform(
&mut self,
X: &ArrayView2<'_, Float>,
) -> SklResult<Array2<Float>>
pub fn fit_transform( &mut self, X: &ArrayView2<'_, Float>, ) -> SklResult<Array2<Float>>
Fit and transform data in one step
Trait Implementations§
Source§impl Clone for RandomProjectionFeatures
impl Clone for RandomProjectionFeatures
Source§impl Debug for RandomProjectionFeatures
impl Debug for RandomProjectionFeatures
Auto Trait Implementations§
impl Freeze for RandomProjectionFeatures
impl RefUnwindSafe for RandomProjectionFeatures
impl Send for RandomProjectionFeatures
impl Sync for RandomProjectionFeatures
impl Unpin for RandomProjectionFeatures
impl UnsafeUnpin for RandomProjectionFeatures
impl UnwindSafe for RandomProjectionFeatures
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
Converts
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> ⓘ
Converts
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