@extends('layouts/user_type/auth') @section('content') {{-- Ringkasan Sentimen --}}
@foreach (['positif' => 'bg-success', 'netral' => 'bg-warning', 'negatif' => 'bg-danger'] as $sent => $badge)

Total {{ ucfirst($sent) }}

{{ $counts['all'][$sent] }}

@endforeach
{{-- Charts Section --}}
Perbandingan Sentimen E-Wallet
Tren Sentimen E-Wallet
{{-- Pie + Table --}}
Distribusi Persentase Sentimen
Perbandingan Sentimen Antar Brand
@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 @endforeach
E-Wallet Positif Netral Negatif Net Score
{{ $label }} {{ $d['positif'] }} {{ $d['netral'] }} {{ $d['negatif'] }} {{ number_format($net, 1) }}%
{{-- WordCloud Section --}}
@foreach (['positif', 'netral', 'negatif'] as $s)
{{ ucfirst($s) }}
@endforeach
{{-- ============================================== SECTION: Confusion Matrix dengan Tailwind CSS ============================================== --}}
{{-- Grid tiga kolom pada layar md ke atas, satu kolom pada layar kecil --}}
@foreach (['dana', 'gopay', 'shopeepay'] as $key)
{{-- Header Card --}}
{{ $key }} Confusion Matrix
{{-- Body Card --}}
@php // Path ke CSV: storage/app/public/confusion_matrix_{key}.csv $confusionPath = storage_path("app/public/confusion_matrix_{$key}.csv"); $confusionData = []; if (file_exists($confusionPath)) { // Parse setiap baris CSV menjadi array via str_getcsv $confusionData = array_map('str_getcsv', file($confusionPath)); } @endphp @if (count($confusionData) > 1) {{-- Wrapper agar tabel bisa di-scroll horizontal di layar kecil, dan center --}}
{{-- Hapus w-full, tambahkan mx-auto supaya tabel di-center --}} {{-- Pojok kiri atas: beri label “Actual\Predicted” --}} {{-- LOOP HANYA header Predicted (lewati elemen pertama yang kosong) --}} @foreach (array_slice($confusionData[0], 1) as $header) @endforeach @foreach (array_slice($confusionData, 1) as $rowIndex => $row) {{-- Striping ganjil/genap --}} {{-- Kolom label “Actual_…” --}} {{-- Loop nilai prediksi --}} @foreach (array_slice($row, 1) as $colIndex => $cell) @php // Perhatikan bahwa $rowIndex mulai dari 0 (baris pertama di body), // tapi kolom diagonal-nya juga sama, karena array_slice dimulai dari row ke-1. $isDiagonal = $rowIndex === $colIndex; @endphp @endforeach @endforeach
Actual\Predicted {{ $header }}
{{ $row[0] }} {{ $cell }}
@else
File confusion_matrix_{{ $key }}.csv tidak ditemukan atau kosong.
@endif
@endforeach
{{-- ================================================================ SECTION: Metrics Chart (Perbandingan Precision, F1, Accuracy) ================================================================ --}} @php // Siapkan array untuk ringkasan metrik tiap e‐wallet $metricsSummary = [ 'dana' => ['precision' => 0, 'f1' => 0, 'accuracy' => 0], 'gopay' => ['precision' => 0, 'f1' => 0, 'accuracy' => 0], 'shopeepay' => ['precision' => 0, 'f1' => 0, 'accuracy' => 0], ]; foreach (array_keys($metricsSummary) as $key) { // 1) Baca evaluation_metrics_full{key}.csv $metricsPath = storage_path("app/public/evaluation_metrics_full{$key}.csv"); $metricsData = []; if (file_exists($metricsPath)) { $metricsData = array_map('str_getcsv', file($metricsPath)); } // Hitung Macro‐Precision & Macro‐F1 (rata-rata precision/f1 tiap kelas) $sumPrecision = 0.0; $sumF1 = 0.0; $nClasses = 0; if (count($metricsData) > 1) { // Baris pertama header: [,precision,recall,f1‐score,support] foreach (array_slice($metricsData, 1) as $row) { $sumPrecision += (float) $row[1]; // precision $sumF1 += (float) $row[3]; // f1‐score $nClasses++; } if ($nClasses > 0) { $metricsSummary[$key]['precision'] = round($sumPrecision / $nClasses, 3); $metricsSummary[$key]['f1'] = round($sumF1 / $nClasses, 3); } } // 2) Hitung Accuracy dari confusion_matrix_{key}.csv $confusionPath = storage_path("app/public/confusion_matrix_{$key}.csv"); $confusionData = []; if (file_exists($confusionPath)) { $confusionData = array_map('str_getcsv', file($confusionPath)); } if (count($confusionData) > 1) { $totalAll = 0; $sumDiagonal = 0; // Hitung total sampel foreach (array_slice($confusionData, 1) as $r) { for ($c = 1; $c < count($r); $c++) { $totalAll += (int) $r[$c]; } } // Jumlah diagonal (misal 3 kelas → sel [1][1], [2][2], [3][3]) $sumDiagonal += (int) $confusionData[1][1]; $sumDiagonal += (int) $confusionData[2][2]; $sumDiagonal += (int) $confusionData[3][3]; if ($totalAll > 0) { $metricsSummary[$key]['accuracy'] = round($sumDiagonal / $totalAll, 3); } } } @endphp
Perbandingan Metode Prediksi: Precision, F1‐Score, dan Akurasi
{{-- ================================================================ SECTION: Top Features (Tiap e‐wallet dalam satu card terpisah) ================================================================ --}}
@foreach (['dana', 'gopay', 'shopeepay'] as $key) @php // Path ke CSV: storage/app/public/top_features_{key}.csv $featuresPath = storage_path("app/public/top_features_{$key}.csv"); $featuresData = []; if (file_exists($featuresPath)) { $featuresData = array_map('str_getcsv', file($featuresPath)); } @endphp
{{-- Header Kartu dengan Gradient Soft UI --}}
{{ $key }} Top Features
{{-- Body Kartu --}}
@if (count($featuresData) > 1)
    @foreach (array_slice($featuresData, 1) as $row) {{-- Kolom pertama = nama fitur, kolom kedua = skor --}}
  • {{ $row[0] }} {{ $row[1] }}
  • @endforeach
@else
File top_features_{{ $key }}.csv tidak ditemukan atau kosong.
@endif
@endforeach
{{-- ======================================================================== --}} @endsection @push('scripts') @endpush