[][src]Struct scholar::Dataset

pub struct Dataset { /* fields omitted */ }

A collection of input vectors matched with their expected output.

You can construct a Dataset manually like so:

// Note that the inputs and target outputs are both vectors, even though the latter has just
// one element
let data = vec![
    (vec![0.0, 0.0], vec![0.0]),
    (vec![0.0, 1.0], vec![1.0]),
    (vec![1.0, 0.0], vec![1.0]),
    (vec![1.0, 1.0], vec![0.0]),
];

let dataset = scholar::Dataset::from(data);

Implementations

impl Dataset[src]

pub fn from_csv(
    file_path: impl AsRef<Path>,
    includes_headers: bool,
    num_inputs: usize
) -> Result<Self, ParseCsvError>
[src]

Parses a Dataset from a CSV file.

Arguments

  • file_path - The path to the CSV file
  • includes_headers - Whether the CSV has a header row or not
  • num_inputs - The number of columns in the CSV that are designated as inputs (to a Machine Learning model)

Examples

// Parses the first four columns of 'iris.csv' as inputs, and the remaining columns as
// target outputs
let dataset = scholar::Dataset::from_csv("iris.csv", false, 4);

pub fn split(self, train_portion: f64) -> (Self, Self)[src]

Splits the dataset into two, with the size of each determined by the given train_portion. This is useful for separating it into training and testing segments.

Examples

let dataset = scholar::Dataset::from_csv("iris.csv", false, 4)?;

// Randomly allocates 75% of the original dataset to `training_data`, and the rest
// to `testing_data`
let (training_data, testing_data) = dataset.split(0.75);

Panics

This method panics if the given train_portion isn't between 0 and 1.

pub fn rows(&self) -> usize[src]

Returns the number of rows in the dataset.

Examples

// Data for the XOR problem
let data = vec![
    (vec![0.0, 0.0], vec![0.0]),
    (vec![0.0, 1.0], vec![1.0]),
    (vec![1.0, 0.0], vec![1.0]),
    (vec![1.0, 1.0], vec![0.0]),
];

let dataset = scholar::Dataset::from(data);
assert_eq!(dataset.rows(), 4);

Trait Implementations

impl Debug for Dataset[src]

impl From<Vec<(Vec<f64>, Vec<f64>)>> for Dataset[src]

impl<'a> IntoIterator for &'a Dataset[src]

type Item = &'a (Vec<f64>, Vec<f64>)

The type of the elements being iterated over.

type IntoIter = DatasetIterator<'a>

Which kind of iterator are we turning this into?

Auto Trait Implementations

impl RefUnwindSafe for Dataset

impl Send for Dataset

impl Sync for Dataset

impl Unpin for Dataset

impl UnwindSafe for Dataset

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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