Reference: http://my.oschina.net/u/175377/blog/84420
First: Use Sklearn to import very simple famous flower data--Anderson Iris Floral Data set.
We have some measurements of the size of 150 irises: sepals length, width, petal length and width. There are also their sub-genus: The iris setosa, the Iris versicolor, and the Iris virginica Virginia. The data is stored in the. Data entry and is an array (N_samples, n_features). The type of each observation object is stored in the. Target property of the dataset. This is an integer one-dimensional array of length n_samples.
Then the data is trained and predicted by SVM.
#-*-coding:utf-8-*-"""Created on Sat 10:38:57 2015@author:lin"""Print(__doc__) fromSklearnImportDatasetsiris=Datasets.load_iris ()#Print Iris.data #注释掉的几行代码都是用来看iris数据一些相关的属性的#iris.target[[10,25,50]]#print=list (iris.target_names)if __name__=="__main__": fromSklearnImportSVM CLF=SVM. Linearsvc () Clf.fit (iris.data,iris.target) result=clf.predict ([[6,4,5,1]]) PrintresultPrintClf.coef_
Python machine learning Kind