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

本文共 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

你可能感兴趣的文章
Java JDBC链接Oracle数据库
查看>>
Moss2010 部署命令
查看>>
Git 操作分支
查看>>
Grid search in the tidyverse
查看>>
hdu 三部曲 Contestants Division
查看>>
day22——创建表、增加数据、查询数据
查看>>
css伪元素实现tootip提示框
查看>>
关于函数指针的总结
查看>>
采用PHP函数uniqid生成一个唯一的ID
查看>>
Centos7安装32位库用来安装32位软件程序
查看>>
【HMOI】小C的填数游戏 DP+线段树维护
查看>>
java中23种设计模式之6-适配器模式(adapter pattern)
查看>>
Easy C 编程 in Linux
查看>>
poj3761(反序表)
查看>>
x86寄存器总结
查看>>
jquery easyui ajax data属性传值方式
查看>>
封装了些文件相关的操作
查看>>
什么是Solr
查看>>
poj2386(简单dfs)
查看>>
双链表的基本操作
查看>>