mirror of
https://github.com/IBM/ai-privacy-toolkit.git
synced 2026-07-02 16:01:00 +02:00
Support additional use cases for data (#46)
* Make ART black box classifier not apply preprocessing to data * Add option to store predictions (in addition to x,y) in Dataset and Data classes
This commit is contained in:
parent
e25e58b253
commit
00f9c16863
6 changed files with 139 additions and 62 deletions
41
tests/test_datasets.py
Normal file
41
tests/test_datasets.py
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import pytest
|
||||
import numpy as np
|
||||
|
||||
from apt.utils.datasets import Data, DatasetWithPredictions
|
||||
from apt.utils import dataset_utils
|
||||
|
||||
|
||||
def test_dataset_predictions():
|
||||
(x_train, y_train), (_, _) = dataset_utils.get_iris_dataset_np()
|
||||
pred = np.array([[0.23, 0.56, 0.21] for i in range(105)])
|
||||
|
||||
dataset = DatasetWithPredictions(pred)
|
||||
data = Data(train=dataset)
|
||||
|
||||
new_pred = data.get_train_set().get_predictions()
|
||||
|
||||
assert np.equal(pred, new_pred).all()
|
||||
|
||||
|
||||
def test_dataset_predictions_x():
|
||||
(x_train, y_train), (_, _) = dataset_utils.get_iris_dataset_np()
|
||||
pred = np.array([[0.23, 0.56, 0.21] for i in range(105)])
|
||||
|
||||
dataset = DatasetWithPredictions(pred, x=x_train)
|
||||
data = Data(train=dataset)
|
||||
|
||||
new_pred = data.get_train_set().get_predictions()
|
||||
|
||||
assert np.equal(pred, new_pred).all()
|
||||
|
||||
|
||||
def test_dataset_predictions_y():
|
||||
(x_train, y_train), (_, _) = dataset_utils.get_iris_dataset_np()
|
||||
pred = np.array([[0.23, 0.56, 0.21] for i in range(105)])
|
||||
|
||||
dataset = DatasetWithPredictions(pred, x=x_train, y=y_train)
|
||||
data = Data(train=dataset)
|
||||
|
||||
new_pred = data.get_train_set().get_predictions()
|
||||
|
||||
assert np.equal(pred, new_pred).all()
|
||||
Loading…
Add table
Add a link
Reference in a new issue