pub struct Dataset<X = ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, Y = ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>> {
pub data: X,
pub target: Y,
pub feature_names: Vec<String>,
pub target_names: Option<Vec<String>>,
pub description: String,
}Expand description
A simple dataset structure for machine learning operations
The Dataset struct is the primary data container for sklears, holding feature matrices and target values along with metadata.
§Type Parameters
X: Type of the feature matrix (defaults toArray2``) Y: Type of the target values (defaults toArray1``)
§Examples
use sklears_core::dataset::Dataset;
use scirs2_core::ndarray::{Array1, Array2};
let features = Array2::`<f64>`::zeros((100, 4));
let targets = Array1::`<f64>`::zeros(100);
let dataset = Dataset::new(features, targets)
.with_description("Sample dataset".to_string());Fields§
§data: XFeature matrix (n_samples x n_features)
target: YTarget values (n_samples,)
feature_names: Vec<String>Feature names for interpretability
target_names: Option<Vec<String>>Target names (for classification tasks)
description: StringDataset description for documentation
Implementations§
Source§impl<X, Y> Dataset<X, Y>
impl<X, Y> Dataset<X, Y>
Sourcepub fn new(data: X, target: Y) -> Dataset<X, Y>
pub fn new(data: X, target: Y) -> Dataset<X, Y>
Create a new dataset with the given data and target
This is the primary constructor for creating datasets. Additional metadata can be added using builder methods.
§Arguments
data- Feature matrix or data structuretarget- Target values corresponding to the features
§Returns
A new Dataset instance with empty metadata
Sourcepub fn builder() -> DatasetBuilder<X, Y, NoData, NoTarget>
pub fn builder() -> DatasetBuilder<X, Y, NoData, NoTarget>
Create a builder for constructing a dataset with compile-time validation
The builder pattern provides compile-time guarantees that both data and targets are provided before the dataset can be constructed.
§Returns
A DatasetBuilder in its initial state
Sourcepub fn with_feature_names(self, names: Vec<String>) -> Dataset<X, Y>
pub fn with_feature_names(self, names: Vec<String>) -> Dataset<X, Y>
Sourcepub fn with_target_names(self, names: Vec<String>) -> Dataset<X, Y>
pub fn with_target_names(self, names: Vec<String>) -> Dataset<X, Y>
Sourcepub fn with_description(self, description: String) -> Dataset<X, Y>
pub fn with_description(self, description: String) -> Dataset<X, Y>
Sourcepub fn n_samples(&self) -> Option<usize>where
X: HasShape,
pub fn n_samples(&self) -> Option<usize>where
X: HasShape,
Get the number of samples in the dataset
This is a convenience method that should be implemented by types that can determine their sample count.
Sourcepub fn n_features(&self) -> Option<usize>where
X: HasShape,
pub fn n_features(&self) -> Option<usize>where
X: HasShape,
Get the number of features in the dataset
This is a convenience method that should be implemented by types that can determine their feature count.
Trait Implementations§
Auto Trait Implementations§
impl<X, Y> Freeze for Dataset<X, Y>
impl<X, Y> RefUnwindSafe for Dataset<X, Y>where
X: RefUnwindSafe,
Y: RefUnwindSafe,
impl<X, Y> Send for Dataset<X, Y>
impl<X, Y> Sync for Dataset<X, Y>
impl<X, Y> Unpin for Dataset<X, Y>
impl<X, Y> UnwindSafe for Dataset<X, Y>where
X: UnwindSafe,
Y: 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