博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【Udacity】朴素贝叶斯
阅读量:7226 次
发布时间:2019-06-29

本文共 1319 字,大约阅读时间需要 4 分钟。

  • 机器学习就像酿制葡萄酒——好的葡萄(数据)+好的酿酒方法(机器学习算法)
  • 监督分类 supervised classification

  • Features ——>Labels
  • 保留10%的数据作为测试数据集

监督学习之朴素贝叶斯 Naive Bayes——寻找决策面
scikit-learn使用入门

googlesearch sklearn+Naive Bayes

关于sklearn版本
  • 视频——基于v0.17
  • 项目——基于v0.18

sklearn的现在稳定版为0.18,官方文档也升级到了0.18。但是,0.18版并不兼容0.17的代码。如果你安装了0.18版,sklearn.cross_validation, sklearn.grid_search and sklearn.learning_curve 等方法都不能直接调用。

新的API调用方法是

from sklearn.model_selection import train_test_split

计算准确度
def NB_Accuracy(features_train, labels_train, features_test, labels_test):        ### import the sklearn module for GaussianNB    from sklearn.naive_bayes import GaussianNB    ### create classifier    clf = GaussianNB()    ### fit the classifier on the training features and labels    clf.fit(features_train, labels_train)    ### use the trained classifier to predict labels for the test features    pred = clf.predict(features_test)    ### calculate and return the accuracy on the test data    ### this is slightly different than the example,     ### where we just print the accuracy    ### you might need to import an sklearn module    ### Method #1:    accuracy = clf.score(features_test, labels_test)    return accuracy    ### Method #2:    from sklearn.metrics import accuracy_score    print accuracy_score(pred, labels_test)

转载于:https://www.cnblogs.com/Neo007/p/7594429.html

你可能感兴趣的文章
LinkedHashSet 元素唯一,存储取出有序
查看>>
!!!四种常见的 POST 提交数据方式(含application/json)
查看>>
vim的用法简介
查看>>
Docker快速入门
查看>>
Linux运维常见面试题之精华收录
查看>>
Open Source的一些网站,自己收集来的
查看>>
导入ubuntu虚机配置,基于XEN4.0
查看>>
Script:收集UNDO诊断信息
查看>>
jmeter连接数据库-华山
查看>>
opencv 源码编译
查看>>
将旧硬盘的内容克隆到新硬盘
查看>>
Linux文件管理类命令之rm
查看>>
如何在Kubernetes中暴露服务访问
查看>>
NTP常见问题和解决方案&配置文件详解
查看>>
crontab计划任务补充知识
查看>>
数据库备份
查看>>
独家 | 图灵奖得主Raj Reddy:通用AI还很遥远,人类将成宠物
查看>>
java中自动生成XML文件
查看>>
Docker 数据卷,数据卷容器详细介绍
查看>>
VS2015编译Live555流媒体服务器
查看>>