aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Ditzler <gditzler@Gregorys-MacBook-Pro.local>2013-03-25 13:40:18 -0400
committerGregory Ditzler <gditzler@Gregorys-MacBook-Pro.local>2013-03-25 13:40:18 -0400
commit553edf5a8c482c8fd1d6009c134a1ef41aef8996 (patch)
treed480c048034b47447800d9aeebf7e737ff102738
parent2760fc4511b08d84dfc6d94611a743db7179ab2d (diff)
added import_data.py
-rw-r--r--python/import_data.py40
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
+
+##################################################################
+##################################################################
+##################################################################