-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
45 lines (31 loc) · 1.21 KB
/
utils.py
File metadata and controls
45 lines (31 loc) · 1.21 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
import pickle as pk
import pandas as pd
def mapping(dFrame):
mapping = {'male': 1, 'female': 0}
voiceData = dFrame.replace({'label': mapping})
return voiceData
def read_OnlyTestData(dropFileName=True,returnXy=True):
testVoiceData = pd.read_csv('static/datafiles/csvfiles/voice50_Test.csv')
testVoiceData = mapping(testVoiceData)
if (dropFileName == True):
testVoiceData = testVoiceData.drop('song name', axis=1)
X = testVoiceData.drop('label', axis=1).values
y = testVoiceData['label']
if(returnXy == True):
return X,y
else:
return testVoiceData
def read_OnlyTrainData(dropFileName=True):
trainVoiceData = pd.read_csv('static/datafiles/csvfiles/voice450_Train.csv')
trainVoiceData = mapping(trainVoiceData)
if(dropFileName == True):
trainVoiceData = trainVoiceData.drop('song name',axis=1)
return trainVoiceData
else:
return trainVoiceData
def savePickle(item,filename):
pk.dump(item, open('static/datafiles/pickles/' + filename, 'wb'))
print('Pickled file : {}'.format(filename) + ' saved !')
def getPicklefile(filename):
modelfile = pk.load(open('static/datafiles/pickles/'+filename, 'rb'))
return modelfile