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.py37
1 files changed, 11 insertions, 26 deletions
diff --git a/python/demo_feast_wrapper.py b/python/demo_feast_wrapper.py
index 6642ca8..4c965e3 100644
--- a/python/demo_feast_wrapper.py
+++ b/python/demo_feast_wrapper.py
@@ -1,36 +1,21 @@
#!/usr/bin/env python
import feast
import numpy as np
+import import_data
-##################################################################
-##################################################################
-##################################################################
-def read_digits(fname='digit.txt'):
- '''
- read_digits(fname='digit.txt')
-
- 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_source = 'uniform'
+
+
+if data_source == 'uniform':
+ data, labels = import_data.uniform_data()
+elif data_source == 'digits':
+ data, labels = import_data.read_digits('digit.txt')
-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