nvflare.app_opt.feature_election.feature_election module

Feature Election Library for NVIDIA FLARE High-level API for federated feature selection and training workflow.

class FeatureElection(freedom_degree: float = 0.5, fs_method: str = 'lasso', aggregation_mode: str = 'weighted', auto_tune: bool = False, tuning_rounds: int = 5, eval_metric: str = 'f1', wait_time_after_min_received: int = 10, fs_params: Dict | None = None)[source]

Bases: object

High-level interface for Feature Election in NVIDIA FLARE. Simplifies integration with tabular datasets for federated feature selection.

This class provides: - Easy data preparation and splitting - Local simulation for testing - Result management and persistence

apply_mask(X: DataFrame | ndarray) DataFrame | ndarray[source]

Apply global feature mask to new data.

create_flare_job(job_name: str = 'feature_election', output_dir: str = 'jobs/feature_election', min_clients: int = 2, num_rounds: int = 5, client_sites: List[str] | None = None) Dict[str, str][source]

Generate FLARE job configuration.

load_results(filepath: str)[source]

Load results from JSON.

prepare_data_splits(df: DataFrame, target_col: str, num_clients: int = 3, split_strategy: str = 'stratified', split_ratios: List[float] | None = None, random_state: int = 42, dirichlet_alpha: float = 0.5) List[Tuple[DataFrame, Series]][source]

Prepare data splits for federated clients.

save_results(filepath: str)[source]

Save results to JSON.

simulate_election(client_data: List[Tuple[DataFrame | ndarray, Series | ndarray]], feature_names: List[str] | None = None) Dict[source]

Simulate election locally.

load_election_results(filepath: str) Dict[source]

Load election results from a JSON file.

quick_election(df: DataFrame, target_col: str, num_clients: int = 3, freedom_degree: float = 0.5, fs_method: str = 'lasso', split_strategy: str = 'stratified', **kwargs) Tuple[ndarray, Dict][source]

Quick Feature Election for tabular data (one-line solution).

**kwargs are routed to either FeatureElection or FeatureElection.prepare_data_splits() based on the parameter name. Recognised split parameters: split_ratios, random_state, dirichlet_alpha. All other kwargs are forwarded to FeatureElection (e.g. aggregation_mode, auto_tune, fs_params).