sklearn3_svc分类器预测

python机器学习-乳腺癌细胞挖掘(博主亲自录制视频)

https://study.163.com/course/introduction.htm?courseId=1005269003&utm_campaign=commission&utm_source=cp-400000000398149&utm_medium=share

svc分类器预测

# -*- coding: utf-8 -*-
"""
Created on Sat Jan  6 17:47:24 2018

@author: daxiong
"""

from sklearn import datasets
from sklearn.svm import SVC
iris = datasets.load_iris()

clf = SVC()

clf.fit(iris.data, iris.target)  

list(clf.predict(iris.data[:3]))
'''
Out[34]: [0, 0, 0]
'''

#clf.fit(iris.data, iris.target_names[iris.target])  
#list(clf.predict(iris.data[:3]))
'''Out[32]: ['setosa', 'setosa', 'setosa']'''

clf.predict(([ 5.1,  3.5,  1.4,  0.2],))
'''
Out[71]: array([0])
'''

clf.predict(([ 5.1,  3.5,  1.4,  0.2],[ 4.9,  3. ,  1.4,  0.2]))
''' array([0, 0])'''

 https://study.163.com/provider/400000000398149/index.htm?share=2&shareId=400000000398149( 欢迎关注博主主页,学习python视频资源,还有大量免费python经典文章)


原文地址:https://www.cnblogs.com/webRobot/p/8214942.html