aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Ditzler <gditzler@n2-145-87.dhcp.drexel.edu>2013-03-19 15:20:26 -0400
committerGregory Ditzler <gditzler@n2-145-87.dhcp.drexel.edu>2013-03-19 15:20:26 -0400
commit3fe802a182d16760b8dbab0533458d2aaf225221 (patch)
treefcd323658f1be33edb34e5c300d80ca08367a6e1
parent1403fc0e1f6e5cd0ed5cf814c9f5540e220ff441 (diff)
added functionality to demo
-rw-r--r--python/demo_feast_wrapper.py44
1 files changed, 43 insertions, 1 deletions
diff --git a/python/demo_feast_wrapper.py b/python/demo_feast_wrapper.py
index b36c538..0913788 100644
--- a/python/demo_feast_wrapper.py
+++ b/python/demo_feast_wrapper.py
@@ -2,6 +2,48 @@
import numpy as np
+##################################################################
+##################################################################
+##################################################################
+def read_digits(fname='digit.txt'):
+ '''
+ read_digits(fname='digit.txt')
-print 'hello'
+ read a data file that contains the features and class labels.
+ each row of the file is a feature vector with the class
+ label appended.
+ '''
+ import csv
+ fw = csv.reader(open(fname,'rb'), delimiter='\t')
+ data = []
+ for line in fw:
+ data.append( [float(x) for x in line] )
+ data = np.array(data)
+ labels = data[:,len(data.transpose())-1]
+ data = data[:,:len(data.transpose())-1]
+ return data, labels
+##################################################################
+##################################################################
+##################################################################
+
+
+
+print '---> Loading digit data'
+data, labels = read_digits('digit.txt')
+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
+method = 'jmi' # feature selection algorithm
+
+
+print '---> Information'
+print ' :n_observations - ' + str(n_observations)
+print ' :n_features - ' + str(n_features)
+print ' :n_select - ' + str(n_select)
+print ' :algorithm - ' + str(method)
+
+
+# Calvin: feature selection wrapper goes here
+#selected_features = feast(data, labels, n_observations, n_features, n_select, \
+# method) \ No newline at end of file