@@ -14,7 +14,7 @@ def fisher(data, num_instances: list, top_k_features=2):
14
14
assert len (num_instances ) == 2 , "Fisher selection method can be performed for two-class problems."
15
15
16
16
data = tf .convert_to_tensor (data )
17
- _ , num_features = data .get_shape ().as_list ()
17
+ num_features = data .get_shape ().as_list ()[ - 1 ]
18
18
if top_k_features > num_features :
19
19
top_k_features = num_features
20
20
class1 , class2 = tf .split (data , num_instances )
@@ -35,7 +35,7 @@ def feature_correlation_with_class(data, num_instances: list, top_k_features=10)
35
35
:return: the list of most significant features.
36
36
"""
37
37
data = tf .convert_to_tensor (data )
38
- _ , num_features = data .get_shape ().as_list ()
38
+ num_features = data .get_shape ().as_list ()[ - 1 ]
39
39
if top_k_features > num_features :
40
40
top_k_features = num_features
41
41
class1 , class2 = tf .split (data , num_instances )
@@ -57,7 +57,7 @@ def t_test(data, num_instances: list, top_k_features=10):
57
57
:return: the list of most significant features.
58
58
"""
59
59
data = tf .convert_to_tensor (data )
60
- _ , num_features = data .get_shape ().as_list ()
60
+ num_features = data .get_shape ().as_list ()[ - 1 ]
61
61
if top_k_features > num_features :
62
62
top_k_features = num_features
63
63
class1 , class2 = tf .split (data , num_instances )
@@ -74,16 +74,10 @@ def t_test(data, num_instances: list, top_k_features=10):
74
74
75
75
def random (data , num_instances : list , top_k_features = 10 ):
76
76
data = tf .convert_to_tensor (data )
77
- _ , num_features = data .get_shape ().as_list ()
77
+ num_features = data .get_shape ().as_list ()[ - 1 ]
78
78
if top_k_features > num_features :
79
79
top_k_features = num_features
80
80
class1 , class2 = tf .split (data , num_instances )
81
81
82
82
with tf .name_scope ('random_selection' ):
83
- mean1 , std1 = tf .nn .moments (class1 , axes = 0 )
84
- mean2 , std2 = tf .nn .moments (class2 , axes = 0 )
85
- t_test_coeffs = tf .abs (mean1 - mean2 ) / tf .sqrt (
86
- tf .square (std1 ) / num_instances [0 ] + tf .square (std2 ) / num_instances [1 ])
87
- selected_features = tf .nn .top_k (t_test_coeffs , k = top_k_features )
88
-
89
- return selected_features
83
+ pass
0 commit comments