You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
1.1 KiB
26 lines
1.1 KiB
6 years ago
|
import numpy as np
|
||
6 years ago
|
import pandas as pd
|
||
6 years ago
|
from feature_extraction.batch_feature_extractor import batchExtract
|
||
6 years ago
|
from preprocessing.data_preprocessing import standardization
|
||
|
from training.model_training import simpleTrain
|
||
6 years ago
|
|
||
6 years ago
|
musicFeatures = batchExtract('../dataset/music_wav/', '../feature_extraction/music_features/', 22050)
|
||
6 years ago
|
musicFeatures = musicFeatures.assign(target=0)
|
||
6 years ago
|
speechFeatures = batchExtract('../dataset/speech_wav/', '../feature_extraction/speech_features/', 22050)
|
||
6 years ago
|
speechFeatures = speechFeatures.assign(target=1)
|
||
6 years ago
|
|
||
6 years ago
|
dataset = pd.concat([musicFeatures, speechFeatures])
|
||
|
target = dataset.pop('target').values
|
||
6 years ago
|
|
||
6 years ago
|
dataset = pd.DataFrame(standardization(dataset), columns = dataset.columns.values)
|
||
6 years ago
|
|
||
|
wholeAccuracy = simpleTrain(dataset, target, 'svm')
|
||
|
print('Accuracy using whole dataset = ' + str(wholeAccuracy))
|
||
|
|
||
6 years ago
|
damages = np.zeros(dataset.columns.values.size)
|
||
6 years ago
|
|
||
6 years ago
|
for index, key in enumerate(dataset.columns.values):
|
||
|
acc = simpleTrain(dataset.drop(key, axis=1), target, 'svm')
|
||
6 years ago
|
damages[index] = 100*(wholeAccuracy-acc)
|
||
|
print('Accuracy without ' + key + '\t= ' + str(acc) +
|
||
6 years ago
|
',\tdamage\t= ' + "%.2f" % damages[index] + '%')
|