def learn(fName, features, nRows=-1):
with open('bin/train.bin', 'r') as f:
train = np.load(f)
x = np.mat(train[:nRows,timbreVector[features[0]]]).reshape(nRows,1)
y = np.mat(train[:nRows,timbreVector[features[1]]]).reshape(nRows,1)
z = np.mat(train[:nRows,timbreVector[features[2]]]).reshape(nRows,1)
X = np.concatenate((x, y, z), axis=1)
Y = train[:nRows,0] % minYear
clf = svm.SVC(verbose=3)
clf.fit(X, Y)
print "[SUCCESS] Fitted training data to SVM (kernel: rbf)."
print "[STARTED] Dumping classifier."
joblib.dump(clf, 'bin/%s'%fName)
print "[SUCCESS] Dumped to ", fName
classify.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录