話者データを学習し、どの人のデータなのか機械学習で予測する
Libraryにmatplotlib, numpy, scikit-learn, libROSA、
識別にSVM、フーリエ変換、MFCCなどを使う
SVM
L 境界線(直線・曲線)を作り、データがどちら側か判定する
L 境界線付近をサポートベクトルと呼ぶ
1 2 3 4 5 6 7 8 9 10 11 12 13 | import numpy as np import matplotlib.pyplot as plt import random from sklearn import svm N = 15 random.seed( 11813 ) train_X = np.array([[random.randint( 0 , 100 ), random.randint( 0 , 100 )] for i in range (N)]) for i in range ( len (train_X)): plt.plot(train_X[i][ 0 ], train_X[i][ 1 ], 'o' , color = 'blue' ) plt.annotate(i, (train_X[i][ 0 ], train_X[i][ 1 ]), size = 20 ) plt.savefig( 'test.jpg' ,dpi = 100 ) |
分類する
1 2 3 4 5 6 7 8 | train_y = np.array([ 0 for i in range (N)]) train_y[ 2 ] = train_y[ 3 ] = train_y[ 1 ] = train_y[ 4 ] = train_y[ 5 ] = train_y[ 6 ] = train_y[ 11 ] = 1 colors = [ 'blue' , 'red' ] for i in range ( len (train_X)): plt.plot(train_X[i][ 0 ], train_X[i][ 1 ], 'o' , color = colors[train_y[i]]) plt.annotate(i, (train_X[i][ 0 ], train_X[i][ 1 ]), size = 20 ) plt.savefig( 'test.jpg' ,dpi = 100 ) |
1 2 3 4 5 6 7 8 9 10 11 12 | test_X = np.array([[ 30 , 60 ]]) plt.plot(test_X[ 0 ][ 0 ], test_X[ 0 ][ 1 ], 'x' , color = "black" ) plt.annotate( 'test' , (test_X[ 0 ][ 0 ], test_X[ 0 ][ 1 ]), size = 20 ) plt.savefig( 'test.jpg' ,dpi = 100 ) clf = svm.SVC(gamma = 0.0001 , C = 1 ) clf.fit(train_X, train_y) test_y = clf.predict(test_X) print (test_y) |
なるほど、SVMが何をやってるのかは理解できた。