DifferentialPrivacySelector<T>

Models & Types ยท AiDotNet.Preprocessing.FeatureSelection.Privacy

Differential Privacy based Feature Selection.

Inheritance: TransformerBase<T, Matrix<T>, Matrix<T>> โ†’ DifferentialPrivacySelector<T>

Implements: IFixedCountFeatureSelector<T>, ISupervisedFeatureSelector<T>

For Beginners

Differential privacy adds calibrated randomness to the feature choice so that whether any single individual is in the dataset barely changes which features get selected. Scale the features and target to known bounds (for example from their documented domains, not from the data itself) and pass those bounds; values outside them are clipped so the privacy guarantee always holds.

How It Works

Selects features with the exponential mechanism (McSherry and Talwar 2007) so that the selected set is epsilon-differentially private with respect to replacing one row of the data. The utility of feature j is the absolute covariance |cov(x_j, y)| of the feature and target after clipping them to [-featureBound, featureBound] and [-targetBound, targetBound]. With values in those ranges, replacing one of the n rows changes the mean of x_j y by at most 2 B_x B_y / n and the product of the means by at most 4 B_x B_y / n, so the utility has sensitivity Delta = 6 B_x B_y / n.

The k features are chosen by k rounds of the exponential mechanism, each with budget epsilon / k over the features not chosen yet, selecting feature j with probability proportional to exp((epsilon / k) u_j / (2 Delta)); by sequential composition the whole selection is epsilon-DP. The rounds are sampled in one shot with the Gumbel-max trick: adding Gumbel noise of scale 2 k Delta / epsilon to every utility and taking the k largest has the same distribution (Durfee and Rogers 2019). Only the selected indices are released; the noisy utilities are not.

Constructors

Constructor Summary
DifferentialPrivacySelector(int nFeaturesToSelect, double epsilon, int? randomState, int[] columnIndices, double featureBound, double targetBound)

Properties

Property Summary
bool SupportsInverseTransform { get; }
double Epsilon { get; } The total privacy budget of the selection.
double FeatureBound { get; } Features are clipped to [-FeatureBound, FeatureBound] before the utilities are computed.
double NoiseScale { get; } The Gumbel noise scale 2 k Delta / epsilon used by the last fit (0 before fitting).
double TargetBound { get; } The target is clipped to [-TargetBound, TargetBound] before the utilities are computed.
int NFeaturesToSelect { get; }
int[] SelectedIndices { get; }

Methods

Method Summary
Matrix<T> FitTransform(Matrix<T> data, Vector<T> target)
bool[] GetSupportMask()
string[] GetFeatureNamesOut(string[] inputFeatureNames)
void Fit(Matrix<T> data, Vector<T> target)