This commit is contained in:
Prayoga K. I. 2026-07-09 18:55:00 +05:30
parent b815e90de2
commit 3641d93a4f
9 changed files with 91 additions and 38 deletions

View File

@ -169,10 +169,10 @@ #### Cara Kerja (Saat Ini)
['id' => 2, 'penyakit_id' => 2, 'kode' => 'R2', 'gejala_ids' => [12, 5, 6]], // P02 - Neurospora
['id' => 3, 'penyakit_id' => 3, 'kode' => 'R3', 'gejala_ids' => [10, 5, 6]], // P03 - Mucor
['id' => 4, 'penyakit_id' => 4, 'kode' => 'R4', 'gejala_ids' => [11, 22, 5]], // P04 - Penicilium
['id' => 5, 'penyakit_id' => 5, 'kode' => 'R5', 'gejala_ids' => [1, 9, 13, 21]], // P05 - Pseudomonas
['id' => 5, 'penyakit_id' => 5, 'kode' => 'R5', 'gejala_ids' => [1, 9, 13, 15, 16, 21]], // P05 - Pseudomonas
['id' => 6, 'penyakit_id' => 6, 'kode' => 'R6', 'gejala_ids' => [22, 5, 8]], // P06 - Chaetomium
['id' => 7, 'penyakit_id' => 7, 'kode' => 'R7', 'gejala_ids' => [14, 23, 19]], // P07 - Coprinus
['id' => 8, 'penyakit_id' => 8, 'kode' => 'R8', 'gejala_ids' => [8, 23, 19]], // P08 - Tikus
['id' => 8, 'penyakit_id' => 8, 'kode' => 'R8', 'gejala_ids' => [8, 17, 5]], // P08 - Tikus
['id' => 9, 'penyakit_id' => 9, 'kode' => 'R9', 'gejala_ids' => [1, 2, 24]], // P09 - Lalat
['id' => 10, 'penyakit_id' => 10, 'kode' => 'R10','gejala_ids' => [4, 18, 24]], // P10 - Tunggu/Gurem
];
@ -191,13 +191,13 @@ #### Hubungan Rule dengan Relasi CF
| R1 | P01 | G12, G18, G06, G07 | G12(1.0), G18(0.8), G06(0.6), G07(0.8) |
| R2 | P02 | G13, G06, G07 | G13(1.0), G06(0.6), G07(0.8) |
| R3 | P03 | G11, G06, G07 | G11(1.0), G06(0.6), G07(0.8) |
| R4 | P04 | G12, G23, G06 | G12(1.0), G23(0.8), G06(0.6) |
| R5 | P05 | G01, G10, G14, G22 | G01(1.0), G10(0.8), G14(0.8), G22(0.8) |
| R4 | P04 | G12, G23, G06 | G12(1.0), G23(0.8), G06(0.8) |
| R5 | P05 | G01, G10, G14, G16, G17, G22 | G01(1.0), G10(0.8), G14(0.8), G16(0.4), G17(0.6), G22(0.8) |
| R6 | P06 | G23, G06, G09 | G23(1.0), G06(0.6), G09(0.6) |
| R7 | P07 | G15, G24, G20 | G15(1.0), G24(0.8), G20(0.6) |
| R8 | P08 | G09, G24, G20 | G09(1.0), G24(0.8), G20(0.6) |
| R9 | P09 | G01, G02, G25 | G01(1.0), G02(0.8), G25(0.8) |
| R10 | P10 | G05, G19, G25 | G05(1.0), G19(0.8), G25(0.8) |
| R8 | P08 | G09, G18, G06 | G09(0.8), G18(0.8), G06(0.6) |
| R9 | P09 | G01, G02, G25 | G01(0.6), G02(0.6), G25(0.8) |
| R10 | P10 | G05, G19, G25 | G05(0.8), G19(0.8), G25(0.6) |
---
@ -219,7 +219,7 @@ #### Struktur Pohon (Saat Ini)
│ └── G02 (Berbau Asam) → P09
├── G23 (Bau Menyengat) ─────────└── G09 (Berlendir) → P06
├── G15 (Kepala Susu Kerdil) ────└── G24 (Warna Tidak Seragam) → P07
├── G09 (Berlendir) ─────────────└── G20 (Miselium Tidak) → P08
├── G09 (Berlendir) ─────────────└── G18 (Kerusakan Tubuh Buah) → P08
└── G05 (Pertumbuhan Terganggu) ─└── G19 (Kontaminan) → P10
```

View File

@ -93,8 +93,8 @@ class ForwardChainingService
'name' => 'Baglog Rusak',
'children' => [
[
'symptom_id' => 20,
'name' => 'Jamur Rontok',
'symptom_id' => 18,
'name' => 'Kerusakan Tubuh Buah',
'penyakit_ids' => [8]
]
]
@ -176,6 +176,10 @@ public function findMatchingDiseases(array $selectedGejalaIds): array
$matchingPenyakitIds = [];
foreach ($rules as $penyakitId => $ruleGejalaIds) {
// Exact match: jumlah gejala harus sama dan semua gejala penyakit ada di pilihan user
if (count($ruleGejalaIds) !== count($selectedGejalaIds)) {
continue;
}
$match = true;
foreach ($ruleGejalaIds as $gejalaId) {
if (!in_array($gejalaId, $selectedGejalaIds)) {

View File

@ -15,14 +15,14 @@ public function run(): void
$gejala = [
['kode' => 'G01', 'nama' => 'Jamur tiram terlihat membusuk', 'kategori' => 'Warna & Kondisi'],
['kode' => 'G02', 'nama' => 'Jamur tiram terlihat keriput', 'kategori' => 'Warna & Kondisi'],
['kode' => 'G03', 'nama' => 'Jamur tiram terlihat berlendir', 'kategori' => 'Kondisi'],
['kode' => 'G03', 'nama' => 'Jamur tiram berubah warna menjadi kecoklatan', 'kategori' => 'Kondisi'],
['kode' => 'G04', 'nama' => 'Batang jamur tiram terlihat berlubang', 'kategori' => 'Kerusakan'],
['kode' => 'G05', 'nama' => 'Jamur tiram hanya tumbuh kecil', 'kategori' => 'Pertumbuhan'],
['kode' => 'G06', 'nama' => 'Pertumbuhan jamur tiram lambat', 'kategori' => 'Pertumbuhan'],
['kode' => 'G07', 'nama' => 'Jamur tiram tidak tumbuh', 'kategori' => 'Pertumbuhan'],
['kode' => 'G08', 'nama' => 'Plastik baglog terlihat berlubang', 'kategori' => 'Kerusakan Baglog'],
['kode' => 'G09', 'nama' => 'Baglog/media jamur tiram rusak', 'kategori' => 'Kerusakan Baglog'],
['kode' => 'G10', 'nama' => 'Bau jamur tiram menyengat', 'kategori' => 'Aroma'],
['kode' => 'G10', 'nama' => 'Bau Jamur tiram menyengat', 'kategori' => 'Aroma'],
['kode' => 'G11', 'nama' => 'Pada media baglog terdapat noda warna hitam', 'kategori' => 'Kondisi Baglog'],
['kode' => 'G12', 'nama' => 'Pada media baglog terdapat bintik-bintik noda hijau', 'kategori' => 'Kondisi Baglog'],
['kode' => 'G13', 'nama' => 'Pada permukaan baglog terdapat tepung warna orange', 'kategori' => 'Kondisi Baglog'],

View File

@ -41,12 +41,14 @@ public function run(): void
// P04 - R4: G12 AND G23 AND G06
['penyakit_id' => 4, 'gejala_kode' => 'G12', 'cf_pakar' => 1.0],
['penyakit_id' => 4, 'gejala_kode' => 'G23', 'cf_pakar' => 0.8],
['penyakit_id' => 4, 'gejala_kode' => 'G06', 'cf_pakar' => 0.6],
['penyakit_id' => 4, 'gejala_kode' => 'G06', 'cf_pakar' => 0.8],
// P05 - R5: G01 AND G10 AND G14 AND G22
// P05 - R5: G01 AND G10 AND G14 AND G16 AND G17 AND G22
['penyakit_id' => 5, 'gejala_kode' => 'G01', 'cf_pakar' => 1.0],
['penyakit_id' => 5, 'gejala_kode' => 'G10', 'cf_pakar' => 0.8],
['penyakit_id' => 5, 'gejala_kode' => 'G14', 'cf_pakar' => 0.8],
['penyakit_id' => 5, 'gejala_kode' => 'G16', 'cf_pakar' => 0.4],
['penyakit_id' => 5, 'gejala_kode' => 'G17', 'cf_pakar' => 0.6],
['penyakit_id' => 5, 'gejala_kode' => 'G22', 'cf_pakar' => 0.8],
// P06 - R6: G23 AND G06 AND G09
@ -59,20 +61,20 @@ public function run(): void
['penyakit_id' => 7, 'gejala_kode' => 'G24', 'cf_pakar' => 0.8],
['penyakit_id' => 7, 'gejala_kode' => 'G20', 'cf_pakar' => 0.6],
// P08 - R8: G09 AND G24 AND G20
['penyakit_id' => 8, 'gejala_kode' => 'G09', 'cf_pakar' => 1.0],
['penyakit_id' => 8, 'gejala_kode' => 'G24', 'cf_pakar' => 0.8],
['penyakit_id' => 8, 'gejala_kode' => 'G20', 'cf_pakar' => 0.6],
// P08 - R8: G09 AND G18 AND G06
['penyakit_id' => 8, 'gejala_kode' => 'G09', 'cf_pakar' => 0.8],
['penyakit_id' => 8, 'gejala_kode' => 'G18', 'cf_pakar' => 0.8],
['penyakit_id' => 8, 'gejala_kode' => 'G06', 'cf_pakar' => 0.6],
// P09 - R9: G01 AND G02 AND G25
['penyakit_id' => 9, 'gejala_kode' => 'G01', 'cf_pakar' => 1.0],
['penyakit_id' => 9, 'gejala_kode' => 'G02', 'cf_pakar' => 0.8],
['penyakit_id' => 9, 'gejala_kode' => 'G01', 'cf_pakar' => 0.6],
['penyakit_id' => 9, 'gejala_kode' => 'G02', 'cf_pakar' => 0.6],
['penyakit_id' => 9, 'gejala_kode' => 'G25', 'cf_pakar' => 0.8],
// P10 - R10: G05 AND G19 AND G25
['penyakit_id' => 10, 'gejala_kode' => 'G05', 'cf_pakar' => 1.0],
['penyakit_id' => 10, 'gejala_kode' => 'G05', 'cf_pakar' => 0.8],
['penyakit_id' => 10, 'gejala_kode' => 'G19', 'cf_pakar' => 0.8],
['penyakit_id' => 10, 'gejala_kode' => 'G25', 'cf_pakar' => 0.8],
['penyakit_id' => 10, 'gejala_kode' => 'G25', 'cf_pakar' => 0.6],
];
foreach ($penyakitGejala as $pg) {

View File

@ -242,7 +242,7 @@ public function run(): void
],
[
'kode' => 'P10',
'nama' => 'Tunggu/Gurem (Hama Serangga - Acari)',
'nama' => 'Tunggu(Gurem)',
'tipe' => 'Hama Serangga',
'deskripsi' => 'Tunggu (akarid) menyerang miselium dan tunas jamur tiram. Menyebabkan jamur tumbuh kecil-kecil.',
'solusi' => json_encode([

10
dc.md
View File

@ -21,7 +21,7 @@ ## Struktur Pohon Keputusan
├── G15 (Kepala Susu Kerdil) ────└── G24 (Warna Tidak Seragam) → P07 (Coprinus spp)
├── G09 (Berlendir) ─────────────└── G20 (Miselium Tidak) → P08 (Tikus)
├── G09 (Berlendir) ─────────────└── G18 (Kerusakan Tubuh Buah) → P08 (Tikus)
└── G05 (Pertumbuhan Terganggu) ─└── G19 (Kontaminan) → P10 (Tunggu/Gurem)
```
@ -52,10 +52,10 @@ ## Flowchart Decision Tree
G15 -- T --> TD6["Tidak Terdiagnosis"]
G24_15 -- Y --> P07["P07 - Coprinus spp"]
G24_15 -- T --> TD6a["Tidak Terdiagnosis"]
G09_2{"G09"} -- Y --> G20{"G20"}
G09_2{"G09"} -- Y --> G18{"G18"}
G09_2 -- T --> TD7["Tidak Terdiagnosis"]
G20 -- Y --> P08["P08 - Tikus"]
G20 -- T --> TD7a["Tidak Terdiagnosis"]
G18 -- Y --> P08["P08 - Tikus"]
G18 -- T --> TD7a["Tidak Terdiagnosis"]
G05{"G05"} -- Y --> G19{"G19"}
G05 -- T --> TD8["Tidak Terdiagnosis"]
G19 -- Y --> P10["P10 - Tunggu/Gurem"]
@ -81,7 +81,7 @@ ## Mapping Leaf ke Penyakit
| Branch 4b | G01 | G02 | R9 | P09 — Lalat |
| Branch 5 | G23 | G09 | R6 | P06 — Chaetomium spp |
| Branch 6 | G15 | G24 | R7 | P07 — Coprinus spp |
| Branch 7 | G09 | G20 | R8 | P08 — Tikus |
| Branch 7 | G09 | G18 | R8 | P08 — Tikus |
| Branch 8 | G05 | G19 | R10 | P10 — Tunggu/Gurem |
## Primary Symptoms

