@ -1,24 +1,26 @@ |
|||||
import numpy as np |
import numpy as np |
||||
|
import pandas as pd |
||||
from feature_extraction.feature_extractor import extractFeatures |
from feature_extraction.feature_extractor import extractFeatures |
||||
from feature_extraction.batch_feature_extractor import batchExtract |
from feature_extraction.batch_feature_extractor import batchExtract |
||||
from preprocessing.data_preprocessing import arrayFromJSON, createSingleFeaturesArray, standardization, PCA |
from preprocessing.data_preprocessing import arrayFromJSON, standardization, PCA |
||||
from training.model_training import simpleTrain, kFCrossValid |
from training.model_training import simpleTrain, kFCrossValid |
||||
|
|
||||
batchExtract('../dataset/music_wav/', 'feature_extraction/music_features/', 22050) |
musicFeatures = batchExtract('../dataset/music_wav/', 'feature_extraction/music_features/', 22050) |
||||
batchExtract('../dataset/speech_wav/', 'feature_extraction/speech_features/', 22050) |
musicFeatures = musicFeatures.assign(target=0) |
||||
|
speechFeatures = batchExtract('../dataset/speech_wav/', 'feature_extraction/speech_features/', 22050) |
||||
|
speechFeatures = speechFeatures.assign(target=1) |
||||
|
|
||||
dataset, target, featureKeys = createSingleFeaturesArray( |
dataset = pd.concat([musicFeatures, speechFeatures]) |
||||
'feature_extraction/music_features/', |
target = dataset.pop('target').values |
||||
'feature_extraction/speech_features/') |
|
||||
|
|
||||
dataset = standardization(dataset) |
dataset = standardization(dataset) |
||||
# dataset = PCA(dataset) |
# dataset = PCA(dataset) |
||||
|
|
||||
print('Simple train accuracy achieved = ' + str(simpleTrain(dataset, target))) |
print('Simple train accuracy achieved = ' + str(simpleTrain(dataset, target))) |
||||
kFCrossValid(dataset, target, model = 'svm') |
kFCrossValid(dataset, target, model = 'svm') |
||||
clf = kFCrossValid(dataset, target, model = 'rndForest') |
clf = kFCrossValid(dataset, target, model = 'rndForest') |
||||
|
|
||||
extractFeatures('compined.wav', 'featuresStream/tmp.json', 22050) |
features = extractFeatures('compined.wav', 'tmp.json', 22050) |
||||
values = arrayFromJSON('featuresStream/tmp.json')[1] |
features = standardization(features) |
||||
values = standardization(values) |
audioClass = clf.predict(features) |
||||
audioClass = clf.predict(values) |
|
||||
print(audioClass) |
print(audioClass) |
@ -1,55 +1,28 @@ |
|||||
import numpy as np |
import numpy as np |
||||
|
import pandas as pd |
||||
from sys import path |
from sys import path |
||||
path.append('..') |
path.append('..') |
||||
from feature_extraction.batch_feature_extractor import batchExtract |
from feature_extraction.batch_feature_extractor import batchExtract |
||||
from preprocessing.data_preprocessing import createSingleFeaturesArray, standardization |
from preprocessing.data_preprocessing import standardization |
||||
from classification_model_training.model_training import simpleTrain |
from training.model_training import simpleTrain |
||||
|
|
||||
batchExtract('../../dataset/music_wav/', '../feature_extraction/music_features/', 22050) |
musicFeatures = batchExtract('../../dataset/music_wav/', '../feature_extraction/music_features/', 22050) |
||||
batchExtract('../../dataset/speech_wav/', '../feature_extraction/speech_features/', 22050) |
musicFeatures = musicFeatures.assign(target=0) |
||||
|
speechFeatures = batchExtract('../../dataset/speech_wav/', '../feature_extraction/speech_features/', 22050) |
||||
|
speechFeatures = speechFeatures.assign(target=1) |
||||
|
|
||||
dataset, target, featureKeys = createSingleFeaturesArray( |
dataset = pd.concat([musicFeatures, speechFeatures]) |
||||
'../feature_extraction/music_features/', |
target = dataset.pop('target').values |
||||
'../feature_extraction/speech_features/') |
|
||||
|
|
||||
dataset = standardization(dataset) |
dataset = pd.DataFrame(standardization(dataset), columns = dataset.columns.values) |
||||
|
|
||||
wholeAccuracy = simpleTrain(dataset, target, 'svm') |
wholeAccuracy = simpleTrain(dataset, target, 'svm') |
||||
print('Accuracy using whole dataset = ' + str(wholeAccuracy)) |
print('Accuracy using whole dataset = ' + str(wholeAccuracy)) |
||||
|
|
||||
damages = np.zeros(featureKeys.size) |
damages = np.zeros(dataset.columns.values.size) |
||||
|
|
||||
for index, key in enumerate(featureKeys): |
for index, key in enumerate(dataset.columns.values): |
||||
acc = simpleTrain(np.delete(dataset, index, axis=1), target, 'svm') |
acc = simpleTrain(dataset.drop(key, axis=1), target, 'svm') |
||||
damages[index] = 100*(wholeAccuracy-acc) |
damages[index] = 100*(wholeAccuracy-acc) |
||||
print('Accuracy without ' + key + '\t= ' + str(acc) + |
print('Accuracy without ' + key + '\t= ' + str(acc) + |
||||
',\tdamage\t= ' + "%.2f" % damages[index] + '%') |
',\tdamage\t= ' + "%.2f" % damages[index] + '%') |
||||
|
|
||||
# Accuracy using whole dataset = 0.951902893127681 |
|
||||
# Accuracy without 4HzMod = 0.9456968148215752, damage = 0.62% |
|
||||
# Accuracy without Flat = 0.9523592224148946, damage = -0.05% |
|
||||
# Accuracy without HFC = 0.9526330199872228, damage = -0.07% |
|
||||
# Accuracy without LAtt = 0.9524504882723374, damage = -0.05% |
|
||||
# Accuracy without SC = 0.9520854248425664, damage = -0.02% |
|
||||
# Accuracy without SComp = 0.948160992972529, damage = 0.37% |
|
||||
# Accuracy without SDec = 0.9520854248425664, damage = -0.02% |
|
||||
# Accuracy without SEFlat = 0.9513552979830245, damage = 0.05% |
|
||||
# Accuracy without SF = 0.9492561832618417, damage = 0.26% |
|
||||
# Accuracy without SFlat = 0.9496212466916126, damage = 0.23% |
|
||||
# Accuracy without SLAtt = 0.9498950442639409, damage = 0.20% |
|
||||
# Accuracy without SR = 0.9523592224148946, damage = -0.05% |
|
||||
# Accuracy without SSDec = 0.9519941589851236, damage = -0.01% |
|
||||
# Accuracy without ZCR = 0.9500775759788264, damage = 0.18% |
|
||||
# Accuracy without mfcc0 = 0.9502601076937118, damage = 0.16% |
|
||||
# Accuracy without mfcc1 = 0.9510815004106964, damage = 0.08% |
|
||||
# Accuracy without mfcc10 = 0.9503513735511545, damage = 0.16% |
|
||||
# Accuracy without mfcc11 = 0.9492561832618417, damage = 0.26% |
|
||||
# Accuracy without mfcc12 = 0.9482522588299717, damage = 0.37% |
|
||||
# Accuracy without mfcc2 = 0.9446928903897052, damage = 0.72% |
|
||||
# Accuracy without mfcc3 = 0.9465182075385599, damage = 0.54% |
|
||||
# Accuracy without mfcc4 = 0.9470658026832162, damage = 0.48% |
|
||||
# Accuracy without mfcc5 = 0.9463356758236744, damage = 0.56% |
|
||||
# Accuracy without mfcc6 = 0.9452404855343616, damage = 0.67% |
|
||||
# Accuracy without mfcc7 = 0.9462444099662316, damage = 0.57% |
|
||||
# Accuracy without mfcc8 = 0.9490736515469563, damage = 0.28% |
|
||||
# Accuracy without mfcc9 = 0.9472483343981016, damage = 0.47% |
|
After Width: | Height: | Size: 326 KiB |
After Width: | Height: | Size: 423 KiB |
After Width: | Height: | Size: 356 KiB |
After Width: | Height: | Size: 380 KiB |
After Width: | Height: | Size: 352 KiB |
After Width: | Height: | Size: 348 KiB |
After Width: | Height: | Size: 487 KiB |
After Width: | Height: | Size: 320 KiB |
After Width: | Height: | Size: 339 KiB |
After Width: | Height: | Size: 314 KiB |
After Width: | Height: | Size: 334 KiB |
After Width: | Height: | Size: 296 KiB |
After Width: | Height: | Size: 434 KiB |
After Width: | Height: | Size: 462 KiB |
After Width: | Height: | Size: 430 KiB |