Home  >  Article  >  Backend Development  >  素朴贝叶斯分类器的实现 (php)

素朴贝叶斯分类器的实现 (php)

WBOY
WBOYOriginal
2016-06-13 13:03:47987browse

朴素贝叶斯分类器的实现 (php)

本文用php实现了一个朴素贝叶斯分类器,针对属性值为离散型变量的记录进行贝叶斯分类。

?

通过对sample.csv文件中数据的学习,得到分类模型,然后对predict.csv中的数据的类指标进行预测。

针对每个被预测数据,计算属于每个类的概率,然后概率最大的类就是该数据被预测的类归属。

?

附件中包含了程序文件:bys.php,样本文件:sample.csv,待预测数据文件:predict.csv。

?

?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn