diff --git a/other_ext/kamaz_ai.py b/other_ext/kamaz_ai.py index 289a1a1..a00f24a 100644 --- a/other_ext/kamaz_ai.py +++ b/other_ext/kamaz_ai.py @@ -107,24 +107,17 @@ class KamazAI: score += self.WEIGHTS['steam_identity'] * identity_score # 2. Причина (точное совпадение) - try: - reason_score = 1.0 if report1['reasons'] == report2['reasons'] else 0.0 - score += self.WEIGHTS['reason'] * reason_score - except: - print("Skip reason calc", report1, report2) - traceback.print_exc() + reason_score = 1.0 if report1['reasons'] == report2['reasons'] else 0.0 + score += self.WEIGHTS['reason'] * reason_score # 3. Права - try: - perm_score = 0.0 - if report1['a_permition'] == report2['a_permition']: - perm_score += 0.5 - if report1['r_permition'] == report2['r_permition']: - perm_score += 0.5 - score += self.WEIGHTS['permissions'] * perm_score - except: - print("Skip permition calc", report1, report2) - traceback.print_exc() + perm_score = 0.0 + if report1['a_permition'] == report2['a_permition']: + perm_score += 0.5 + if report1['r_permition'] == report2['r_permition']: + perm_score += 0.5 + score += self.WEIGHTS['permissions'] * perm_score + # 4. Числовые поля (нормированное евклидово расстояние -> сходство) num_fields = ['a_kills', 'a_deads', 'a_seconds', 'r_kills', 'r_deads', 'r_seconds', 'online'] @@ -150,14 +143,18 @@ class KamazAI: srv_score = 1.0 if report1['srv'] == report2['srv'] else 0.0 score += self.WEIGHTS['server'] * srv_score - return score + return [score, + { + "reason_score": reason_score, + "perm_score": perm_score, + "num_similarity": num_similarity}] async def predict(self, new_report): # Вычисляем сходство со всеми историческими заявками similarities = [] for hist in self.historical_reports: - sim = await self.similarity(new_report, hist, self.numeric_stats) - similarities.append((hist['id'], sim)) + s_container = await self.similarity(new_report, hist, self.numeric_stats) + similarities.append((hist['id'], s_container[0], s_container[1])) # Сортируем по убыванию сходства similarities.sort(key=lambda x: x[1], reverse=True) @@ -167,7 +164,7 @@ class KamazAI: # Собираем все действия, назначенные на эти заявки action_counter = Counter() similar_report_ids = [] - for rid, sim in top_k: + for rid, sim, score_rate in top_k: #print(rid, sim) if sim > 0: # можно задать порог, чтобы отсечь шум similar_report_ids.append(rid) @@ -185,7 +182,7 @@ class KamazAI: }) else: # Если ни одного похожего – предложение "inspect" по умолчанию - suggestions.append({'action': 'inspect', 'confidence': 1.0}) + suggestions.append({'action': 'none', 'confidence': 1.0}) return { 'suggestions': suggestions, @@ -204,7 +201,8 @@ class Extension: 'author_kick': "кикнуть автора репорта", 'mute': "замьютить игрока", 'unban': "разбанить игрока если тот в бане, ебанутое решение", - 'author_inspect': 'глянуть профиль автора репорта' + 'author_inspect': 'глянуть профиль автора репорта', + 'none': 'ничего не делать, лучше не лезть' } def __init__(self, core):