aboutsummaryrefslogtreecommitdiff
path: root/python/demo_feast_wrapper.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/demo_feast_wrapper.py')
-rw-r--r--python/demo_feast_wrapper.py96
1 files changed, 88 insertions, 8 deletions
diff --git a/python/demo_feast_wrapper.py b/python/demo_feast_wrapper.py
index 813c2f5..fd40515 100644
--- a/python/demo_feast_wrapper.py
+++ b/python/demo_feast_wrapper.py
@@ -1,12 +1,21 @@
#!/usr/bin/env python
-import feast
+from feast import *
import numpy as np
import import_data
-print '---> Loading digit data'
+def check_result(selected_features, n_select):
+ selected_features = sorted(selected_features)
+ success = True
+ for k in range(n_select):
+ if k != selected_features[k]:
+ success = False
+ return success
-data_source = 'uniform'
+
+
+
+data_source = 'uniform' # set the data set we want to test
if data_source == 'uniform':
@@ -14,9 +23,6 @@ if data_source == 'uniform':
elif data_source == 'digits':
data, labels = import_data.read_digits('digit.txt')
-print data
-
-
n_observations = len(data) # number of samples in the data set
n_features = len(data.transpose()) # number of features in the data set
n_select = 15 # how many features to select
@@ -28,7 +34,81 @@ print ' :n_observations - ' + str(n_observations)
print ' :n_features - ' + str(n_features)
print ' :n_select - ' + str(n_select)
print ' :algorithm - ' + str(method)
+print ' '
+print '---> Running unit tests on FEAST 4 Python... '
+
+
+#################################################################
+#################################################################
+print ' Running BetaGamma... '
+sf = BetaGamma(data, labels, n_select, beta=0.5, gamma=0.5)
+if check_result(sf) == True:
+ print ' BetaGamma passed!'
+else:
+ print ' BetaGamma failed!'
+
+
+#################################################################
+#################################################################
+print ' Running CMIM... '
+sf = CMIM(data, labels, n_select)
+if check_result(sf) == True:
+ print ' CMIM passed!'
+else:
+ print ' CMIM failed!'
+
+
+#################################################################
+#################################################################
+print ' Running CondMI... '
+sf = CondMI(data, labels, n_select)
+if check_result(sf) == True:
+ print ' CondMI passed!'
+else:
+ print ' CondMI failed!'
+
+
+#################################################################
+#################################################################
+print ' Running DISR... '
+sf = DISR(data, labels, n_select)
+if check_result(sf) == True:
+ print ' DISR passed!'
+else:
+ print ' DISR failed!'
+
+
+#################################################################
+#################################################################
+print ' Running ICAP... '
+sf = ICAP(data, labels, n_select)
+if check_result(sf) == True:
+ print ' ICAP passed!'
+else:
+ print ' ICAP failed!'
+
+
+#################################################################
+#################################################################
+print ' Running JMI... '
+sf = JMI(data, labels, n_select)
+if check_result(sf) == True:
+ print ' JMI passed!'
+else:
+ print ' JMI failed!'
+
+
+#################################################################
+#################################################################
+print ' Running mRMR... '
+sf = mRMR(data, labels, n_select)
+if check_result(sf) == True:
+ print ' mRMR passed!'
+else:
+ print ' mRMR failed!'
+
+print '---> Done unit tests!'
+
+
-selected_features = feast.JMI(data, labels, n_select)
-print selected_features