import seaborn as sns sns.set() iris = sns.load_dataset('iris') sns.pairplot(iris, hue='species', size=1.5) X_iris = iris.drop('species', axis=1) print(X_iris) y_iris = iris['species'] print(y_iris) from sklearn.cross_validation import train_test_split Xtrain, Xtest, ytrain, ytest = train_test_split(X_iris, y_iris, random_state=1) from sklearn.naive_bayes import GaussianNB model = GaussianNB() model.fit(Xtrain, ytrain) y_model = model.predict(Xtest) from sklearn.metrics import accuracy_score print(accuracy_score(ytest, y_model))
监督学习model test
最新推荐文章于 2024-06-03 01:09:35 发布