aboutsummaryrefslogtreecommitdiff
path: root/python/import_data.py
diff options
context:
space:
mode:
authorCalvin <calvin@EESI>2013-03-26 13:44:35 -0400
committerCalvin <calvin@EESI>2013-03-26 13:44:35 -0400
commiteac04614526d7d619822bbabf46543053e5e7200 (patch)
tree5e4be62de68126cb9569b03ece6666ff391ea417 /python/import_data.py
parent94da049a53423a9aca04d8376b75347ca7eadcbe (diff)
renamed a bunch of stuff
Diffstat (limited to 'python/import_data.py')
-rw-r--r--python/import_data.py58
1 files changed, 0 insertions, 58 deletions
diff --git a/python/import_data.py b/python/import_data.py
deleted file mode 100644
index 6d4bd9e..0000000
--- a/python/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 = 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
-
-##################################################################
-##################################################################
-##################################################################