diff options
author | Gregory Ditzler <gditzler@Gregorys-MacBook-Pro.local> | 2013-03-25 13:52:08 -0400 |
---|---|---|
committer | Gregory Ditzler <gditzler@Gregorys-MacBook-Pro.local> | 2013-03-25 13:52:08 -0400 |
commit | 308c5ffba14dc5211689e7afd90c5d58d9c5d581 (patch) | |
tree | b21b39783869db5b98a6d60d23cbc7ec653f90c4 /python/import_data.py | |
parent | 13e3c413e80f1cc781e3f03083cccccb820223c6 (diff) |
modified demo and import data to test new feast functionality.
Diffstat (limited to 'python/import_data.py')
-rw-r--r-- | python/import_data.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/python/import_data.py b/python/import_data.py index c97ce7e..6d4bd9e 100644 --- a/python/import_data.py +++ b/python/import_data.py @@ -14,6 +14,7 @@ def read_digits(fname='digit.txt'): label appended. ''' import csv + import numpy as np fw = csv.reader(open(fname,'rb'), delimiter='\t') data = [] @@ -34,6 +35,23 @@ def read_digits(fname='digit.txt'): ################################################################## 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 ################################################################## ################################################################## |