/// Load the Boston dataset.
///
/// NOTE: we don't really care about preserving the original data;
/// in fact, the labels in the original data have floating point
/// values, but we convert them into `Label`.
/// This dataset only serves for benchmark purposes.
Load the Boston dataset.
NOTE: we don't really care about preserving the original data;
in fact, the labels in the original data have floating point
values, but we convert them into `Label`.
This dataset only serves for benchmark purposes.
Load the Boston dataset . NOTE : we don ' t really care about preserving the original data ; in fact the labels in the original data have floating point values but we convert them into ` Label ` . This dataset only serves for benchmark purposes .
fn load_boston() -> (Array2<f64>, Array1<Label>, Array2<f64>, Array1<Label>) {
    let n = 506;
    let n_train = 406;
    let d = 13;
    let (data, target) = boston::load_data();
    let train_y = Array::from(
        target
            .data()
            .iter()
            .take(n_train)
            .map(|y| *y as Label)
            .collect::<Vec<_>>(),
    );
    let test_y = Array::from(
        target
            .data()
            .iter()
            .skip(n_train)
            .map(|y| *y as Label)
            .collect::<Vec<_>>(),
    );
    let train_x = Array::from_shape_vec(
        (n_train, d),
        data.data()
            .iter()
            .take(n_train * d)
            .map(|x| *x as f64)
            .collect(),
    )
    .unwrap();
    let test_x = Array::from_shape_vec(
        (n - n_train, d),
        data.data()
            .iter()
            .skip(n_train * d)
            .map(|x| *x as f64)
            .collect(),
    )
    .unwrap();
    (train_x, train_y, test_x, test_y)
}
fn load_boston ( ) -> ( Array2 < f64 > , Array1 < Label > , Array2 < f64 > , Array1 < Label > ) { let n = 506 ; let n_train = 406 ; let d = 13 ; let ( data , target ) = boston :: load_data ( ) ; let train_y = Array :: from ( target . data ( ) . iter ( ) . take ( n_train ) . map ( | y | * y as Label ) . collect :: < Vec < _ > > ( ) , ) ; let test_y = Array :: from ( target . data ( ) . iter ( ) . skip ( n_train ) . map ( | y | * y as Label ) . collect :: < Vec < _ > > ( ) , ) ; let train_x = Array :: from_shape_vec ( ( n_train , d ) , data . data ( ) . iter ( ) . take ( n_train * d ) . map ( | x | * x as f64 ) . collect ( ) , ) . unwrap ( ) ; let test_x = Array :: from_shape_vec ( ( n - n_train , d ) , data . data ( ) . iter ( ) . skip ( n_train * d ) . map ( | x | * x as f64 ) . collect ( ) , ) . unwrap ( ) ; ( train_x , train_y , test_x , test_y ) }
Load the Boston dataset.
Load the Boston dataset .