Log解析の基礎@phpcon2014
- 9. 9
<?php
namespace Algorithms;
class NaiveBayes {
public function add_instance(){}
public function train(){}
public function predict(){}
...
}
- 11. { 正解 : {KW : 回数} }
{ 男性 : {ガンダム : 5 , ACミラン : 8 } }
{ 女性 : {化粧水 : 2 , 日焼け止め : 7 } }
11
・・・
- 12. 12
$nb = new NaiveBayes();
// iteration
$nb->add_instance( 'label' => '正解',
'attributes' => 'KW : 回数' );
$nb->train();
- 14. { 未知 : {KW : 回数} }
{ ? : {ガンダム : 3 , シャア : 2 } }
14
・・・
- 15. 15
// iteration
$res = $nb->predict( 'attributes' => 'KW :
回数' );
foreach($res as $label => $p) {
echo $label . "t" . $p . "n";
}
// 男性 : 0.878
// 女性 : 0.122
// UniqIDをKeyにNosqlへ