MCPcopy Index your code
hub / github.com/ujjwalkarn/DataSciencePython / load_data

Function load_data

Logistic-Regression/classifier_corrected.py:23–39  ·  view source on GitHub ↗

Load data from CSV files and return them as numpy arrays The use_labels parameter indicates whether one should read the first column (containing class labels). If false, return all 0s.

(filename, use_labels=True)

Source from the content-addressed store, hash-verified

21
22
23def load_data(filename, use_labels=True):
24 """
25 Load data from CSV files and return them as numpy arrays
26 The use_labels parameter indicates whether one should
27 read the first column (containing class labels). If false,
28 return all 0s.
29 """
30
31 # load column 1 to 8 (ignore last one)
32 data = np.loadtxt(open("data/" + filename), delimiter=',',
33 usecols=range(1, 9), skiprows=1)
34 if use_labels:
35 labels = np.loadtxt(open("data/" + filename), delimiter=',',
36 usecols=[0], skiprows=1)
37 else:
38 labels = np.zeros(data.shape[0])
39 return labels, data
40
41
42def save_results(predictions, filename):

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected