⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_bayes.php

📁 PHP NaiveBayes源代码
💻 PHP
字号:
<?php// test_bayes.phpinclude "Bayes.php";// Different possible disease the patient might have$disease_labels = array("d1", "d2", "d3");// Where patient is assessed as to whether they exhibit symptom 1 and/or symptom 2$symptom_labels = array("++", "+-", "-+", "--");  // Load the disease base rates// $priors = array(.3215, .2125, .4660);$priors = array(.322, .214, .464);// Load liklihood estimates$likelihood[0] = array(.656, .094, .219, .031);$likelihood[1] = array(.186, .062, .559, .193);$likelihood[2] = array(.109, .766, .016, .109);// Instantiate Bayes object using specified priors and likelihood$bayes = new Bayes($priors, $likelihood);// Call the big hammer$bayes->getPosterior();echo "<p>";echo "The probability of each disease type given the presence or absence of symptoms is: ";echo "</p>";$bayes->setRowLabels($symptom_labels);    // i.e., evidence$bayes->setColumnLabels($disease_labels); // i.e., hypothesis$bayes->toHTML();echo "<br />";echo "<p>";echo "Here is what a dump of the Bayes object looks: ";echo "</p>";echo "<pre>";print_r($bayes);echo "</pre>";?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -