mirror of
https://github.com/IBM/ai-privacy-toolkit.git
synced 2026-06-14 15:25:12 +02:00
Add tests for single label binary pytorch models
Signed-off-by: abigailt <abigailt@il.ibm.com>
This commit is contained in:
parent
aa65f0f6f2
commit
a8ec87f922
2 changed files with 170 additions and 42 deletions
|
|
@ -235,7 +235,10 @@ class Model(metaclass=ABCMeta):
|
|||
predicted = expit(predicted)
|
||||
predicted[predicted < binary_threshold] = 0
|
||||
predicted[predicted >= binary_threshold] = 1
|
||||
return np.count_nonzero(y == predicted) / (predicted.shape[0] * y.shape[1])
|
||||
if len(y.shape) > 1:
|
||||
return np.count_nonzero(y == predicted) / (predicted.shape[0] * y.shape[1])
|
||||
else:
|
||||
return np.count_nonzero(y == predicted.reshape(-1)) / (predicted.shape[0])
|
||||
else:
|
||||
raise NotImplementedError('score method not implemented for output type: ', self.output_type)
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue