Machine learning portal sklearn

--- --- restore content begins

# In iris data set, for example, using algorithms to do prediction knn 

# loading data set 
from sklearn Import Datasets 
iris = datasets.load_iris () 
X- = iris.data 
Y = iris.target
 Print (X.shape)
 Print (y.shape) 

from sklearn.neighbors Import KNeighborsClassifier 

# Create instance 
KNN = KNeighborsClassifier (= N_NEIGHBORS. 1 ) 

# model training 
knn.fit (X-, Y) 

# class prediction 
x_text = [[1, 2, 3, 4], [3, 2, 2 ,. 1 ]] 
RES = knn.predict (x_text)
 Print(res)

 

--- end --- restore content

Guess you like

Origin www.cnblogs.com/Chaosliang/p/11586554.html