@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 // Daftar e-wallet yang ingin kita tampilkan $wallets = ['dana', 'gopay', 'shopeepay']; // Kita akan menyimpan struktur seperti: // $metricsDetail['dana'] = [ // 'labels' => ['Netral','Positif','Negatif'], // 'precision' => [0.812, 0.902, 0.748], // 'recall' => [0.800, 0.889, 0.765], // 'f1' => [0.806, 0.895, 0.756], // ]; $metricsDetail = []; // Kelas‐kelas yang ingin kita plot urutannya: netral → positif → negatif $kelasUrut = ['netral', 'positif', 'negatif']; foreach ($wallets as $key) { // Nama file CSV mirip: evaluation_metrics_full{key}.csv // Note: untuk 'shopeepay', file Anda pakai 'shopee' bukan 'shopeepay'? // Di contoh awal Anda, yang di‐upload adalah evaluation_metrics_fullshopee.csv, // maka gunakan $fileKey='shopee' bukan 'shopeepay'. $fileKey = $key; $pathCsv = storage_path("app/public/evaluation_metrics_full{$fileKey}.csv"); $rows = []; if (file_exists($pathCsv)) { // Baca setiap baris kemudian pecah jadi array per kolom $rows = array_map('str_getcsv', file($pathCsv)); } // Inisialisasi struktur kosong $metricsDetail[$key] = [ 'labels' => [], 'precision' => [], 'recall' => [], 'f1' => [], ]; if (count($rows) > 1) { // Baris 0: header → abaikan. Mulai dari baris 1. // Kita ingin memastikan tiap kelas ('netral','positif','negatif') ada, dan urutannya sesuai $kelasUrut. // Bisa saja di CSV urutannya sudah sama, tapi kita paksa urut sesuai $kelasUrut. // Buat map nama kelas ke indeks baris $mapRowByKelas = []; foreach (array_slice($rows, 1) as $r) { // Asumsikan kolom 0 adalah nama kelas, kolom 2 precision, kolom 3 recall, kolom 4 f1-score $namaKelas = strtolower(trim($r[0])); $mapRowByKelas[$namaKelas] = $r; } foreach ($kelasUrut as $kelas) { if (isset($mapRowByKelas[$kelas])) { $r = $mapRowByKelas[$kelas]; // Ambil nilai ke‐2 (precision), ke‐3 (recall), ke‐4 (f1‐score) // Hati‐hati: format CSV kadang ada kolom kosong di indeks 1 → kita gunakan r[2], r[3], r[4]. $precision = isset($r[2]) ? (float) $r[2] : 0; $recall = isset($r[3]) ? (float) $r[3] : 0; $f1score = isset($r[4]) ? (float) $r[4] : 0; // Push ke dalam array $metricsDetail[$key]['labels'][] = ucfirst($kelas); $metricsDetail[$key]['precision'][] = round($precision, 3); $metricsDetail[$key]['recall'][] = round($recall, 3); $metricsDetail[$key]['f1'][] = round($f1score, 3); } else { // Jika suatu kelas tidak ditemukan di CSV, isi 0. $metricsDetail[$key]['labels'][] = ucfirst($kelas); $metricsDetail[$key]['precision'][] = 0; $metricsDetail[$key]['recall'][] = 0; $metricsDetail[$key]['f1'][] = 0; } } } } @endphp
@foreach ($wallets as $key) @php // Ubah key menjadi judul yang lebih enak (Dana, Gopay, Shopeepay) $judul = ucfirst($key); @endphp
Metrik Klasifikasi: {{ $judul }}
{{-- Canvas untuk Chart.js --}}
@endforeach
{{-- ================================================================ 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