2019-07-25 09:28:30 +02:00
|
|
|
<?php
|
2019-07-25 15:45:33 +02:00
|
|
|
include_once 'Base.php';
|
2019-07-25 09:28:30 +02:00
|
|
|
|
2019-08-13 14:21:58 +02:00
|
|
|
class Polynomial extends DecayingModelBase
|
2019-07-25 09:28:30 +02:00
|
|
|
{
|
2019-09-12 11:28:32 +02:00
|
|
|
function __construct() {
|
2019-09-12 16:33:19 +02:00
|
|
|
$this->description = __('The implementation of the decaying formula from the paper `An indicator scoring method for MISP platforms`.');
|
2019-09-12 11:28:32 +02:00
|
|
|
}
|
2019-08-19 12:26:58 +02:00
|
|
|
|
2019-07-25 09:28:30 +02:00
|
|
|
public function computeScore($model, $attribute, $base_score, $elapsed_time)
|
|
|
|
{
|
|
|
|
if ($elapsed_time < 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
2019-08-21 10:02:26 +02:00
|
|
|
$decay_speed = $model['DecayingModel']['parameters']['decay_speed'];
|
|
|
|
$lifetime = $model['DecayingModel']['parameters']['lifetime']*24*60*60;
|
|
|
|
$score = $base_score * (1 - pow($elapsed_time / $lifetime, 1 / $decay_speed));
|
2019-07-25 09:28:30 +02:00
|
|
|
return $score < 0 ? 0 : $score;
|
|
|
|
}
|
2019-07-25 16:13:42 +02:00
|
|
|
|
|
|
|
public function isDecayed($model, $attribute, $score)
|
|
|
|
{
|
|
|
|
$threshold = $model['DecayingModel']['parameters']['threshold'];
|
|
|
|
return $threshold > $score;
|
|
|
|
}
|
2019-07-25 09:28:30 +02:00
|
|
|
}
|