Feat: Update recommendation system weights to match ROC scores from thesis analysis

- Minat (Interest): 0.456 (45.6%)
- Preferensi Studi (Study Preference): 0.256 (25.6%)
- Nilai Akademik (Academic Score): 0.156 (15.6%)
- Cita-cita (Career Aspiration): 0.090 (9.0%)
- Prestasi (Achievement): 0.040 (4.0%)

Updated weights in RekomendasiController.php at:
- Line 259: Default weights assignment
- Line 263: Fallback weights
- Line 268-278: Weight normalization logic

All 49 tests passing (122 assertions) 
This commit is contained in:
KakaPatria 2026-05-13 15:53:03 +07:00
parent e45b75531b
commit a7e4d0e5f0
2 changed files with 7 additions and 5 deletions

1
.phpunit.result.cache Normal file
View File

@ -0,0 +1 @@
{"version":2,"defects":[],"times":{"Tests\\Unit\\ExampleTest::test_that_true_is_true":1.142,"Tests\\Unit\\RekomendasiAlgorithmTest::test_minat_mapping_logika_komputer":1.83,"Tests\\Unit\\RekomendasiAlgorithmTest::test_minat_mapping_alam_tanaman":0.001,"Tests\\Unit\\RekomendasiAlgorithmTest::test_minat_mapping_bisnis":0.001,"Tests\\Unit\\RekomendasiAlgorithmTest::test_nilai_kategori_tinggi":0,"Tests\\Unit\\RekomendasiAlgorithmTest::test_nilai_kategori_sedang":0,"Tests\\Unit\\RekomendasiAlgorithmTest::test_nilai_kategori_rendah":0,"Tests\\Unit\\RekomendasiAlgorithmTest::test_prestasi_scoring_tinggi":0.326,"Tests\\Unit\\RekomendasiAlgorithmTest::test_prestasi_scoring_sedang":0,"Tests\\Unit\\RekomendasiAlgorithmTest::test_prestasi_scoring_minimal":0.055,"Tests\\Feature\\Auth\\AuthenticationTest::test_login_screen_can_be_rendered":9.692,"Tests\\Feature\\Auth\\AuthenticationTest::test_users_can_authenticate_using_the_login_screen":6.712,"Tests\\Feature\\Auth\\AuthenticationTest::test_users_can_not_authenticate_with_invalid_password":0.471,"Tests\\Feature\\Auth\\AuthenticationTest::test_users_can_logout":0.172,"Tests\\Feature\\Auth\\EmailVerificationTest::test_email_verification_screen_can_be_rendered":1.41,"Tests\\Feature\\Auth\\EmailVerificationTest::test_email_can_be_verified":0.494,"Tests\\Feature\\Auth\\EmailVerificationTest::test_email_is_not_verified_with_invalid_hash":0.581,"Tests\\Feature\\Auth\\PasswordConfirmationTest::test_confirm_password_screen_can_be_rendered":1.132,"Tests\\Feature\\Auth\\PasswordConfirmationTest::test_password_can_be_confirmed":0.12,"Tests\\Feature\\Auth\\PasswordConfirmationTest::test_password_is_not_confirmed_with_invalid_password":0.217,"Tests\\Feature\\Auth\\PasswordResetTest::test_reset_password_link_screen_can_be_rendered":1.654,"Tests\\Feature\\Auth\\PasswordResetTest::test_reset_password_link_can_be_requested":3.132,"Tests\\Feature\\Auth\\PasswordResetTest::test_reset_password_screen_can_be_rendered":1.884,"Tests\\Feature\\Auth\\PasswordResetTest::test_password_can_be_reset_with_valid_token":0.498,"Tests\\Feature\\Auth\\PasswordUpdateTest::test_password_can_be_updated":0.196,"Tests\\Feature\\Auth\\PasswordUpdateTest::test_correct_password_must_be_provided_to_update_password":0.175,"Tests\\Feature\\Auth\\RegistrationTest::test_registration_screen_can_be_rendered":0.204,"Tests\\Feature\\Auth\\RegistrationTest::test_new_users_can_register":0.104,"Tests\\Feature\\CrudValidationTest::test_admin_can_add_jurusan_data":0.229,"Tests\\Feature\\CrudValidationTest::test_bk_can_add_jurusan_data":0.058,"Tests\\Feature\\CrudValidationTest::test_admin_guru_bk_store_validates_email_and_password":0.206,"Tests\\Feature\\CrudValidationTest::test_rekomendasi_ipa_requires_all_ipa_scores":0.014,"Tests\\Feature\\CrudValidationTest::test_admin_student_detail_only_accepts_siswa_id":0.21,"Tests\\Feature\\ExampleTest::test_the_application_returns_a_successful_response":0.122,"Tests\\Feature\\ExplainableRecommendationTest::test_recommendation_includes_explanation":1.773,"Tests\\Feature\\ExplainableRecommendationTest::test_scoring_detail_stored_correctly":0.989,"Tests\\Feature\\ExplainableRecommendationTest::test_all_recommendations_have_explanations":0.027,"Tests\\Feature\\ExplainableRecommendationTest::test_explanation_displayed_in_view":0.021,"Tests\\Feature\\ProfileTest::test_profile_page_is_displayed":0.466,"Tests\\Feature\\ProfileTest::test_profile_information_can_be_updated":0.3,"Tests\\Feature\\ProfileTest::test_email_verification_status_is_unchanged_when_the_email_address_is_unchanged":0.216,"Tests\\Feature\\ProfileTest::test_user_can_delete_their_account":0.118,"Tests\\Feature\\ProfileTest::test_correct_password_must_be_provided_to_delete_account":0.141,"Tests\\Feature\\RekomendasiTest::test_high_math_and_coding_prefers_teknologi_informasi":0.223,"Tests\\Feature\\RekomendasiTest::test_high_language_prefers_bahasa_komunikasi":0.021,"Tests\\Feature\\UserFlowTest::test_siswa_complete_flow":1.02,"Tests\\Feature\\UserFlowTest::test_bk_complete_flow":2.378,"Tests\\Feature\\UserFlowTest::test_admin_complete_flow":2.52,"Tests\\Feature\\UserFlowTest::test_access_control":0.023}}

