venumML.linear_models.regression.logistic_regression
class
EncryptedLogisticRegression:
Logistic Regression model that supports encrypted computations.
Attributes
- _context (object): Encryption context to perform encrypted operations.
- _coef_ (numpy.ndarray or None): Model coefficients (weights).
- _intercept_ (float): Intercept (bias) term.
- _encrypted_coef_ (numpy.ndarray): Encrypted model coefficients (weights).
- _encrypted_intercept_ (object): Encrypted intercept (bias) term.
EncryptedLogisticRegression(ctx)
Initialise the EncryptedLogisticRegression model.
Parameters
- ctx (object): Encryption context to handle encrypted operations.
def
fit(self, X, y, num_iterations=1000, learning_rate=0.1):
Fit the model to the provided data using gradient descent.
Parameters
- X (numpy.ndarray): Feature matrix (n_samples, n_features).
- y (numpy.ndarray): Target vector (n_samples,).
- num_iterations (int, optional): Number of iterations for gradient descent (default is 1000).
- learning_rate (float, optional): Learning rate for gradient descent (default is 0.1).
def
encrypted_fit(self, ctx, x, y, lr=0.3, gamma=0.9, epochs=3):
Fit the model using encrypted data using encrypted data, Nesterov optimization, and a sigmoid approximation.
Parameters
- ctx (object): Encryption context for handling encrypted operations.
- x (numpy.ndarray): Encrypted feature matrix (n_samples, n_features).
- y (numpy.ndarray): Encrypted target vector (n_samples,).
- lr (float, optional): Learning rate for optimisation (default is 0.3).
- gamma (float, optional): Momentum term for Nesterov optimisation (default is 0.9).
- epochs (int, optional): Number of epochs for training (default is 3).