-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathread_featureval_csv.py
More file actions
61 lines (43 loc) · 1.66 KB
/
Copy pathread_featureval_csv.py
File metadata and controls
61 lines (43 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# -*- coding: utf-8 -*-
"""
Created on Thu Dec 13 19:30:51 2018
@author: Casey
"""
import pandas as pd
import numpy as np
def getFeatures(featureFile):
featureVals = pd.read_csv(featureFile,
sep=',',
header=0)
labels = pd.read_csv('labels.csv',
sep=',',
header=0)#ignore first row because matlab writes an irrelevant var name to first row
# featureNames = pd.read_csv('features.csv',
# sep=',',
# header=0)#same as above
featureValnp = np.array(featureVals,dtype="float32")
labelsnp = np.array(labels)
featureNamesnp = featureVals.head(0).columns.values
#featureNamesnp=np.array(featureNames)
return featureValnp, labelsnp, featureNamesnp
#print(featureValnp)
#print(np.shape(featureValnp))
#print(labels)
#print(featureNames)
def getNames(featureFile):
featureVals = pd.read_csv(featureFile,
sep=',',
header=0)
featureNamesnp = featureVals.head(0).columns.values
return featureNamesnp
def chooseFeatures(XFeatures, XFile,yFile):
inputData = pd.read_csv(XFile,
sep=',',
usecols=XFeatures,
header=0)
outputData = pd.read_csv(yFile,
sep=',',
usecols=[0],
header=0)
tempAllX = np.array(inputData, dtype="float")
return tempAllX, np.array(outputData), inputData.head(0).columns.values