鸢尾花完整的python代码knn_knn实现鸢尾花分类

#coding:utf-8

%matplotlib inline

from sklearn.datasets import load_iris

from sklearn.model_selection import train_test_split

from sklearn.neighbors import KNeighborsClassifier

import numpy as np

import matplotlib.pyplot as plt

iris_dataset = load_iris() # 获取数据

# print("keys of iris_dataset:\n{}".format(iris_dataset.keys()))

# print(iris_dataset["DESCR"][:193]+"\n...")

# print("target names:{}".format(iris_dataset["target_names"]))

# print("feature names:{}".format(iris_dataset["feature_names"]))

# print(iris_dataset["data"][:5])

# print(iris_dataset["data"], iris_dataset["target"])

# 对数据进行拆分,分为训练数据和测试数据

x_train, x_test, y_train, y_test = train_test_split(iris_dataset["data"], iris_dataset["target"], random

你可能感兴趣的:(鸢尾花完整的python代码knn_knn实现鸢尾花分类)