Beispiel #1
0
 def test_max_freq_filter(self):
     X = np.array([[1.0, 0.0, 0.0], 
                   [0.0, 0.0, 0.0], 
                   [1.0, 9.0, 0.0], 
                   [1.0, 9.0, 0.0], 
                   [1.0, 9.0, 0.0], 
                   [0.0, 0.0, 0.0]])   
     max_freq = 0.5
     filt = MaxFreqFilter(max_freq=max_freq)
     Xt = filt.fit_transform(X)
     # expected X
     Xe = X[:,1:]
     assert_array_equal(Xt, Xe)
Beispiel #2
0
 def test_max_freq_filter_sparse(self):
     X = sp.csr_matrix([[1.0, 0.0, 0.0], 
                        [0.0, 0.0, 0.0], 
                        [1.0, 9.0, 0.0], 
                        [1.0, 9.0, 0.0], 
                        [1.0, 9.0, 0.0], 
                        [0.0, 0.0, 0.0]])        
     filt = MaxFreqFilter(max_freq=0.5)
     Xt = filt.fit_transform(X)
     # expected X
     Xe = X[:,1:]
     assert Xt.shape == (6,2)
     # __eq__ is not properly implemented for sparse matrices
     # so apply this trick
     assert (Xt - Xe).nnz == 0