diff options
-rw-r--r-- | python/import_data.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/python/import_data.py b/python/import_data.py new file mode 100644 index 0000000..c97ce7e --- /dev/null +++ b/python/import_data.py @@ -0,0 +1,40 @@ + + + + +################################################################## +################################################################## +################################################################## +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 +################################################################## +################################################################## +################################################################## + + + +################################################################## +################################################################## +################################################################## +def uniform_data(n_observations = 1000, n_features = 50, n_relevant = 5): + import numpy as np + +################################################################## +################################################################## +################################################################## |