pub struct Dataset {
pub features: Array2<f64>,
pub targets: Array2<f64>,
pub feature_names: Option<Vec<String>>,
pub target_names: Option<Vec<String>>,
}Expand description
Dataset container for training data.
Fields§
§features: Array2<f64>Feature matrix (samples x features).
targets: Array2<f64>Target vector or matrix.
feature_names: Option<Vec<String>>Feature names (if available).
target_names: Option<Vec<String>>Target names (if available).
Implementations§
Source§impl Dataset
impl Dataset
Sourcepub fn with_feature_names(self, names: Vec<String>) -> Self
pub fn with_feature_names(self, names: Vec<String>) -> Self
Set feature names.
Sourcepub fn with_target_names(self, names: Vec<String>) -> Self
pub fn with_target_names(self, names: Vec<String>) -> Self
Set target names.
Sourcepub fn num_samples(&self) -> usize
pub fn num_samples(&self) -> usize
Get number of samples.
Sourcepub fn num_features(&self) -> usize
pub fn num_features(&self) -> usize
Get number of features.
Sourcepub fn num_targets(&self) -> usize
pub fn num_targets(&self) -> usize
Get number of targets.
Sourcepub fn shuffle(&mut self, seed: u64)
pub fn shuffle(&mut self, seed: u64)
Shuffle the dataset in place using Fisher-Yates algorithm.
Sourcepub fn train_test_split(
&self,
train_ratio: f64,
) -> TrainResult<(Dataset, Dataset)>
pub fn train_test_split( &self, train_ratio: f64, ) -> TrainResult<(Dataset, Dataset)>
Split into train and test sets.
Sourcepub fn train_val_test_split(
&self,
train_ratio: f64,
val_ratio: f64,
) -> TrainResult<(Dataset, Dataset, Dataset)>
pub fn train_val_test_split( &self, train_ratio: f64, val_ratio: f64, ) -> TrainResult<(Dataset, Dataset, Dataset)>
Split into train, validation, and test sets.
Sourcepub fn subset(&self, indices: &[usize]) -> TrainResult<Dataset>
pub fn subset(&self, indices: &[usize]) -> TrainResult<Dataset>
Get a subset of the dataset by indices.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Dataset
impl RefUnwindSafe for Dataset
impl Send for Dataset
impl Sync for Dataset
impl Unpin for Dataset
impl UnwindSafe for Dataset
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
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