1、简易安装模块
conda install scikit-learn
失败看下面链接
https://sklearn.apachecn.org/docs/master/62.html
2、整体过程(与tensorflow相似)
1)、获取数据
2)、建模
3)、训练模型
4)、测试模型
3、简单案例
from sklearn import datasets from sklearn.model_selection import train_test_split from sklearn.neighbors import KNeighborsClassifier # 1.数据 x, y = datasets.load_iris(return_X_y=True) x_train, x_test, y_train, y_test = train_test_split(x, y, train_size=0.7) # 2. 模型 model = KNeighborsClassifier() # 3. 训练 model.fit(x_train, y_train) # 4.测试(评估) res = model.score(x_test, y_test) print(res)