如下10种分类算法对比
names = ["Nearest Neighbors", "Linear SVM", "RBF SVM", "Gaussian Process","Decision Tree", "Random Forest", "Neural Net", "AdaBoost","Naive Bayes", "QDA"]
https://scikit-learn.org/stable/auto_examples/classification/plot_classifier_comparison.htmlprint(__doc__)# Code source: Gaël Varoquaux
#              Andreas Müller
# Modified for documentation by Jaques Grobler
# License: BSD 3 clauseimport numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import ListedColormap
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.datasets import make_moons, make_circles, make_classification
from sklearn.neural_network import MLPClassifier
from sklearn.neighbors import KNeighborsClassifier
from sklearn.svm import SVC
from sklearn.gaussian_process import GaussianProcessClassifier
from sklearn.gaussian_process.kernels import RBF
from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import RandomForestClassifier, AdaBoostClassifier
from sklearn.naive_bayes import GaussianNB
from sklearn.discriminant_analysis import QuadraticDiscriminantAnalysish = .02  # step size in the meshnames = ["Nearest Neighbors", "Linear SVM", "RBF SVM", "Gaussian Process","Decision Tree", "Random Forest", "Neural Net", "AdaBoost","Naive Bayes", "QDA"]classifiers = [KNeighborsClassifier(3),SVC(kernel="linear", C=0.025),SVC(gamma=2, C=1),GaussianProcessClassifier(1.0 * RBF(1.0)),DecisionTreeClassifier(max_depth=5),RandomForestClassifier(max_depth=5, n_estimators=10, max_features=1),MLPClassifier(alpha=1, max_iter=1000),AdaBoostClassifier(),GaussianNB(),QuadraticDiscriminantAnalysis()]X, y = make_classification(n_features=2, n_redundant=0, n_informative=2,random_state=1, n_clusters_per_class=1)
rng = np.random.RandomState(2)
X += 2 * rng.uniform(size=X.shape)
linearly_separable = (X, y)datasets = [make_moons(noise=0.3, random_state=0),make_circles(noise=0.2, factor=0.5, random_state=1),linearly_separable]figure = plt.figure(figsize=(27, 9))
i = 1
# iterate over datasets
for ds_cnt, ds in enumerate(datasets):# preprocess dataset, split into training and test partX, y = dsX = StandardScaler().fit_transform(X)X_train, X_test, y_train, y_test = \train_test_split(X, y, test_size=.4, random_state=42)x_min, x_max = X[:, 0].min() - .5, X[:, 0].max() + .5y_min, y_max = X[:, 1].min() - .5, X[:, 1].max() + .5xx, yy = np.meshgrid(np.arange(x_min, x_max, h),np.arange(y_min, y_max, h))# just plot the dataset firstcm = plt.cm.RdBucm_bright = ListedColormap(['#FF0000', '#0000FF'])ax = plt.subplot(len(datasets), len(classifiers) + 1, i)if ds_cnt == 0:ax.set_title("Input data")# Plot the training pointsax.scatter(X_train[:, 0], X_train[:, 1], c=y_train, cmap=cm_bright,edgecolors='k')# Plot the testing pointsax.scatter(X_test[:, 0], X_test[:, 1], c=y_test, cmap=cm_bright, alpha=0.6,edgecolors='k')ax.set_xlim(xx.min(), xx.max())ax.set_ylim(yy.min(), yy.max())ax.set_xticks(())ax.set_yticks(())i += 1# iterate over classifiersfor name, clf in zip(names, classifiers):ax = plt.subplot(len(datasets), len(classifiers) + 1, i)clf.fit(X_train, y_train)score = clf.score(X_test, y_test)# Plot the decision boundary. For that, we will assign a color to each# point in the mesh [x_min, x_max]x[y_min, y_max].if hasattr(clf, "decision_function"):Z = clf.decision_function(np.c_[xx.ravel(), yy.ravel()])else:Z = clf.predict_proba(np.c_[xx.ravel(), yy.ravel()])[:, 1]# Put the result into a color plotZ = Z.reshape(xx.shape)ax.contourf(xx, yy, Z, cmap=cm, alpha=.8)# Plot the training pointsax.scatter(X_train[:, 0], X_train[:, 1], c=y_train, cmap=cm_bright,edgecolors='k')# Plot the testing pointsax.scatter(X_test[:, 0], X_test[:, 1], c=y_test, cmap=cm_bright,edgecolors='k', alpha=0.6)ax.set_xlim(xx.min(), xx.max())ax.set_ylim(yy.min(), yy.max())ax.set_xticks(())ax.set_yticks(())if ds_cnt == 0:ax.set_title(name)ax.text(xx.max() - .3, yy.min() + .3, ('%.2f' % score).lstrip('0'),size=15, horizontalalignment='right')i += 1plt.tight_layout()
plt.show()

