RADAR.federated_data.algorithms
Submodules
RADAR.federated_data.algorithms.flexanomalies module
- class RADAR.federated_data.algorithms.flexanomalies.FlexAnomalyDetection(**kwargs)[source]
Bases:
BaseAnomalyDetection- decision_function(X, y=None)[source]
Predict raw anomaly score of X using the fitted detector.
- Parameters:
X (numpy array of shape (n_samples, n_features)) – The training input samples. Sparse matrices are accepted only if they are supported by the base estimator.
- Returns:
anomaly_scores – The anomaly score of the input samples.
- Return type:
numpy array of shape (n_samples,)
- fit(X, y)[source]
Fit detector.
- Parameters:
X (numpy array of shape (n_samples, n_features)) – The input samples.
y (numpy array of shape)
- Returns:
self – Fitted estimator.
- Return type:
object
- get_default_params(**params)[source]
Get DEFAULT parameters for this estimator, params is used to configure positional parameters in order to obtain default parameters of the object.
- Returns:
params – Parameter names mapped to their values.
- Return type:
mapping of string to any
- get_params()[source]
Get parameters for this estimator.
- Returns:
params – Parameter names mapped to their values.
- Return type:
mapping of string to any
- predict(X, y=None)[source]
Predict raw anomaly scores of X using the fitted detector.
The anomaly score of an input sample is computed based on the fitted detector. For consistency, outliers are assigned with higher anomaly scores.
If label_parser is an attribute, then we execute the particular predict function
- Parameters:
X (numpy array of shape (n_samples, n_features)) – The input samples. Sparse matrices are accepted only if they are supported by the base estimator.
- Returns:
anomaly_scores – The anomaly score of the input samples.
- Return type:
numpy array of shape (n_samples,)
- classmethod register_algorithm(name, model_class)[source]
Register a new algorithm in the class. :param - name: The name of the new algorithm. :type - name: str :param - model_class: The class implementing the anomaly detection model. :type - model_class: class
- The class should have:
An __init__ method that accepts model-specific parameters.
A fit(X, y) method to train the model.
A predict(X) method to make predictions.
Optionally, a decision_function(X) for scoring anomalies.
- register_federated_functions(name, functions)[source]
- Records the federated functions of a new algorithm.
federated_functions (dict): A dictionary defining federated learning functions.
- Required keys:
“build_model”: Function to initialize the server model.
“copy”: Function to distribute the model to clients.
“train”: Function to train the model on client data.
“collect”: Function to gather updates from clients.
“aggregate”: Function to combine client updates.
“set_weights”: Function to update the global model.