#machine-learning #statistical #statistics #feature-selection

gammatest

gammatest crate provides a code to perform Gamma Test for machine learning feature selection

4 releases

0.1.21 Aug 14, 2022
0.1.2 Aug 14, 2022
0.1.1 Aug 14, 2022
0.1.0 Aug 14, 2022

#608 in Machine learning

MIT license

21KB
300 lines

gammatest

Definition

gammatest is a simple rust implementation of the Gamma Test.

Gamma Test [1] is non-parametric test for feature selection frequently used in machine learning.

The gammatest crate is based on the paper [2].

References

[1] Stefánsson, A., Končar, N., & Jones, A. J. (1997). A note on the gamma test. Neural Computing & Applications, 5(3), 131-133.

[2] Kemp, S. E., Wilson, I. D., & Ware, J. A. (2004). A tutorial on the gamma test. International Journal of Simulation: Systems, Science and Technology, 6(1-2), 67-75.

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));
    } 

Current development state

In the current version, gammatest uses the "Brute force approach" to sort k-near neighbors, which is a simple but slow method comparing to some others.

Dependencies

~155KB