holisticai.security.metrics.shapr_score#

holisticai.security.metrics.shapr_score(y_train: Series, y_test: Series, y_pred_train: Series, y_pred_test: Series, batch_size=500, train_size=1.0) Array[source]#

Compute the SHAPr membership privacy risk metric [1] for the given classifier and training set.

Parameters

y_train: pd.Series

(nb_samples, nb_classes) or indices of shape (nb_samples,). Target values (class labels) of x_train, one-hot-encoded.

y_test: pd.Series

(nb_samples, nb_classes) or indices of shape (nb_samples,). Target values (class labels) of x_test, one-hot-encoded.

y_pred_train: pd.Series

(nb_samples, nb_classes) or indices of shape (nb_samples,). Predicted values (class labels) of x_train, one-hot-encoded.

y_pred_test: pd.Series

(nb_samples, nb_classes) or indices of shape (nb_samples,). Predicted values (class labels) of x_test, one-hot-encoded.

batch_size: int, default=100

The number of samples to process in each batch.

train_size: float, default=1.0

The fraction of the training set to use for the k-nearest neighbors search

Returns

float: The higher the value, the higher the privacy leakage for that sample. Any value above 0 should be considered a privacy leak.

Reference#