Skip to content
Snippets Groups Projects
Commit 70d18b7a authored by a.croix's avatar a.croix
Browse files

Remove Job for processing AUC. AUC is always processed during WowaTraining job

parent 7145892b
No related branches found
No related tags found
1 merge request!1Include Wowa Training
Pipeline #6107 failed
......@@ -137,15 +137,4 @@ class WowaController extends Controller
return redirect(action("WowaController@index"));
}
public function computeAUCRoc(Wowa $wowa)
{
ProcessAUC::dispatch($wowa, 1, 0);
return redirect(action('WowaController@show', ["wowa" => $wowa]));
//return view("wowa.show", ["wowa" => $wowa]);
}
public function computeAUCPR(Wowa $wowa)
{
ProcessAUC::dispatch($wowa, 0, 1);
return redirect(action('WowaController@show', ["wowa" => $wowa]));
}
}
<?php
namespace App\Jobs;
use App\Feedback;
use App\Mark;
use App\Wowa;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use RUCD\Training\SolutionDistance;
class ProcessAUC implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $wowa;
protected $data = [];
protected $expected = [];
protected $auc;
protected $pr;
/**
* Create a new job instance.
*
* @param Wowa $wowa
* @param bool $auc
* @param bool $pr
* @param array|null $data
* @param array|null $expected
*/
public function __construct(Wowa $wowa, bool $auc, bool $pr, array $data = null, array $expected = null)
{
$this->wowa = $wowa;
$this->data = $data;
$this->expected = $expected;
$this->auc = $auc;
$this->pr = $pr;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$this->wowa->status = Wowa::STATE_RUNNING;
$this->wowa->save();
$solution = new SolutionDistance(count($this->wowa->w_weights));
$solution->weights_w = $this->wowa->w_weights;
$solution->weights_p = $this->wowa->p_weights;
if ($this->data === null || $this->expected === null) {
try {
Feedback::chunk(100, function ($feedbacks) {
foreach ($feedbacks as $feed) {
$evidence_references = $feed->report()->references;
$this->expected[] = $feed->is_true_alert;
$scores_references = [];
foreach ($evidence_references as $evidence_reference) {
$scores_references[] = Mark::get()->findEvidenceById($evidence_reference)->score;
}
$this->data[] = $scores_references;
}
});
} catch (\Exception $e) {
$this->wowa->status = Wowa::STATE_FAILED;
$this->wowa->save();
}
}
if ($this->auc) {
$solution->computeAUC($this->data, $this->expected);
$this->wowa->roc = $solution->getAucRoc();
}
if ($this->pr) {
$solution->computePRAUC($this->data, $this->expected);
$this->wowa->pr = $solution->getAucPr();
}
$this->wowa->status = Wowa::STATE_SUCCESS;
$this->wowa->save();
}
}
......@@ -111,13 +111,15 @@ class WowaJob implements ShouldQueue
$logg->error("Error during wowa training");
$this->wowa->save();
}
$this->wowa->status = Wowa::STATE_SUCCESS;
$this->wowa->w_weights = $solution->weights_w;
$this->wowa->p_weights = $solution->weights_p;
$this->wowa->score = $solution->getDistance();
$this->wowa->end_time = time();
$solution->computeAUC($this->evidences, $this->is_true_alert);
$solution->computePRAUC($this->evidences, $this->is_true_alert);
$this->wowa->roc = $solution->getAucRoc();
$this->wowa->pr = $solution->getAucPr();
$this->wowa->status = Wowa::STATE_SUCCESS;
$this->wowa->save();
ProcessAUC::dispatch($this->wowa, $this->bool_auc, $this->bool_pr, $this->evidences, $this->is_true_alert);
}
}
......@@ -47,24 +47,6 @@ class Wowa extends Model
}
}
public function roc()
{
if ($this->roc == null) {
return "ADD Button";
} else {
return $this->roc;
}
}
public function pr()
{
if ($this->pr == null) {
return "ADD Compute Button";
} else {
return $this->pr;
}
}
public function weightsP()
{
return $this->w_weights->toArray();
......
......@@ -41,40 +41,10 @@
<b>Weights P Vector</b> : @json($wowa->p_weights)
</p>
<p>
<b>AUC Roc curve</b> :
@if($wowa->roc == null)
@if($wowa->status == \App\Wowa::STATE_RUNNING)
<a class="btn btn-primary btn-sm disabled" aria-disabled="true"
href="{{ action('WowaController@computeAUCRoc', ['wowa' => $wowa]) }}">
Compute AUC Roc
</a>
@else
<a class="btn btn-primary btn-sm"
href="{{ action('WowaController@computeAUCRoc', ['wowa' => $wowa]) }}">
Compute AUC Roc
</a>
@endif
@else
{{ $wowa->roc }}
@endif
<b>AUC Roc curve</b> : {{ $wowa->roc }}
</p>
<p>
<b>AUC P-R curve</b> :
@if($wowa->pr == null)
@if($wowa->status == \App\Wowa::STATE_RUNNING)
<a class="btn btn-primary btn-sm disabled" aria-disabled=true"
href="{{ action('WowaController@computeAUCPR', ['wowa' => $wowa]) }}">
Compute AUC P-R
</a>
@else
<a id="pr" class="btn btn-primary btn-sm"
href="{{ action('WowaController@computeAUCPR', ['wowa' => $wowa]) }}">
Compute AUC P-R
</a>
@endif
@else
{{ $wowa->pr }}
@endif
<b>AUC P-R curve</b> : {{ $wowa->pr }}
</p>
<div>
<form method="POST"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment