当前位置:   article > 正文

机器学习分类模型的选择_五折交叉验证的混淆矩阵

五折交叉验证的混淆矩阵

分别用逻辑回归、线性回归、K近邻、决策树、贝叶斯和SVM6个算法对iris数据集进行分类,并采用交叉验证计算模型的准确率。

加载一些库:

  1. from sklearn.datasets import load_iris
  2. from sklearn.model_selection import train_test_split
  3. from sklearn.model_selection import KFold
  4. from sklearn.model_selection import cross_val_score
  5. from sklearn.metrics import classification_report
  6. from sklearn.metrics import confusion_matrix
  7. from sklearn.metrics import accuracy_score
  8. from sklearn.linear_model import LogisticRegression
  9. from sklearn.tree import DecisionTreeClassifier
  10. from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
  11. from sklearn.neighbors import KNeighborsClassifier
  12. from sklearn.naive_bayes import GaussianNB
  13. from sklearn.svm import SVC
  14. from matplotlib import pyplot

加载数据集:

  1. #加载数据集
  2. data = load_iris()
  3. X = data['data']
  4. y = data['target']

训练集和测试集的

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/在线问答5/article/detail/909021
推荐阅读
相关标签
  

闽ICP备14008679号