源码地址:https://github.com/yicaifenchen8/learning.git
1.定义训练集合测试集
X = [[i, i] for i in range(20)] # training samples
# X = [[0, 0],[0, 0], [0, 1], [1, 0]] # training samples
# y = [i%2 for i in range(20)] # training target
y = [i > 2 and '0' or '1' for i in range(20)] # training target
2.训练模型
clf = svm.SVC() # class
clf.fit(X, y) # training the svc model
3.预测
print(clf.predict([[i, i] for i in range(20)]))
4.保存模型...
# 保存模型
joblib.dump(clf, '../res/rf.model')
# 加载模型
RF = joblib.load('../res/rf.model')
# 应用模型进行预测
result = RF.predict([[i, i] for i in range(20)])
print("result:",result)
a = 'ad' + 'bdd' + [555].__str__()+{'k':True}.__str__()
print(a)
源码地址:https://github.com/yicaifenchen8/learning.git