Struct linfa::dataset::DatasetBase

source ·
pub struct DatasetBase<R, T>
where R: Records,
{ pub records: R, pub targets: T, pub weights: Array1<f32>, /* private fields */ }
Expand description

DatasetBase

This is the fundamental structure of a dataset. It contains a number of records about the data and may contain targets, weights and feature names. In order to keep the type complexity low the dataset base is only generic over the records and targets and introduces a trait bound on the records. weights and feature_names, on the other hand, are always assumed to be owned and copied when views are created.

§Fields

  • records: a two-dimensional matrix with dimensionality (nsamples, nfeatures), in case of kernel methods a quadratic matrix with dimensionality (nsamples, nsamples), which may be sparse
  • targets: a two-/one-dimension matrix with dimensionality (nsamples, ntargets)
  • weights: optional weights for each sample with dimensionality (nsamples)
  • feature_names: optional descriptive feature names with dimensionality (nfeatures)

§Trait bounds

  • R: Records: generic over feature matrices or kernel matrices
  • T: generic over any ndarray matrix which can be used as targets. The AsTargets trait bound is omitted here to avoid some repetition in implementation src/dataset/impl_dataset.rs

Fields§

§records: R§targets: T§weights: Array1<f32>

Implementations§

source§

impl<F: Float, D: Data<Elem = F>, T> DatasetBase<ArrayBase<D, Ix2>, T>

source

pub fn pearson_correlation(&self) -> PearsonCorrelation<F>

Calculate the Pearson Correlation Coefficients from a dataset

The PCC describes the linear correlation between two variables. It is the covariance divided by the product of the standard deviations, therefore essentially a normalised measurement of the covariance and in range (-1, 1). A negative coefficient indicates a negative correlation between both variables.

§Example
let corr = linfa_datasets::diabetes()
    .pearson_correlation();

println!("{}", corr);
source

pub fn pearson_correlation_with_p_value( &self, num_iter: usize ) -> PearsonCorrelation<F>

Calculate the Pearson Correlation Coefficients and p-values from the dataset

The PCC describes the linear correlation between two variables. It is the covariance divided by the product of the standard deviations, therefore essentially a normalised measurement of the covariance and in range (-1, 1). A negative coefficient indicates a negative correlation between both variables.

The p-value supports or reject the null hypthesis that two variables are not correlated. The smaller the p-value the stronger is the evidence that two variables are correlated. A typical threshold is p < 0.05.

§Parameters
  • num_iter: number of iterations of the permutation test to estimate the p-value
§Example
let corr = linfa_datasets::diabetes()
    .pearson_correlation_with_p_value(100);

println!("{}", corr);
source§

impl<R: Records, S> DatasetBase<R, S>

Implementation without constraints on records and targets

This implementation block provides methods for the creation and mutation of datasets. This includes swapping the targets, return the records etc.

source

pub fn new(records: R, targets: S) -> DatasetBase<R, S>

Create a new dataset from records and targets

§Example
let dataset = Dataset::new(records, targets);
source

pub fn targets(&self) -> &S

Returns reference to targets

source

pub fn weights(&self) -> Option<&[f32]>

Returns optionally weights

source

pub fn weight_for(&self, idx: usize) -> f32

Return a single weight

The weight of the idxth observation is returned. If no weight is specified, then all observations are unweighted with default value 1.0.

source

pub fn feature_names(&self) -> Vec<String>

Returns feature names

A feature name gives a human-readable string describing the purpose of a single feature. This allow the reader to understand its purpose while analysing results, for example correlation analysis or feature importance.

source

pub fn records(&self) -> &R

Return records of a dataset

The records are data points from which predictions are made. This functions returns a reference to the record field.

source

pub fn with_records<T: Records>(self, records: T) -> DatasetBase<T, S>

Updates the records of a dataset

This function overwrites the records in a dataset. It also invalidates the weights and feature names.

source

pub fn with_targets<T>(self, targets: T) -> DatasetBase<R, T>

Updates the targets of a dataset

This function overwrites the targets in a dataset.

source

pub fn with_weights(self, weights: Array1<f32>) -> DatasetBase<R, S>

Updates the weights of a dataset

source