View File

@ -255,27 +255,28 @@ public function proses(Request $request)
$prior = 1 / $cfgCount; $prior = 1 / $cfgCount;
$logPrior = log(max($prior, $epsilon)); $logPrior = log(max($prior, $epsilon));
// Weights dan match probabilities dengan defaults // Weights dan match probabilities dengan defaults (berdasarkan ROC dari analisis)
$weights = $c['weights'] ?? ['nilai' => 0.40, 'minat' => 0.35, 'cita_cita' => 0.15, 'prestasi' => 0.10]; $weights = $c['weights'] ?? ['nilai' => 0.156, 'minat' => 0.456, 'pref' => 0.256, 'cita_cita' => 0.090, 'prestasi' => 0.040];
// Ensure weights is array // Ensure weights is array
if (!is_array($weights)) { if (!is_array($weights)) {
$weights = ['nilai' => 0.40, 'minat' => 0.35, 'cita_cita' => 0.15, 'prestasi' => 0.10]; $weights = ['nilai' => 0.156, 'minat' => 0.456, 'pref' => 0.256, 'cita_cita' => 0.090, 'prestasi' => 0.040];
} }
// Jika prestasi kosong, atribut prestasi tidak dihitung dengan normalisasi ulang // Jika prestasi kosong, atribut prestasi tidak dihitung dengan normalisasi ulang
if (!$isPrestasiFilled) { if (!$isPrestasiFilled) {
$weights['prestasi'] = 0.0; $weights['prestasi'] = 0.0;
$sumNonPrestasi = ($weights['nilai'] ?? 0) + ($weights['minat'] ?? 0) + ($weights['cita_cita'] ?? 0); $sumNonPrestasi = ($weights['nilai'] ?? 0) + ($weights['minat'] ?? 0) + ($weights['pref'] ?? 0) + ($weights['cita_cita'] ?? 0);
// Normalize weights dengan safety check // Normalize weights dengan safety check
if ($sumNonPrestasi > $epsilon) { if ($sumNonPrestasi > $epsilon) {
$weights['nilai'] = ($weights['nilai'] ?? 0) / $sumNonPrestasi; $weights['nilai'] = ($weights['nilai'] ?? 0) / $sumNonPrestasi;
$weights['minat'] = ($weights['minat'] ?? 0) / $sumNonPrestasi; $weights['minat'] = ($weights['minat'] ?? 0) / $sumNonPrestasi;
$weights['pref'] = ($weights['pref'] ?? 0) / $sumNonPrestasi;
$weights['cita_cita'] = ($weights['cita_cita'] ?? 0) / $sumNonPrestasi; $weights['cita_cita'] = ($weights['cita_cita'] ?? 0) / $sumNonPrestasi;
} else { } else {
// Fallback weights jika semua weight adalah 0 // Fallback weights jika semua weight adalah 0
$weights = ['nilai' => 0.45, 'minat' => 0.35, 'cita_cita' => 0.20]; $weights = ['nilai' => 0.156, 'minat' => 0.456, 'pref' => 0.256, 'cita_cita' => 0.238];
} }
} }