View File

@ -59,10 +59,10 @@ ### Aturan (Rule) Sistem Pakar
| R2 | **Neurospora spp** (P02) | G13, G06, G07 |
| R3 | **Mucor spp** (P03) | G11, G06, G07 |
| R4 | **Penicilium spp** (P04) | G12, G23, G06 |
| R5 | **Pseudomonas tolaasii** (P05) | G01, G10, G14, G22 |
| R5 | **Pseudomonas tolaasii** (P05) | G01, G10, G14, G16, G17, G22 |
| R6 | **Chaetomium spp** (P06) | G23, G06, G09 |
| R7 | **Coprinus spp** (P07) | G15, G24, G20 |
| R8 | **Tikus** (P08) | G09, G24, G20 |
| R8 | **Tikus** (P08) | G09, G18, G06 |
| R9 | **Lalat** (P09) | G01, G02, G25 |
| R10 | **Tunggu/Gurem** (P10) | G05, G19, G25 |
@ -177,7 +177,7 @@ ### Contoh 4: Penicilium spp (P04) — Partial Match
|---------|--------|----------|---------|-----------|
| 1 | G12 | 1.0 | 0.8 | $1.0 \times 0.8 = 0.80$ |
| 2 | G23 | 0.8 | 0.6 | $0.8 \times 0.6 = 0.48$ |
| 3 | G06 | 0.6 | 0.8 | $0.6 \times 0.8 = 0.48$ |
| 3 | G06 | 0.8 | 0.8 | $0.8 \times 0.8 = 0.64$ |
> **Catatan:** Untuk penyakit **Trichoderma spp** (P01) yang juga memiliki G12, perhitungan akan berbeda karena gejala yang cocok tidak sama.
@ -187,11 +187,11 @@ ### Contoh 4: Penicilium spp (P04) — Partial Match
$$CF_2 = 0.80 + 0.48 \times (1 - 0.80) = 0.896$$
$$CF_3 = 0.896 + 0.48 \times (1 - 0.896) = 0.94592$$
$$CF_3 = 0.896 + 0.64 \times (1 - 0.896) = 0.96256$$
$$CF_{\%} = 0.94592 \times 100 = 94.59\%$$
$$CF_{\%} = 0.96256 \times 100 = 96.26\%$$
**Kesimpulan:** **Penicilium spp** (P04) dengan keyakinan **94.59%** — Sangat Yakin
**Kesimpulan:** **Penicilium spp** (P04) dengan keyakinan **96.26%** — Sangat Yakin
### Contoh 5: Multipenyakit (CF User Berbeda)
@ -217,16 +217,16 @@ ### Contoh 5: Multipenyakit (CF User Berbeda)
**P09 — Lalat** (memiliki G01)
$$\text{Hanya 1 gejala: } CF = 1.0 \times 0.6 = 0.60$$
$$\text{Hanya 1 gejala: } CF = 0.6 \times 0.6 = 0.36$$
$$CF_{\%} = 60\%$$
$$CF_{\%} = 36\%$$
**Hasil Akhir:**
| Peringkat | Penyakit | Keyakinan | Status |
|-----------|----------|-----------|--------|
| 1 | **Pseudomonas tolaasii** (P05) | 90.21% | Sangat Yakin |
| 2 | **Lalat** (P09) | 60% | Cukup Yakin |
| 2 | **Lalat** (P09) | 36% | Tidak Yakin |
### Tabel Kategori Keyakinan