#result

如下10种分类算法对比Classifier comparison相关推荐

  1. 10 种机器学习算法的要点(附 Python 和 R 代码)(转载)

    10 种机器学习算法的要点(附 Python 和 R 代码)(转载) from:https://zhuanlan.zhihu.com/p/25273698 前言 谷歌董事长施密特曾说过:虽然谷歌的无人 ...

  2. 三种Hash算法对比以及秒传原理.

    三种Hash算法对比以及秒传原理 CRC (32/64)   MD5  Sha1 分5个点来说 1.校验值长度 2.校验值类别 3.安全级别 4.应用场景 1).校验值长度 CRC(32/64) 分别 ...

  3. 「数据科学家」必备的10种机器学习算法

    来源 | 雷克世界(ID:raicworld) 编译 | 嗯~是阿童木呀.KABUDA.EVA 可以说,机器学习从业者都是个性迥异的.虽然其中一些人会说"我是X方面的专家,X可以在任何类型的 ...

  4. 10 种机器学习算法的要点

    前言 谷歌董事长施密特曾说过:虽然谷歌的无人驾驶汽车和机器人受到了许多媒体关注,但是这家公司真正的未来在于机器学习,一种让计算机更聪明.更个性化的技术. 也许我们生活在人类历史上最关键的时期:从使用大 ...

  5. 10 种机器学习算法的要点(附 Python 和 R 代码)

    前言 谷歌董事长施密特曾说过:虽然谷歌的无人驾驶汽车和机器人受到了许多媒体关注,但是这家公司真正的未来在于机器学习,一种让计算机更聪明.更个性化的技术. 也许我们生活在人类历史上最关键的时期:从使用大 ...

  6. 机器学习的9个基础概念和10种基本算法总结

    https://blog.csdn.net/libaqiangdeliba/article/details/41901387 1.基础概念: (1) 10折交叉验证:英文名是10-fold cross ...

  7. 10种排序算法基础总结

    基于比较的排序: 基础排序:  冒泡排序:谁大谁上,每一轮都把最大的顶到天花板 效率太低--掌握swap. 选择排序:效率较低,但经常用它内部的循环方式来找最大值和最小值. 插入排序:虽然平均效率低, ...

  8. em算法直观_直观地解释了10种图形算法

    em算法直观 重点 (Top highlight) Graphs have become a powerful means of modelling and capturing data in rea ...

  9. Python 实操案例:一文详解10种聚类算法

    聚类或聚类分析是无监督学习问题.它通常被用作数据分析技术,用于发现数据中的有趣模式,例如基于其行为的客户群.有许多聚类算法可供选择,对于所有情况,没有单一的最佳聚类算法.相反,最好探索一系列聚类算法以 ...

最新文章

  1. 制作CentOS fence-agents 镜像
  2. px4flow智能光学流动传感器
  3. 贾跃亭画了一个8500亿的大饼
  4. C++STL之vector的说明及使用
  5. Harbour.Space Scholarship Contest 2021-2022 F. Pairwise Modulo 逆向思维 + 树状数组
  6. 统计Apache或Nginx访问日志里的独立IP访问数量的Shell
  7. 信息学奥赛一本通(1021:打印字符)
  8. flow.php 漏洞,Ecshop 3.0的flow.php文件SQL注射漏洞修复
  9. 转Openstack Ceilometer监控项扩展
  10. 323 id与小数据池
  11. 震惊!!【微信拼图红包】继微信语音红包后又一新技能
  12. 获取百度云盘真实下载链接(告别云盘客户端,全速下载)
  13. 软件工程(软件维护)
  14. 短信验证码(SMS verification)是什么
  15. 我的全栈之路-C语言基础之数据存储
  16. 关于 ORA-22992
  17. JMX : MXBean
  18. 手把手教你给KEGG pathway图标注颜色
  19. [青少年CTF]弱口令实验室招新赛部分WriteUp
  20. ATI六维力传感器完整使用教程(婴儿式教学!!!!)

热门文章

  1. python数据类型变量_python的数据类型与变量
  2. flat在java中的含义_java – 在flatingBy中使用flatMap的优雅方法
  3. JS打印指定区域内容
  4. 为什么正则化可以起到对模型容量进行控制_正则化为什么能防止过拟合(重点地方标红了)...
  5. python累加求和_李老师带你学Python-第二课 如何编写Python程序
  6. python-docx 使用教程_python docx 中文字体设置的操作方法
  7. 磁盘分区形式mbr和gpt哪个好_济南历下区中考美术集训应该选哪个
  8. mysql-5.5.59安装_MySQL-5.5 安装
  9. java wait for_Java p.waitfor()永远等待
  10. 华为mate x2什么时候更新鸿蒙系统,华为Mate X2真机发布,今年四月可升级鸿蒙系统...