@@ -1187,3 +1187,97 @@ Here is the flowchart of ``show_summary_report``.
11871187 # add the score
11881188 self .quark_analysis.score_sum += score
11891189
1190+ show_label_report
1191+ ===============
1192+
1193+ **The algorithm of show_label_report **
1194+
1195+ The function ``show_label_report `` generates a tabular report that summarizes statistical information.
1196+
1197+ Here is the process of ``show_label_report ``.
1198+
1199+ .. code-block :: TEXT
1200+
1201+ 1. Clear label_report_table and initializes label_desc.
1202+
1203+ 2. Iterate through the all_labels dictionary.
1204+
1205+ 3. Calculate the maximum, average, and standard deviation of the confidence values for each label.
1206+
1207+ 4. Check if table_version is max.
1208+ - If true, set table header for table_version is max.
1209+ - If false, set table header for table_version is not max.
1210+
1211+ Here is the flowchart of ``show_label_report ``.
1212+
1213+ .. image :: https://i.imgur.com/uT0RuB8.png
1214+
1215+
1216+ **The code of show_label_report **
1217+
1218+
1219+ .. code :: python
1220+
1221+ def show_label_report (self , rule_path , all_labels , table_version ):
1222+ """
1223+ Show the report based on label, last column represents max confidence for that label
1224+ :param rule_path: the path where may be present the file label_desc.csv.
1225+ :param all_labels: dictionary containing label:<array of confidence values associated to that label>
1226+ :return: None
1227+ """
1228+ label_desc = {}
1229+ # clear table to manage max/detail version
1230+ self .quark_analysis.label_report_table.clear()
1231+ if os.path.isfile(os.path.join(rule_path, " label_desc.csv" )):
1232+ # associate to each label a description
1233+ col_list = [" label" , " description" ]
1234+ # csv file on form <label,description>
1235+ # put this file in the folder of rules (it must not be a json file since it could create conflict with management of rules)
1236+ # remove temporarily
1237+ # df = pd.read_csv(
1238+ # os.path.join(rule_path, "label_desc.csv"), usecols=col_list
1239+ # )
1240+ #
1241+ # label_desc = dict(zip(df["label"], df["description"]))
1242+
1243+ for label_name in all_labels:
1244+ confidences = np.array(all_labels[label_name])
1245+
1246+ if table_version == " max" :
1247+ self .quark_analysis.label_report_table.field_names = [
1248+ " Label" ,
1249+ " Description" ,
1250+ " Number of rules" ,
1251+ " MAX Confidence %" ,
1252+ ]
1253+ self .quark_analysis.label_report_table.add_row(
1254+ [
1255+ green(label_name),
1256+ yellow(label_desc.get(label_name, " -" )),
1257+ (len (confidences)),
1258+ red(np.max(confidences)),
1259+ ]
1260+ )
1261+ else :
1262+ self .quark_analysis.label_report_table.field_names = [
1263+ " Label" ,
1264+ " Description" ,
1265+ " Number of rules" ,
1266+ " MAX Confidence %" ,
1267+ " AVG Confidence" ,
1268+ " Std Deviation" ,
1269+ " # of Rules with Confidence >= 80%" ,
1270+ ]
1271+ self .quark_analysis.label_report_table.add_row(
1272+ [
1273+ green(label_name),
1274+ yellow(label_desc.get(label_name, " -" )),
1275+ (len (confidences)),
1276+ red(np.max(confidences)),
1277+ magenta(round (np.mean(confidences), 2 )),
1278+ lightblue(round (np.std(confidences), 2 )),
1279+ lightyellow(np.count_nonzero(confidences >= 80 )),
1280+ ]
1281+ )
1282+
1283+
0 commit comments