secure_learning.models.common_gradient_forms module¶
Provides classes for computing the gradient of objective functions
- class secure_learning.models.common_gradient_forms.GradientFunction(*args, **kwargs)[source]¶
Bases:
Protocol
Class for objective function.
- class secure_learning.models.common_gradient_forms.WeightedDifferencesGradient(predictive_func)[source]¶
Bases:
GradientFunction
Class for computing the gradient of objective functions. The gradient is assumed to have the following form: $$g(X, y, w) = X^T (f(X, w) - y)$$
We refer to $f$ as the predictive function.
- __call__(X, y, coef_, grad_per_sample=False, weights_list=None)[source]¶
Evaluate the gradient from the given parameters.
Note that this function calculates the gradient as if the input data consists out of all data samples. That is, it does not incorporate coefficients for gradients of partial input data.
- Parameters:
X (
List
[List
[SecureFixedPoint
]]) – Independent variablesy (
List
[SecureFixedPoint
]) – Dependent variablescoef – Current coefficients vector
grad_per_sample (
bool
) – Return a list with gradient per sample instead of aggregated (summed) gradientweights_list (
Optional
[List
[SecureFixedPoint
]]) – List of class weights to scale the prediction error by, defaults to None
- Return type:
Union
[List
[SecureFixedPoint
],List
[List
[SecureFixedPoint
]]]- Returns:
Gradient of objective function as specified in class docstring, evaluated from the provided parameters