diff options
-rw-r--r-- | python/demo_feast_wrapper.py | 44 |
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 |