贝叶斯方法完整代码 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 import seaborn as sns iris = sns.load_dataset('iris') X_iris = iris.drop('species', axis=1) y_iris = iris['species'] print(X_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 accuracy_score(ytest,