-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
50 lines (38 loc) · 1.3 KB
/
main.py
File metadata and controls
50 lines (38 loc) · 1.3 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
import pickle
from extract_features import extract_features_pca,extract_features_chroma_cqt,extract_features_chroma_stft,extract_features_lda
from evaluate import evaluate_all_songs_jointly,evaluate_a_song,evaluate_classifier,evaluate_all_songs_jointly_classifier
from sklearn.model_selection import train_test_split
from sklearn.externals import joblib
from sklearn.naive_bayes import GaussianNB
import os
def read_pkls():
data = []
labels = []
files = os.listdir(os.path.join(os.getcwd(),'data'))
files = sorted(files)
print(files)
for file in files:
X = joblib.load(os.path.join(os.getcwd(),'data',file))
data.append(X)
files = os.listdir(os.path.join(os.getcwd(),'labels'))
files = sorted(files)
print(files)
for file in files:
Y = joblib.load(os.path.join(os.getcwd(),'labels',file))
labels.append(Y)
return data, labels
def run(data, labels):
evaluate_all_songs_jointly(data,labels)
# evaluate_all_songs_jointly_classifier(data,labels,GaussianNB())
#Data reading after preprocessing
data, labels = read_pkls()
#Feature extraction
data_red=[]
for i in range(len(data)):
# song_red=extract_features_lda(data[i],labels[i])
song_red=extract_features_chroma_cqt(data[i])
# print song_red.shape
# song_red=extract_features_pca(data[i])
data_red.append(song_red)
#Evaluation
run(data_red, labels)