pub fn with_feature_names<I: Into<String>>( self, names: Vec<I> ) -> DatasetBase<R, S>

Updates the feature names of a dataset

source§

impl<X, Y> DatasetBase<ArrayBase<OwnedRepr<X>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<Y>, Dim<[usize; 2]>>>

source

pub fn into_single_target(self) -> Dataset<X, Y, Ix1>

source§

impl<L, R: Records, T: AsTargets<Elem = L>> DatasetBase<R, T>

source

pub fn map_targets<S, G: FnMut(&L) -> S>( self, fnc: G ) -> DatasetBase<R, Array<S, T::Ix>>

Map targets with a function f

§Example
let dataset = linfa_datasets::winequality()
    .map_targets(|x| *x > 6);

// dataset has now boolean targets
println!("{:?}", dataset.targets());
§Returns

A modified dataset with new target type.

source

pub fn ntargets(&self) -> usize

Return the number of targets in the dataset

§Example
let dataset = linfa_datasets::winequality();

println!("#targets {}", dataset.ntargets());
source§

impl<'a, F, L, D, T> DatasetBase<ArrayBase<D, Ix2>, T>
where D: Data<Elem = F>, T: AsTargets<Elem = L>,

source

pub fn sample_iter(&'a self) -> Iter<'a, '_, F, T::Elem, T::Ix>

Iterate over observations

This function creates an iterator which produces tuples of data points and target value. The iterator runs once for each data point and, while doing so, holds an reference to the owned dataset.

For multi-target datasets, the yielded target value is ArrayView1 consisting of the different targets. For single-target datasets, the target value is ArrayView0 containing the single target.

§Example
let dataset = linfa_datasets::iris();

for (x, y) in dataset.sample_iter() {
    println!("{} => {}", x, y);
}
source§

impl<'a, F: 'a, L: 'a, D, T> DatasetBase<ArrayBase<D, Ix2>, T>
where D: Data<Elem = F>, T: AsTargets<Elem = L> + FromTargetArray<'a>,

source

pub fn view(&'a self) -> DatasetBase<ArrayView2<'a, F>, T::View>

Creates a view of a dataset

source

pub fn feature_iter(&'a self) -> DatasetIter<'a, '_, ArrayBase<D, Ix2>, T>

Iterate over features

This iterator produces dataset views with only a single feature, while the set of targets remain complete. It can be useful to compare each feature individual to all targets.

source

pub fn target_iter(&'a self) -> DatasetIter<'a, '_, ArrayBase<D, Ix2>, T>

Iterate over targets

This functions creates an iterator which produces dataset views complete records, but only a single target each. Useful to train multiple single target models for a multi-target dataset.

source§

impl<'a, L: 'a, F, T> DatasetBase<ArrayView2<'a, F>, T>
where T: AsTargets<Elem = L> + FromTargetArray<'a>,

source

pub fn split_with_ratio( &'a self, ratio: f32 ) -> (DatasetBase<ArrayView2<'a, F>, T::View>, DatasetBase<ArrayView2<'a, F>, T::View>)

Split dataset into two disjoint chunks

This function splits the observations in a dataset into two disjoint chunks. The splitting threshold is calculated with the ratio. For example a ratio of 0.9 allocates 90% to the first chunks and 9% to the second. This is often used in training, validation splitting procedures.

source§

impl<'a, 'b: 'a, F, L: Label, T, D> DatasetBase<ArrayBase<D, Ix2>, T>
where D: Data<Elem = F>, T: AsSingleTargets<Elem = L> + Labels<Elem = L>,

source

pub fn one_vs_all( &self ) -> Result<Vec<(L, DatasetBase<ArrayView2<'_, F>, CountedTargets<bool, Array1<bool>>>)>>

Produce N boolean targets from multi-class targets

Some algorithms (like SVM) don’t support multi-class targets. This function splits a dataset into multiple binary single-target views of the same dataset.

source§

impl<L: Label, R: Records, S: AsTargets<Elem = L>> DatasetBase<R, S>

source

pub fn label_frequencies_with_mask(&self, mask: &[bool]) -> HashMap<L, f32>

Calculates label frequencies from a dataset while masking certain samples.

§Parameters
  • mask: a boolean array that specifies which samples to include in the count
§Returns

A mapping of the Dataset’s samples to their frequencies

source

pub fn label_frequencies(&self) -> HashMap<L, f32>

Calculates label frequencies from a dataset

source§

impl<'b, F: Clone, E: Copy + 'b, D, T> DatasetBase<ArrayBase<D, Ix2>, T>
where D: Data<Elem = F>, T: FromTargetArray<'b, Elem = E>, T::Owned: AsTargets,

source

pub fn bootstrap<R: Rng>( &'b self, sample_feature_size: (usize, usize), rng: &'b mut R ) -> impl Iterator<Item = DatasetBase<Array2<F>, <T as FromTargetArray<'b>>::Owned>> + 'b

Apply bootstrapping for samples and features

Bootstrap aggregating is used for sub-sample generation and improves the accuracy and stability of machine learning algorithms. It samples data uniformly with replacement and generates datasets where elements may be shared. This selects a subset of observations as well as features.

§Parameters
  • sample_feature_size: The number of samples and features per bootstrap
  • rng: The random number generator used in the sampling procedure
§Returns

An infinite Iterator yielding at each step a new bootstrapped dataset

source

pub fn bootstrap_samples<R: Rng>( &'b self, num_samples: usize, rng: &'b mut R ) -> impl Iterator<Item = DatasetBase<Array2<F>, <T as FromTargetArray<'b>>::Owned>> + 'b

Apply sample bootstrapping

Bootstrap aggregating is used for sub-sample generation and improves the accuracy and stability of machine learning algorithms. It samples data uniformly with replacement and generates datasets where elements may be shared. Only a sample subset is selected which retains all features and targets.

§Parameters
  • num_samples: The number of samples per bootstrap
  • rng: The random number generator used in the sampling procedure
§Returns

An infinite Iterator yielding at each step a new bootstrapped dataset

source

pub fn bootstrap_features<R: Rng>( &'b self, num_features: usize, rng: &'b mut R ) -> impl Iterator<Item = DatasetBase<Array2<F>, <T as FromTargetArray<'b>>::Owned>> + 'b

Apply feature bootstrapping

Bootstrap aggregating is used for sub-sample generation and improves the accuracy and stability of machine learning algorithms. It samples data uniformly with replacement and generates datasets where elements may be shared. Only a feature subset is selected while retaining all samples and targets.

§Parameters
  • num_features: The number of features per bootstrap
  • rng: The random number generator used in the sampling procedure
§Returns

An infinite Iterator yielding at each step a new bootstrapped dataset

source

pub fn shuffle<R: Rng>(&self, rng: &mut R) -> DatasetBase<Array2<F>, T::Owned>

Produces a shuffled version of the current Dataset.

§Parameters
  • rng: the random number generator that will be used to shuffle the samples
§Returns

A new shuffled version of the current Dataset

source

pub fn fold( &self, k: usize ) -> Vec<(DatasetBase<Array2<F>, T::Owned>, DatasetBase<Array2<F>, T::Owned>)>

Performs K-folding on the dataset.

The dataset is divided into k “folds”, each containing (dataset size)/k samples, used to generate k training-validation dataset pairs. Each pair contains a validation Dataset with k samples, the ones contained in the i-th fold, and a training Dataset composed by the union of all the samples in the remaining folds.

§Parameters
  • k: the number of folds to apply
§Returns

A vector of k training-validation Dataset pairs.

§Example
use linfa::dataset::DatasetView;
use ndarray::{Ix1, array};

let records = array![[1.,1.], [2.,1.], [3.,2.], [4.,1.],[5., 3.], [6.,2.]];
let targets = array![1, 1, 0, 1, 0, 0];

let dataset : DatasetView<f64, usize, Ix1> = (records.view(), targets.view()).into();
let accuracies = dataset.fold(3).into_iter().map(|(train, valid)| {
    // Here you can train your model and perform validation
     
    // let model = params.fit(&dataset);
    // let predi = model.predict(&valid);
    // predi.confusion_matrix(&valid).accuracy()  
});
source

pub fn sample_chunks<'a: 'b>( &'b self, chunk_size: usize ) -> ChunksIter<'b, 'a, F, T>

source

pub fn to_owned(&self) -> DatasetBase<Array2<F>, T::Owned>

source§

impl<'a, F: 'a + Clone, E: Copy + 'a, D, S, I: TargetDim> DatasetBase<ArrayBase<D, Ix2>, ArrayBase<S, I>>
where D: DataMut<Elem = F>, S: DataMut<Elem = E>,

source

pub fn iter_fold<O, C: Fn(&DatasetView<'_, F, E, I>) -> O>( &'a mut self, k: usize, fit_closure: C ) -> impl Iterator<Item = (O, DatasetBase<ArrayView2<'_, F>, ArrayView<'_, E, I>>)>

Performs k-folding cross validation on fittable algorithms.

Given a dataset as input, a value of k and the desired params for the fittable algorithm, returns an iterator over the k trained models and the associated validation set.

The models are trained according to a closure specified as an input.

§Parameters
  • k: the number of folds to apply to the dataset
  • params: the desired parameters for the fittable algorithm at hand
  • fit_closure: a closure of the type (params, training_data) -> fitted_model that will be used to produce the trained model for each fold. The training data given in input won’t outlive the closure.
§Returns

An iterator over couples (trained_model, validation_set).

§Panics

This method will panic for any of the following three reasons:

  • The value of k provided is not positive;
  • The value of k provided is greater than the total number of samples in the dataset;
  • The dataset’s data is not stored contiguously and in standard order;
§Example
use linfa::traits::Fit;
use linfa::dataset::{Dataset, DatasetView, Records};
use ndarray::{array, ArrayView1, ArrayView2, Ix1};
use linfa::Error;

struct MockFittable {}

struct MockFittableResult {
   mock_var: usize,
}

impl<'a> Fit<ArrayView2<'a,f64>, ArrayView1<'a, f64>, linfa::error::Error> for MockFittable {
    type Object = MockFittableResult;

    fn fit(&self, training_data: &DatasetView<f64, f64, Ix1>) -> Result<Self::Object, linfa::error::Error> {
        Ok(MockFittableResult {
            mock_var: training_data.nsamples(),
        })
    }
}

let records = array![[1.,1.], [2.,2.], [3.,3.], [4.,4.], [5.,5.]];
let targets = array![1.,2.,3.,4.,5.];
let mut dataset: Dataset<f64, f64, Ix1> = (records, targets).into();
let params = MockFittable {};

for (model,validation_set) in dataset.iter_fold(5, |v| params.fit(v).unwrap()){
    // Here you can use `model` and `validation_set` to
    // assert the performance of the chosen algorithm
}
source

pub fn cross_validate<O, ER, M, FACC, C>( &'a mut self, k: usize, parameters: &[M], eval: C ) -> Result<Array<FACC, I>, ER>
where ER: Error + From<Error>, M: for<'c> Fit<ArrayView2<'c, F>, ArrayView<'c, E, I>, ER, Object = O>, O: for<'d> PredictInplace<ArrayView2<'a, F>, Array<E, I>>, FACC: Float, C: Fn(&Array<E, I>, &ArrayView<'_, E, I>) -> Result<Array<FACC, I::Smaller>, Error>,

Cross validation for single and multi-target algorithms

Given a list of fittable models, cross validation is used to compare their performance according to some performance metric. To do so, k-folding is applied to the dataset and, for each fold, each model is trained on the training set and its performance is evaluated on the validation set. The performances collected for each model are then averaged over the number of folds.

For single-target datasets, Dataset::cross_validate_single is recommended.

§Parameters:
  • k: the number of folds to apply
  • parameters: a list of models to compare
  • eval: closure used to evaluate the performance of each trained model. This closure is called on the model output and validation targets of each fold and outputs the performance score for each target. For single-target dataset the signature is (Array1, Array1) -> Array0. For multi-target dataset the signature is (Array2, Array2) -> Array1.
§Returns

An array of model performances, for each model and each target, if no errors occur. For multi-target dataset, the array has dimensions (n_models, n_targets). For single-target dataset, the array has dimensions (n_models). Otherwise, it might return an Error in one of the following cases:

  • An error occurred during the fitting of one model
  • An error occurred inside the evaluation closure
§Example

use linfa::prelude::*;
use ndarray::arr0;






// mutability needed for fast cross validation
let mut dataset = linfa_datasets::diabetes();

let models = vec![model1, model2];

let r2_scores = dataset.cross_validate(5, &models, |prediction, truth| prediction.r2(truth).map(arr0))?;
source§

impl<'a, F: 'a + Clone, E: Copy + 'a, D, S> DatasetBase<ArrayBase<D, Ix2>, ArrayBase<S, Ix1>>
where D: DataMut<Elem = F>, S: DataMut<Elem = E>,

source

pub fn cross_validate_single<O, ER, M, FACC, C>( &'a mut self, k: usize, parameters: &[M], eval: C ) -> Result<Array1<FACC>, ER>
where ER: Error + From<Error>, M: for<'c> Fit<ArrayView2<'c, F>, ArrayView1<'c, E>, ER, Object = O>, O: for<'d> PredictInplace<ArrayView2<'a, F>, Array1<E>>, FACC: Float, C: Fn(&Array1<E>, &ArrayView1<'_, E>) -> Result<FACC, Error>,

Specialized version of cross_validate for single-target datasets. Allows the evaluation closure to return a float without wrapping it in arr0. See [Dataset.cross_validate] for more details.

source§

impl<F, E, I: TargetDim> DatasetBase<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<E>, I>>

source

pub fn split_with_ratio(self, ratio: f32) -> (Self, Self)

Split dataset into two disjoint chunks

This function splits the observations in a dataset into two disjoint chunks. The splitting threshold is calculated with the ratio. If the input Dataset contains n samples then the two new Datasets will have respectively n * ratio and n - (n*ratio) samples. For example a ratio of 0.9 allocates 90% to the first chunks and 10% to the second. This is often used in training, validation splitting procedures.

§Parameters
  • ratio: the ratio of samples in the input Dataset to include in the first output one
§Returns

The input Dataset split into two according to the input ratio.

§Panics

Panic occurs when the input record or targets are not in row-major layout.

source§

impl<F: Copy, L: Copy + Label, D, T> DatasetBase<ArrayBase<D, Ix2>, T>
where D: Data<Elem = F>, T: AsTargets<Elem = L>,

source

pub fn with_labels( &self, labels: &[L] ) -> DatasetBase<Array2<F>, CountedTargets<L, Array<L, T::Ix>>>

Transforms the input dataset by keeping only those samples whose label appears in labels.

In the multi-target case a sample is kept if any of its targets appears in labels.

Sample weights and feature names are preserved by this transformation.

Trait Implementations§

source§

impl<L, R: Records, T: AsTargets<Elem = L>> AsTargets for DatasetBase<R, T>

§

type Elem = L

§

type Ix = <T as AsTargets>::Ix

source§

fn as_targets(&self) -> ArrayView<'_, Self::Elem, Self::Ix>

source§

impl<L, R: Records, T: AsTargetsMut<Elem = L>> AsTargetsMut for DatasetBase<R, T>

§

type Elem = L

§

type Ix = <T as AsTargetsMut>::Ix

source§

fn as_targets_mut(&mut self) -> ArrayViewMut<'_, Self::Elem, Self::Ix>

source§

impl<R: Records, R2: Records, T: AsSingleTargets<Elem = bool>, T2: AsSingleTargets<Elem = Pr>> BinaryClassification<&DatasetBase<R, T>> for DatasetBase<R2, T2>

source§

fn log_loss(&self, y: &DatasetBase<R, T>) -> Result<f32>

Log loss of the probabilities of the binary target

source§

fn roc(&self, y: &DatasetBase<R, T>) -> Result<ReceiverOperatingCharacteristic>

source§

impl<R, T: Clone> Clone for DatasetBase<R, T>
where R: Records + Clone,

source§

fn clone(&self) -> DatasetBase<R, T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<R, T: Debug> Debug for DatasetBase<R, T>
where R: Records + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<F, E, D, S, I: TargetDim> From<(ArrayBase<D, Dim<[usize; 2]>>, ArrayBase<S, I>)> for DatasetBase<ArrayBase<D, Ix2>, ArrayBase<S, I>>
where D: Data<Elem = F>, S: Data<Elem = E>,

source§

fn from(rec_tar: (ArrayBase<D, Ix2>, ArrayBase<S, I>)) -> Self

Converts to this type from the input type.
source§

impl<F, D: Data<Elem = F>, I: Dimension> From<ArrayBase<D, I>> for DatasetBase<ArrayBase<D, I>, Array1<()>>

source§

fn from(records: ArrayBase<D, I>) -> Self

Converts to this type from the input type.
source§

impl<L: Label, T: Labels<Elem = L>, R: Records> Labels for DatasetBase<R, T>

§

type Elem = L

source§

fn label_count(&self) -> Vec<HashMap<L, usize>>

source§

fn label_set(&self) -> Vec<HashSet<Self::Elem>>

source§

fn labels(&self) -> Vec<Self::Elem>

source§

impl<F: Float, T: AsMultiTargets<Elem = F>, T2: AsMultiTargets<Elem = F>, D: Data<Elem = F>> MultiTargetRegression<F, T2> for DatasetBase<ArrayBase<D, Ix2>, T>

source§

fn max_error(&self, other: &T) -> Result<Array1<F>>

Maximal error between two continuous variables
source§

fn mean_absolute_error(&self, other: &T) -> Result<Array1<F>>

Mean error between two continuous variables
source§

fn mean_squared_error(&self, other: &T) -> Result<Array1<F>>

Mean squared error between two continuous variables
source§

fn mean_squared_log_error(&self, other: &T) -> Result<Array1<F>>

Mean squared log error between two continuous variables
source§

fn median_absolute_error(&self, other: &T) -> Result<Array1<F>>

Median absolute error between two continuous variables
source§

fn mean_absolute_percentage_error(&self, other: &T) -> Result<Array1<F>>

Mean absolute percentage error between two continuous variables MAPE = 1/N * SUM(abs((y_hat - y) / y))
source§

fn r2(&self, other: &T) -> Result<Array1<F>>

R squared coefficient, is the proportion of the variance in the dependent variable that is predictable from the independent variable
source§

fn explained_variance(&self, other: &T) -> Result<Array1<F>>

Same as R-Squared but with biased variance
source§

impl<R, T: PartialEq> PartialEq for DatasetBase<R, T>
where R: Records + PartialEq,

source§

fn eq(&self, other: &DatasetBase<R, T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<F, D: Records<Elem = F>, T> Records for DatasetBase<D, T>

Implement records for a DatasetBase

§

type Elem = F

source§

fn nsamples(&self) -> usize

source§

fn nfeatures(&self) -> usize

source§

impl<'a, F: Float, L: 'a + Label, D: Data<Elem = F>, T: AsSingleTargets<Elem = L> + Labels<Elem = L>> SilhouetteScore<F> for DatasetBase<ArrayBase<D, Ix2>, T>

source§

fn silhouette_score(&self) -> Result<F>

Evaluates the quality of a clustering. Read more
source§

impl<F: Float, T: AsSingleTargets<Elem = F>, T2: AsSingleTargets<Elem = F>, D: Data<Elem = F>> SingleTargetRegression<F, T2> for DatasetBase<ArrayBase<D, Ix2>, T>

source§

fn max_error(&self, compare_to: &T) -> Result<F>

Maximal error between two continuous variables
source§

fn mean_absolute_error(&self, compare_to: &T) -> Result<F>

Mean error between two continuous variables
source§

fn mean_squared_error(&self, compare_to: &T) -> Result<F>

Mean squared error between two continuous variables
source§

fn mean_squared_log_error(&self, compare_to: &T) -> Result<F>

Mean squared log error between two continuous variables
source§

fn median_absolute_error(&self, compare_to: &T) -> Result<F>

Median absolute error between two continuous variables
source§

fn mean_absolute_percentage_error(&self, compare_to: &T) -> Result<F>

Mean absolute percentage error between two continuous variables MAPE = 1/N * SUM(abs((y_hat - y) / y))
source§

fn r2(&self, compare_to: &T) -> Result<F>

R squared coefficient, is the proportion of the variance in the dependent variable that is predictable from the independent variable
source§

fn explained_variance(&self, compare_to: &T) -> Result<F>

Same as R-Squared but with biased variance
source§

impl<L: Label, S: Data<Elem = L>, T: AsSingleTargets<Elem = L> + Labels<Elem = L>, R: Records> ToConfusionMatrix<L, &DatasetBase<R, T>> for ArrayBase<S, Ix1>

source§

fn confusion_matrix( &self, ground_truth: &DatasetBase<R, T> ) -> Result<ConfusionMatrix<L>>

source§

impl<L: Label, R, R2, T, T2> ToConfusionMatrix<L, &DatasetBase<R, T>> for DatasetBase<R2, T2>
where R: Records, R2: Records, T: AsSingleTargets<Elem = L>, T2: AsSingleTargets<Elem = L> + Labels<Elem = L>,

source§

fn confusion_matrix( &self, ground_truth: &DatasetBase<R, T> ) -> Result<ConfusionMatrix<L>>

source§

impl<R, T> StructuralPartialEq for DatasetBase<R, T>
where R: Records,

Auto Trait Implementations§

§

impl<R, T> RefUnwindSafe for DatasetBase<R, T>

§

impl<R, T> Send for DatasetBase<R, T>
where R: Send, T: Send,

§

impl<R, T> Sync for DatasetBase<R, T>
where R: Sync, T: Sync,

§

impl<R, T> Unpin for DatasetBase<R, T>
where R: Unpin, T: Unpin,

§

impl<R, T> UnwindSafe for DatasetBase<R, T>
where R: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AsMultiTargets for T
where T: AsTargets<Ix = Dim<[usize; 2]>>,

source§

fn as_multi_targets(&self) -> ArrayView2<'_, Self::Elem>

source§

impl<T> AsMultiTargetsMut for T
where T: AsTargetsMut<Ix = Dim<[usize; 2]>>,

source§

fn as_multi_targets_mut(&mut self) -> ArrayViewMut2<'_, Self::Elem>

source§

impl<T> AsSingleTargets for T
where T: AsTargets<Ix = Dim<[usize; 1]>>,

source§

fn as_single_targets(&self) -> ArrayView1<'_, Self::Elem>

source§

impl<T> AsSingleTargetsMut for T
where T: AsTargetsMut<Ix = Dim<[usize; 1]>>,

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<'a, F, R, T, S, O> Predict<&'a DatasetBase<R, T>, S> for O
where R: Records<Elem = F>, O: PredictInplace<R, S>,

source§

fn predict(&self, ds: &'a DatasetBase<R, T>) -> S

source§

impl<F, D, E, T, O> Predict<ArrayBase<D, Dim<[usize; 2]>>, DatasetBase<ArrayBase<D, Dim<[usize; 2]>>, T>> for O
where D: Data<Elem = F>, T: AsTargets<Elem = E>, O: PredictInplace<ArrayBase<D, Dim<[usize; 2]>>, T>,

source§

fn predict( &self, records: ArrayBase<D, Dim<[usize; 2]>> ) -> DatasetBase<ArrayBase<D, Dim<[usize; 2]>>, T>

source§

impl<F, R, T, E, S, O> Predict<DatasetBase<R, T>, DatasetBase<R, S>> for O
where R: Records<Elem = F>, S: AsTargets<Elem = E>, O: PredictInplace<R, S>,

source§

fn predict(&self, ds: DatasetBase<R, T>) -> DatasetBase<R, S>

§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

unsafe fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<L, S, T> ToConfusionMatrix<L, &ArrayBase<S, Dim<[usize; 1]>>> for T
where L: Label, S: Data<Elem = L>, T: AsSingleTargets<Elem = L> + Labels<Elem = L>,

source§

fn confusion_matrix( &self, ground_truth: &ArrayBase<S, Dim<[usize; 1]>> ) -> Result<ConfusionMatrix<L>, Error>

source§

impl<L, S, T> ToConfusionMatrix<L, ArrayBase<S, Dim<[usize; 1]>>> for T
where L: Label, S: Data<Elem = L>, T: AsSingleTargets<Elem = L> + Labels<Elem = L>,

source§

fn confusion_matrix( &self, ground_truth: ArrayBase<S, Dim<[usize; 1]>> ) -> Result<ConfusionMatrix<L>, Error>

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V