MCPcopy Create free account
hub / github.com/logpai/logparser / evaluate

Function evaluate

logparser/utils/evaluator.py:21–50  ·  view source on GitHub ↗

Evaluation function to benchmark log parsing accuracy Arguments --------- groundtruth : str file path of groundtruth structured csv file parsedresult : str file path of parsed structured csv file Returns ------- f_measure :

(groundtruth, parsedresult)

Source from the content-addressed store, hash-verified

19
20
21def evaluate(groundtruth, parsedresult):
22 """Evaluation function to benchmark log parsing accuracy
23
24 Arguments
25 ---------
26 groundtruth : str
27 file path of groundtruth structured csv file
28 parsedresult : str
29 file path of parsed structured csv file
30
31 Returns
32 -------
33 f_measure : float
34 accuracy : float
35 """
36 df_groundtruth = pd.read_csv(groundtruth)
37 df_parsedlog = pd.read_csv(parsedresult)
38 # Remove invalid groundtruth event Ids
39 non_empty_log_ids = df_groundtruth[~df_groundtruth["EventId"].isnull()].index
40 df_groundtruth = df_groundtruth.loc[non_empty_log_ids]
41 df_parsedlog = df_parsedlog.loc[non_empty_log_ids]
42 (precision, recall, f_measure, accuracy) = get_accuracy(
43 df_groundtruth["EventId"], df_parsedlog["EventId"]
44 )
45 print(
46 "Precision: {:.4f}, Recall: {:.4f}, F1_measure: {:.4f}, Parsing_Accuracy: {:.4f}".format(
47 precision, recall, f_measure, accuracy
48 )
49 )
50 return f_measure, accuracy
51
52
53def get_accuracy(series_groundtruth, series_parsedlog, debug=False):

Callers

nothing calls this directly

Calls 2

get_accuracyFunction · 0.85
formatMethod · 0.80

Tested by

no test coverage detected