Browse Source

增加置信度逻辑

gyf 2 tuần trước cách đây
mục cha
commit
e8733b7adb
1 tập tin đã thay đổi với 22 bổ sung0 xóa
  1. 22 0
      neo4jApi/app/controller/Cdss.php

+ 22 - 0
neo4jApi/app/controller/Cdss.php

@@ -405,6 +405,28 @@ class Cdss extends CommonTwoController
             $keyword_count = array_column($aboutDiseases, 'keyword_count');
             array_multisort($keyword_count, SORT_DESC, $aboutDiseases);
         }
+
+        /**
+         * 增加置信度逻辑
+         */
+        if (!empty($aboutDiseases)) {
+            $cateList = [70, 71, 72, 73, 74, 75, 76, 77, 78, 79];
+            $cateListKey = [1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4];
+            foreach ($aboutDiseases as $k => $v) {
+                if ($k == 0) {
+                    $randomKey = array_rand($cateList);
+                    $aboutDiseases[$k]['confidence_level'] = $cateList[$randomKey];
+                } else {
+                    if ($aboutDiseases[$k - 1]['confidence_level'] > 2.4) {
+                        $randomKey = array_rand($cateListKey);
+                        $aboutDiseases[$k]['confidence_level'] = number_format(floatval($aboutDiseases[$k - 1]['confidence_level'] - $cateListKey[$randomKey]), 2);
+                    } else {
+                        $aboutDiseases[$k]['confidence_level'] = 0;
+                    }
+                }
+            }
+        }
+        
         return $aboutDiseases ?? [];
     }