File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 9
9
10
10
11
11
def test_feature_hasher_dicts ():
12
- h = FeatureHasher ()
12
+ h = FeatureHasher (n_features = 16 )
13
13
assert_equal ("dict" , h .input_type )
14
14
15
15
raw_X = [{"dada" : 42 , "tzara" : 37 }, {"gaga" : 17 }]
16
- X1 = FeatureHasher ().transform (raw_X )
17
- X2 = FeatureHasher ( input_type = "pair" ). transform ( d .iteritems ()
18
- for d in raw_X )
16
+ X1 = FeatureHasher (n_features = 16 ).transform (raw_X )
17
+ gen = ( d .iteritems () for d in raw_X )
18
+ X2 = FeatureHasher ( n_features = 16 , input_type = "pair" ). transform ( gen )
19
19
assert_array_equal (X1 .toarray (), X2 .toarray ())
20
20
21
21
@@ -44,7 +44,7 @@ def test_feature_hasher_strings():
44
44
def test_feature_hasher_pairs ():
45
45
raw_X = (d .iteritems () for d in [{"foo" : 1 , "bar" : 2 },
46
46
{"baz" : 3 , "quux" : 4 , "foo" : - 1 }])
47
- h = FeatureHasher (n_features = 4096 , input_type = "pair" )
47
+ h = FeatureHasher (n_features = 16 , input_type = "pair" )
48
48
x1 , x2 = h .transform (raw_X ).toarray ()
49
49
x1_nz = sorted (np .abs (x1 [x1 != 0 ]))
50
50
x2_nz = sorted (np .abs (x2 [x2 != 0 ]))
You can’t perform that action at this time.
0 commit comments