Ich trainiere zwei GMM-Klassifikatoren, jeweils für ein Label, mit MFCC-Werten. Ich verkettete alle MFCC-Werte einer Klasse und passte in einen Klassifikator. Und für jeden Klassifikator summiere ich die Wahrscheinlichkeit der Wahrscheinlichkeit seines Labels.Klassifikator Vorhersagen sind unzuverlässig, ist das, weil mein GMM Klassifikator nicht richtig trainiert ist?
def createGMMClassifiers():
label_samples = {}
for label, sample in training.iteritems():
labelstack = np.empty((50,13))
for feature in sample:
#debugger.set_trace()
labelstack = np.concatenate((labelstack,feature))
label_samples[label]=labelstack
for label in label_samples:
#debugger.set_trace()
classifiers[label] = mixture.GMM(n_components = n_classes)
classifiers[label].fit(label_samples[label])
for sample in testing['happy']:
classify(sample)
def classify(testMFCC):
probability = {'happy':0,'sad':0}
for name, classifier in classifiers.iteritems():
prediction = classifier.predict_proba(testMFCC)
for probforlabel in prediction:
probability[name]+=probforlabel[0]
print 'happy ',probability['happy'],'sad ',probability['sad']
if(probability['happy']>probability['sad']):
print 'happy'
else:
print 'sad'
Aber meine Ergebnisse scheint nicht konsequent zu sein und ich finde es schwer, weil der Zustand RandomSeed = None ist es zu glauben, da alle Prognosen oft das gleiche Etikett für alle Testdaten sind, aber jeder Lauf es gibt oft die genauen Gegensätze (siehe Ausgang 1 und Ausgang 2).
Also meine Frage ist, mache ich etwas offensichtlich falsch beim Training meiner Klassifikator?
Ausgang 1:
happy 123.559202732 sad 122.409167294
happy
happy 120.000879032 sad 119.883786657
happy
happy 124.000069307 sad 123.999928962
happy
happy 118.874574047 sad 118.920941127
sad
happy 117.441353421 sad 122.71924156
sad
happy 122.210579428 sad 121.997571901
happy
happy 120.981752603 sad 120.325940128
happy
happy 126.013713257 sad 125.885047394
happy
happy 122.776016525 sad 122.12320875
happy
happy 115.064172476 sad 114.999513909
happy
Ausgang 2:
happy 123.559202732 sad 122.409167294
happy
happy 120.000879032 sad 119.883786657
happy
happy 124.000069307 sad 123.999928962
happy
happy 118.874574047 sad 118.920941127
sad
happy 117.441353421 sad 122.71924156
sad
happy 122.210579428 sad 121.997571901
happy
happy 120.981752603 sad 120.325940128
happy
happy 126.013713257 sad 125.885047394
happy
happy 122.776016525 sad 122.12320875
happy
happy 115.064172476 sad 114.999513909
happy
Früher fragte ich eine relevante Frage und bekam eine richtige Antwort. Ich gebe den Link unten an.
Having different results every run with GMM Classifier
Edit: hinzugefügt Hauptfunktion, die die Daten und teilt sich in Ausbildung sammelt und Test
def main():
happyDir = dir+'happy/'
sadDir = dir+'sad/'
training["sad"]=[]
training["happy"]=[]
testing["happy"]=[]
#TestSet
for wavFile in os.listdir(happyDir)[::-1][:10]:
#print wavFile
fullPath = happyDir+wavFile
testing["happy"].append(sf.getFeatures(fullPath))
#TrainSet
for wavFile in os.listdir(happyDir)[::-1][10:]:
#print wavFile
fullPath = happyDir+wavFile
training["happy"].append(sf.getFeatures(fullPath))
for wavFile in os.listdir(sadDir)[::-1][10:]:
fullPath = sadDir+wavFile
training["sad"].append(sf.getFeatures(fullPath))
#Ensure the number of files in set
print "Test(Happy): ", len(testing['happy'])
print "Train(Happy): ", len(training['happy'])
createGMMClassifiers()
Edit 2: den Code geändert, um die Antwort nach. Immer noch ähnliche inkonsistente Ergebnisse.
Vielen Dank für Ihren Vorschlag! Ich werde den Link so bald wie möglich überprüfen, nachdem ich diesen bestimmten Klassifizierungsalgorithmus aussagekräftige Ergebnisse erhalten habe. – Ugur