pub struct GammaTest<'a, T: Float> {
pub intercept: Option<T>,
pub slope: Option<T>,
pub v_ratio: Option<T>,
pub p: usize,
pub output_variance: Option<T>,
pub sigmas: Option<Vec<T>>,
pub deltas: Option<Vec<T>>,
pub inputs: &'a [Vec<T>],
pub outputs: &'a [T],
pub euclidean_distance_table: Vec<Vec<T>>,
pub y_distance_table: Vec<Vec<T>>,
pub near_neighbor_table: Vec<Vec<T>>,
/* private fields */
}
Expand description
GammaTest struct computes Gamma Test for a given (inputs/outputs) dataset in lazy way.
Example :
use gammatest::*;
fn main()
{
// Give the input matrix
let inputs =[
[3.0f32, 4.0, 4.0].to_vec(),
[2.0f32, 1.0, 3.0].to_vec(),
[1.0f32, 0.0, 1.0].to_vec(),
[1.0f32, 1.0, 1.0].to_vec(),
];
// Give the output vector
let output = [54.0f32, 30.0, 3.0, 28.0];
// p is the number of neighbors
let p : usize = 3;
// Build the GammaTest using f32 data type
let mut gt : GammaTest<f32> = GammaTest::new(&inputs, &output, p);
// To use f64 data type
//let mut gt : GammaTest<f64> = GammaTest::new(&inputs, &output, p);
// Call function compute() to compute GammaTest parameters.
gt.compute();
// Check results
assert_eq!(gt.slope, Some(33.54095));
assert_eq!(gt.intercept, Some(20.578278));
}
Fields
intercept: Option<T>
The Gamma parameter (intercept)
slope: Option<T>
The slope value
v_ratio: Option<T>
The V_ratio value
p: usize
The number of neighbors
output_variance: Option<T>
sigmas: Option<Vec<T>>
deltas: Option<Vec<T>>
inputs: &'a [Vec<T>]
outputs: &'a [T]
euclidean_distance_table: Vec<Vec<T>>
y_distance_table: Vec<Vec<T>>
near_neighbor_table: Vec<Vec<T>>
Implementations
sourceimpl<'a, T: Float> GammaTest<'a, T>
impl<'a, T: Float> GammaTest<'a, T>
sourcepub fn new(inputs: &'a [Vec<T>], outputs: &'a [T], p: usize) -> GammaTest<'a, T>
pub fn new(inputs: &'a [Vec<T>], outputs: &'a [T], p: usize) -> GammaTest<'a, T>
Build a new Gammatest object. “p” in number of neighbors. #Panics The code panics if :
- inputs/outputs length is null (i.e., if no elements in the dataset),
- inputs lenght not equals outputs length,
- number of neighbors p is less than 2.
Auto Trait Implementations
impl<'a, T> RefUnwindSafe for GammaTest<'a, T> where
T: RefUnwindSafe,
impl<'a, T> Send for GammaTest<'a, T> where
T: Send + Sync,
impl<'a, T> Sync for GammaTest<'a, T> where
T: Sync,
impl<'a, T> Unpin for GammaTest<'a, T> where
T: Unpin,
impl<'a, T> UnwindSafe for GammaTest<'a, T> where
T: UnwindSafe + RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more