pub struct StreamingGraphLearning<S = Untrained> { /* private fields */ }Expand description
Streaming Graph Learning for Dynamic Semi-Supervised Learning
This method continuously updates graph structures as new data points arrive, making it suitable for dynamic environments where the data distribution may change over time. It maintains a sliding window of recent data points and efficiently updates the graph structure and label propagation.
§Parameters
window_size- Size of the sliding window for maintaining recent datalambda_sparse- Sparsity regularization parameter for graph learningalpha_decay- Decay factor for edge weights over timeupdate_frequency- Frequency of full graph reconstructionforgetting_factor- Factor for exponential forgetting of old connectionsadaptive_threshold- Whether to use adaptive thresholds for edge additionmin_samples_update- Minimum samples required before updating the graph
§Examples
use scirs2_core::array;
use sklears_semi_supervised::StreamingGraphLearning;
use sklears_core::traits::{Predict, Fit};
let X = array![[1.0, 2.0], [2.0, 3.0], [3.0, 4.0], [4.0, 5.0]];
let y = array![0, 1, -1, -1]; // -1 indicates unlabeled
let mut sgl = StreamingGraphLearning::new()
.window_size(100)
.lambda_sparse(0.1)
.alpha_decay(0.95);
let mut fitted = sgl.fit(&X.view(), &y.view()).unwrap();
let predictions = fitted.predict(&X.view()).unwrap();
// Update with new data
let X_new = array![[5.0, 6.0], [6.0, 7.0]];
let y_new = array![-1, 0];
let updated = fitted.update(&X_new.view(), &y_new.view()).unwrap();Implementations§
Source§impl StreamingGraphLearning<Untrained>
impl StreamingGraphLearning<Untrained>
Sourcepub fn window_size(self, window_size: usize) -> Self
pub fn window_size(self, window_size: usize) -> Self
Set the sliding window size
Sourcepub fn lambda_sparse(self, lambda_sparse: f64) -> Self
pub fn lambda_sparse(self, lambda_sparse: f64) -> Self
Set the sparsity regularization parameter
Sourcepub fn alpha_decay(self, alpha_decay: f64) -> Self
pub fn alpha_decay(self, alpha_decay: f64) -> Self
Set the decay factor for edge weights
Sourcepub fn update_frequency(self, frequency: usize) -> Self
pub fn update_frequency(self, frequency: usize) -> Self
Set the frequency of full graph reconstruction
Sourcepub fn forgetting_factor(self, factor: f64) -> Self
pub fn forgetting_factor(self, factor: f64) -> Self
Set the forgetting factor for old connections
Sourcepub fn adaptive_threshold(self, adaptive: bool) -> Self
pub fn adaptive_threshold(self, adaptive: bool) -> Self
Enable/disable adaptive threshold for edge addition
Sourcepub fn min_samples_update(self, min_samples: usize) -> Self
pub fn min_samples_update(self, min_samples: usize) -> Self
Set minimum samples required before updating the graph
Sourcepub fn k_neighbors(self, k: usize) -> Self
pub fn k_neighbors(self, k: usize) -> Self
Set the number of nearest neighbors to consider
Sourcepub fn similarity_threshold(self, threshold: f64) -> Self
pub fn similarity_threshold(self, threshold: f64) -> Self
Set the similarity threshold for edge creation
Source§impl StreamingGraphLearning<StreamingGraphLearningTrained>
impl StreamingGraphLearning<StreamingGraphLearningTrained>
Sourcepub fn update(
&mut self,
X_new: &ArrayView2<'_, Float>,
y_new: &ArrayView1<'_, i32>,
) -> SklResult<()>
pub fn update( &mut self, X_new: &ArrayView2<'_, Float>, y_new: &ArrayView1<'_, i32>, ) -> SklResult<()>
Update the model with new streaming data
Trait Implementations§
Source§impl<S: Clone> Clone for StreamingGraphLearning<S>
impl<S: Clone> Clone for StreamingGraphLearning<S>
Source§fn clone(&self) -> StreamingGraphLearning<S>
fn clone(&self) -> StreamingGraphLearning<S>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<S: Debug> Debug for StreamingGraphLearning<S>
impl<S: Debug> Debug for StreamingGraphLearning<S>
Source§impl Default for StreamingGraphLearning<Untrained>
impl Default for StreamingGraphLearning<Untrained>
Source§impl Estimator for StreamingGraphLearning<Untrained>
impl Estimator for StreamingGraphLearning<Untrained>
Source§type Error = SklearsError
type Error = SklearsError
Source§fn validate_config(&self) -> Result<(), SklearsError>
fn validate_config(&self) -> Result<(), SklearsError>
Source§fn check_compatibility(
&self,
n_samples: usize,
n_features: usize,
) -> Result<(), SklearsError>
fn check_compatibility( &self, n_samples: usize, n_features: usize, ) -> Result<(), SklearsError>
Source§fn metadata(&self) -> EstimatorMetadata
fn metadata(&self) -> EstimatorMetadata
Source§impl Fit<ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>, ArrayBase<ViewRepr<&i32>, Dim<[usize; 1]>>> for StreamingGraphLearning<Untrained>
impl Fit<ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>, ArrayBase<ViewRepr<&i32>, Dim<[usize; 1]>>> for StreamingGraphLearning<Untrained>
Source§type Fitted = StreamingGraphLearning<StreamingGraphLearningTrained>
type Fitted = StreamingGraphLearning<StreamingGraphLearningTrained>
Source§fn fit(
self,
X: &ArrayView2<'_, Float>,
y: &ArrayView1<'_, i32>,
) -> SklResult<Self::Fitted>
fn fit( self, X: &ArrayView2<'_, Float>, y: &ArrayView1<'_, i32>, ) -> SklResult<Self::Fitted>
Source§fn fit_with_validation(
self,
x: &X,
y: &Y,
_x_val: Option<&X>,
_y_val: Option<&Y>,
) -> Result<(Self::Fitted, FitMetrics), SklearsError>where
Self: Sized,
fn fit_with_validation(
self,
x: &X,
y: &Y,
_x_val: Option<&X>,
_y_val: Option<&Y>,
) -> Result<(Self::Fitted, FitMetrics), SklearsError>where
Self: Sized,
Source§impl Predict<ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<i32>, Dim<[usize; 1]>>> for StreamingGraphLearning<StreamingGraphLearningTrained>
impl Predict<ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<i32>, Dim<[usize; 1]>>> for StreamingGraphLearning<StreamingGraphLearningTrained>
Source§fn predict(&self, X: &ArrayView2<'_, Float>) -> SklResult<Array1<i32>>
fn predict(&self, X: &ArrayView2<'_, Float>) -> SklResult<Array1<i32>>
Source§fn predict_with_uncertainty(
&self,
x: &X,
) -> Result<(Output, UncertaintyMeasure), SklearsError>
fn predict_with_uncertainty( &self, x: &X, ) -> Result<(Output, UncertaintyMeasure), SklearsError>
Source§impl PredictProba<ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>> for StreamingGraphLearning<StreamingGraphLearningTrained>
impl PredictProba<ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>> for StreamingGraphLearning<StreamingGraphLearningTrained>
Source§fn predict_proba(&self, X: &ArrayView2<'_, Float>) -> SklResult<Array2<f64>>
fn predict_proba(&self, X: &ArrayView2<'_, Float>) -> SklResult<Array2<f64>>
Auto Trait Implementations§
impl<S> Freeze for StreamingGraphLearning<S>where
S: Freeze,
impl<S> RefUnwindSafe for StreamingGraphLearning<S>where
S: RefUnwindSafe,
impl<S> Send for StreamingGraphLearning<S>where
S: Send,
impl<S> Sync for StreamingGraphLearning<S>where
S: Sync,
impl<S> Unpin for StreamingGraphLearning<S>where
S: Unpin,
impl<S> UnwindSafe for StreamingGraphLearning<S>where
S: UnwindSafe,
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> 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