MCPcopy Create free account
hub / github.com/SpecterOps/DeepPass2 / _calculate_accuracy

Function _calculate_accuracy

test/testDeeppass2.py:96–134  ·  view source on GitHub ↗
(
    y_true,
    y_pred,
    type="strict",
    min_overlap=0.5,
    string_min_ratio=0.5,
    method="sequence",
)

Source from the content-addressed store, hash-verified

94
95
96def _calculate_accuracy(
97 y_true,
98 y_pred,
99 type="strict",
100 min_overlap=0.5,
101 string_min_ratio=0.5,
102 method="sequence",
103):
104 correct = 0
105 tot = 0
106 length = len(y_true)
107
108 if type == "strict":
109 for i in range(length):
110 if y_pred[i] == ["No Secret"]:
111 y_pred[i] =[]
112 if len(y_true[i]) == len(y_pred[i]) and set(y_true[i]) == set(y_pred[i]):
113 correct += 1
114 accuracy = correct / length
115 elif type == "string_overlap":
116 for i in range(length):
117 if y_pred[i] == ["No Secret"]:
118 y_pred[i] =[]
119 if _areEqualOverlapStrings(
120 y_true[i], y_pred[i], min_overlap, string_min_ratio
121 ):
122 correct += 1
123 accuracy = correct / length
124 elif type == "number":
125 for i in range(length):
126 tot += len(y_true[i])
127 if y_pred[i] == ["No Secret"]:
128 y_pred[i]=[]
129 for pred in y_pred[i]:
130 if pred in y_true[i]:
131 correct += 1
132 accuracy = correct / tot
133
134 return accuracy
135
136
137def _calculate_confusionmetrics(y_true, y_pred):

Callers 1

calculate_metricsFunction · 0.85

Calls 1

_areEqualOverlapStringsFunction · 0.85

Tested by

no test coverage detected