You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
549 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# Example
from sklearn import datasets
import numpy
from numpy import *
from sklearn import svm
print ('''加载数据集''')
digits = datasets.load_digits()
# 例如在digits数据集中digits.data是可以用来分类数字样本的特征
print(digits.data,"type(digits.data)=%s"%type(digits.data))
print("shape(digits.data)=%s,%s"%shape(digits.data))
print (digits.target)
print ('''训练和预测''')
#选择参数
clf = svm.SVC(gamma=0.0001,C=100)
# 进行训练
clf.fit(digits.data[:-1],digits.target[:-1])
# 进行预测
print (clf.predict(digits.data[:-1]))