aboutsummaryrefslogtreecommitdiff
path: root/test/import_data.py
diff options
context:
space:
mode:
authorGregory Ditzler <gditzler@Gregorys-MacBook-Pro.local>2013-04-01 13:48:34 -0400
committerGregory Ditzler <gditzler@Gregorys-MacBook-Pro.local>2013-04-01 13:48:34 -0400
commitd9d44c48398016d2562a723f0737b691077a57df (patch)
tree5e7fa4d2ffc02db3d90341b0b4b1ebf3c8257253 /test/import_data.py
parent19dff63ce30ae2355eb5413299b62447406f9bb8 (diff)
added more functions to feast
Diffstat (limited to 'test/import_data.py')
-rw-r--r--test/import_data.py58
1 files changed, 0 insertions, 58 deletions
diff --git a/test/import_data.py b/test/import_data.py
deleted file mode 100644
index 158e97d..0000000
--- a/test/import_data.py
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
-##################################################################
-##################################################################
-##################################################################
-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
- import numpy as np
-
- 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
-##################################################################
-##################################################################
-##################################################################
-
-
-
-##################################################################
-##################################################################
-##################################################################
-def uniform_data(n_observations = 1000, n_features = 50, n_relevant = 5):
- import numpy as np
- xmax = 10
- xmin = 0
- data = 1.0*np.random.randint(xmax + 1, size = (n_features, n_observations))
- labels = np.zeros(n_observations)
- delta = n_relevant * (xmax - xmin) / 2.0
-
- for m in range(n_observations):
- zz = 0.0
- for k in range(n_relevant):
- zz += data[k, m]
- if zz > delta:
- labels[m] = 1
- else:
- labels[m] = 2
- data = data.transpose()
-
- return data, labels
-
-##################################################################
-##################################################################
-##################################################################