View File

@ -46,6 +46,48 @@ class="rounded-3xl shadow-2xl w-full max-w-md object-cover border-4 border-green
</div>
</section>
<!-- Table Penyakit-Gejala -->
<section class="bg-white py-16 border-t border-green-100">
<div class="container mx-auto px-6 md:px-10">
<h2 class="mb-2 text-center text-3xl font-bold text-gray-900">Relasi Penyakit & Gejala</h2>
<p class="mb-10 text-center text-gray-600">Daftar penyakit jamur tiram beserta gejala terkait dan bobot CF Pakar.</p>
<div class="mx-auto max-w-6xl overflow-x-auto rounded-2xl border border-green-100 shadow-lg">
<table class="w-full text-left text-sm">
<thead>
<tr class="bg-green-600 text-white">
<th class="px-4 py-3 font-semibold">Kode</th>
<th class="px-4 py-3 font-semibold">Nama Penyakit</th>
<th class="px-4 py-3 font-semibold">Gejala Terkait</th>
</tr>
</thead>
<tbody class="divide-y divide-green-100">
@foreach ($penyakits as $penyakit)
<tr class="transition hover:bg-green-50">
<td class="px-4 py-3 font-mono font-bold text-green-700">{{ $penyakit->kode }}</td>
<td class="px-4 py-3 font-semibold text-gray-800">{{ $penyakit->nama }}</td>
<td class="px-4 py-3">
@if ($penyakit->gejala->isNotEmpty())
<ul class="list-inside list-disc space-y-1">
@foreach ($penyakit->gejala as $gejala)
<li>
<span class="font-mono text-green-600">{{ $gejala->kode }}</span>
<span class="text-gray-700"> {{ $gejala->nama }}</span>
</li>
@endforeach
</ul>
@else
<span class="text-gray-400"></span>
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</section>
<!-- Footer -->
<footer class="text-center text-gray-600 py-6 border-t border-green-100 bg-green-50">
&copy; 2025 <span class="text-green-700 font-semibold">Sistem Pakar Jamur Tiram</span> Semua Hak Dilindungi tomihartanto.

View File

@ -12,7 +12,10 @@
*/
Route::get('/', function () {
return view('layouts.home'); // ✅ file: resources/views/layouts/home.blade.php
$penyakits = App\Models\Penyakit::with(['gejala' => function ($query) {
$query->orderBy('kode');
}])->orderBy('kode')->get();
return view('layouts.home', compact('penyakits'));
});
/*
@ -60,3 +63,5 @@
Route::get('/tentang', function () {
return view('layouts.tentang'); // ✅ file: resources/views/layouts/tentang.blade.php
});