代码拉取完成,页面将自动刷新
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 15 16:38:03 2017
@author: hans
"""
import sklearn.svm as ssv
from sklearn.externals import joblib
import glob
import os
import time
if __name__ == "__main__":
model_path = './models/svm.model'
train_feat_path = './features/train'
fds = []
labels = []
num=0
for feat_path in glob.glob(os.path.join(train_feat_path, '*.feat')):
num += 1
data = joblib.load(feat_path)
fds.append(data[:-1])
labels.append(data[-1])
print "%d Dealing with %s" %(num,feat_path)
t0 = time.time()
#------------------------SVM--------------------------------------------------
clf = ssv.SVC(kernel='rbf') # for training initial model
# clf = ssv.SVC(kernel='rbf', C=17.255220940030252, gamma=1.2943653125547475e-06) # for training svm_pso.model(origin model)
print "Training a SVM Classifier."
clf.fit(fds, labels)
joblib.dump(clf, model_path)
#------------------------SVM--------------------------------------------------
t1 = time.time()
print "Classifier saved to {}".format(model_path)
print 'The cast of time is :%f seconds' % (t1-t0)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。