@foreach (['positif' => 'bg-gradient-success', 'netral' => 'bg-gradient-warning', 'negatif' => 'bg-gradient-danger'] as $sent => $badge)
{{ 'Total ' . ucfirst($sent) }}
{{ $counts['all'][$sent] }}
@endforeach
{{-- ====================== --}}
{{-- Section: Charts Row --}}
{{-- ====================== --}}
{{-- ====================== --}}
{{-- Section: Pie + Table --}}
{{-- ====================== --}}
E-Wallet |
Positif |
Netral |
Negatif |
Net Score |
@foreach (['Dana' => 'dana', 'GoPay' => 'gopay', 'ShopeePay' => 'shopeepay'] as $label => $key)
@php
$d = $counts[$key];
$net = (($d['positif'] - $d['negatif']) / max(1, array_sum($d))) * 100;
@endphp
{{ $label }} |
{{ $d['positif'] }} |
{{ $d['netral'] }} |
{{ $d['negatif'] }} |
{{ number_format($net, 1) }}%
|
@endforeach
{{-- ====================== --}}
{{-- Section: WordClouds --}}
{{-- ====================== --}}
@foreach (['positif', 'netral', 'negatif'] as $s)
@endforeach
{{-- =========================================================== --}}
{{-- Section: Confusion Matrix (Tailwind-like styling via utility) --}}
{{-- =========================================================== --}}
@foreach (['dana', 'gopay', 'shopeepay'] as $key)
@php
$confusionPath = storage_path("app/public/confusion_matrix_{$key}.csv");
$confusionData = [];
if (file_exists($confusionPath)) {
$confusionData = array_map('str_getcsv', file($confusionPath));
}
@endphp
@if (count($confusionData) > 1)
Actual\Predicted |
@foreach (array_slice($confusionData[0], 1) as $header)
{{ $header }} |
@endforeach
@foreach (array_slice($confusionData, 1) as $rowIndex => $row)
{{ $row[0] }} |
@foreach (array_slice($row, 1) as $colIndex => $cell)
@php
$isDiagonal = $rowIndex === $colIndex;
@endphp
{{ $cell }}
|
@endforeach
@endforeach
@else
File confusion_matrix_{{ $key }}.csv
tidak ditemukan atau
kosong.
@endif
@endforeach
{{-- ====================================== --}}
{{-- Section: Metrics Chart (Precision, F1) --}}
{{-- ====================================== --}}
@php
$wallets = ['dana', 'gopay', 'shopeepay'];
$metricsDetail = [];
$kelasUrut = ['netral', 'positif', 'negatif'];
foreach ($wallets as $key) {
$fileKey = $key;
$pathCsv = storage_path("app/public/evaluation_metrics_full{$fileKey}.csv");
$rows = [];
if (file_exists($pathCsv)) {
$rows = array_map('str_getcsv', file($pathCsv));
}
$metricsDetail[$key] = [
'labels' => [],
'precision' => [],
'recall' => [],
'f1' => [],
];
if (count($rows) > 1) {
$mapRowByKelas = [];
foreach (array_slice($rows, 1) as $r) {
$mapRowByKelas[strtolower(trim($r[0]))] = $r;
}
foreach ($kelasUrut as $kelas) {
if (isset($mapRowByKelas[$kelas])) {
$r = $mapRowByKelas[$kelas];
$precision = isset($r[1]) ? (float) $r[1] : 0;
$recall = isset($r[2]) ? (float) $r[2] : 0;
$f1score = isset($r[3]) ? (float) $r[3] : 0;
$metricsDetail[$key]['labels'][] = ucfirst($kelas);
$metricsDetail[$key]['precision'][] = round($precision, 3);
$metricsDetail[$key]['recall'][] = round($recall, 3);
$metricsDetail[$key]['f1'][] = round($f1score, 3);
} else {
$metricsDetail[$key]['labels'][] = ucfirst($kelas);
$metricsDetail[$key]['precision'][] = 0;
$metricsDetail[$key]['recall'][] = 0;
$metricsDetail[$key]['f1'][] = 0;
}
}
}
}
@endphp
@foreach ($wallets as $key)
@endforeach
{{-- ====================================== --}}
{{-- Section: Top Features per e-Wallet --}}
{{-- ====================================== --}}
@foreach (['dana', 'gopay', 'shopeepay'] as $key)
@php
$featuresPath = storage_path("app/public/top_features_{$key}.csv");
$featuresRaw = [];
if (file_exists($featuresPath)) {
$featuresRaw = array_map('str_getcsv', file($featuresPath));
}
$classFeatures = ['neutral' => [], 'positive' => [], 'negative' => []];
if (count($featuresRaw) > 1) {
foreach (array_slice($featuresRaw, 1) as $row) {
$classFeatures['neutral'][] = $row[1] ?? '';
$classFeatures['positive'][] = $row[2] ?? '';
$classFeatures['negative'][] = $row[3] ?? '';
}
}
@endphp
@if (count($featuresRaw) > 1)
@foreach (['neutral' => 'Netral', 'positive' => 'Positif', 'negative' => 'Negatif'] as $clsKey => $clsLabel)
{{ $clsLabel }}
@foreach ($classFeatures[$clsKey] as $feature)
- {{ $feature }}
@endforeach
@endforeach
@else
File top_features_{{ $key }}.csv
tidak ditemukan atau kosong.
@endif
@endforeach
{{-- ====================== --}}
{{-- SCRIPTS --}}
{{-- ====================== --}}