@extends('admin.layouts.app') @section('title', 'Model Naive Bayes') @php $dataLatih = $dataLatihBalanced; @endphp @section('content')

Model Naive Bayes

Pilih tab untuk melihat prior dan likelihood per kelas {{-- ===================== --}} {{-- NAV TABS --}} {{-- ===================== --}} {{-- ===================== --}} {{-- TAB CONTENT --}} {{-- ===================== --}}
@foreach($modelNaiveBayes as $class => $data)
{{-- Prior --}}

Prior P ({{ $class === 'lolos' ? 'Lulus' : ($class === 'tidak' ? 'Tidak Lulus' : ucwords($class)) }}): {{ number_format($data['prior'], 2) }}

Jumlah Data: (Lolos: {{ $dataLatih->where('status_label', 'lolos')->count() }}) (Tidak Lolos: {{ $dataLatih->where('status_label', 'tidak')->count() }}) (Total: {{ $dataLatih->count() }})

{{-- Accordion Rumus & Perhitungan --}}

Rumus Prior:
P(H) = Jumlah data kelas H / Total data

Rumus Likelihood:
P(Xi | H) = Jumlah Xi dalam H / Jumlah data H

@foreach($data['likelihood'] as $attr => $values) {{-- Label atribut --}} @php $attrLabelMap = [ 'iq_cat' => 'Tes IQ', ]; $attrLabel = $attrLabelMap[$attr] ?? strtoupper($attr); @endphp @foreach($values as $val => $prob) @php $totalClass = $dataLatih->where('status_label', $class)->count(); $countVal = $dataLatih ->where('status_label', $class) ->where($attr, $val) ->count(); @endphp

Contoh:
Misal atribut {{ $attrLabel }} = {{ strtoupper($val) }}  dan kelas {{ $class === 'lolos' ? 'Lulus' : 'Tidak Lulus' }}:
- Jumlah {{ $class === 'lolos' ? 'Lulus' : 'Tidak Lulus' }} = {{ $totalClass }}
- Jumlah nilai {{ strtoupper($val) }} dalam kelas = {{ $countVal }}
P({{ $attrLabel }} = {{ strtoupper($val) }} | {{ $class === 'lolos' ? 'Lulus' : 'Tidak Lulus' }}) = {{ $countVal }} / {{ $totalClass }}

@break {{-- cukup satu contoh saja --}} @endforeach @break @endforeach
{{-- Likelihood per atribut --}}

Likelihood

@foreach($data['likelihood'] as $attr => $values) @php $attrLabelMap = [ 'family_cat' => 'KONDISI KELUARGA', 'age_cat' => 'UMUR', 'iq_cat' => 'NILAI TES IQ', 'personal_cat' => 'NILAI TES KEPRIBADIAN', ]; $attrLabel = $attrLabelMap[$attr] ?? strtoupper(str_replace('-', ' ', $attr)); @endphp

@foreach($values as $val => $prob) {{-- @dd($attr, $values, $val, $dataLatih->first()) --}} @php // Hitung jumlah data latih dengan nilai $val di kelas $class $countVal = $dataLatih->where('status_label', $class)->where($attr, $val)->count(); @endphp @endforeach
NILAI JUMLAH P(X | {{ strtoupper($class === 'lolos' ? 'LOLOS' : 'TIDAK LOLOS') }})
{{ strtoupper(str_replace('-', ' ', $val)) }} {{ $countVal }} {{ number_format($prob, 2) }}
@endforeach
@endforeach
@endsection