How silencex12138/protogate works
Project type and purpose
• This repo is an open-source research codebase (Python/PyTorch) implementing ProtoGate, a prototype-based neural network with global-to-local feature selection for tabular biomedical data, along with benchmark methods (KNN, LASSO, MLP, RF, TabNet). It provides end-to-end experiment orchestration (data loading → training → evaluation → logging).
File structure
• Top level
• data/ – tabular biomedical datasets (e.g. Metabric samples)
• scripts/ – per-method experiment folders (KNN, LASSO, MLP, PROTOGATE, RF, TABNET) each containing shell scripts to launch experiments
• src/ – core library:
– _config.py, _shared_imports.py for global settings
– dataset.py for data loading and preprocessing
– custom_models/ (MLP, ProtoGate implementations)
– models.py for “vanilla” or wrapper model definitions
– lookahead_optimizer.py – custom optimizer
– param_tune.py – hyperparameter tuning logic
– run_experiment.py – main training/evaluation loop
– utils.py – logging, checkpoint utilities
• protogate_colab.ipynb & colab_requirements.txt – Colab setup
• requirements.txt – dependencies (PyTorch, scikit-learn, wandb, etc.)
README for additional insights
• Confirms PyTorch implementation, optional LightGBM support, WandB for logging
• Describes experiment scripts and parameter overrides
• Details usage on local vs Google Colab
a. Main components
• Data Layer
– Local CSV files in data/
– External dataset sources (TabZilla, scikit-feature)
• Data Ingestion & Preprocessing
– src/dataset.py
• Model Zoo
– Benchmark methods (KNN, LASSO, RF, TabNet in src/models & custom_models)
– ProtoGate implementation (src/custom_models/protogate/ProtoGate.py)
• Training & Evaluation Engine
– run_experiment.py orchestrates:
• Parameter parsing (from scripts or CLI)
• Model instantiation
• Optimizer & scheduler setup (including lookahead_optimizer)
• Training loop, validation, checkpointing (via utils)
• Hyperparameter Tuning
– param_tune.py for grid search or custom tuning
• Experiment Runner
– scripts/*/*.sh invoking run_experiment.py with method-specific flags
• Logging & Tracking
– WandB integration in utils or run_experiment
• Interactive Interface
– protogate_colab.ipynb for Colab users
b. Relationships & interactions
2. Engine → (calls) Data Ingestion → Loads raw CSVs → Feeds mini-batches
3. Engine → (instantiates) Model from Model Zoo → Feeds data
4. Engine → (uses) Optimizer → Updates model parameters
5. Engine → (logs) metrics to WandB or stdout → persisted via utils
6. Optional: Engine → param_tune to loop over hyperparameters
7. Notebook → (can call) the same Python modules interactively
c. Architectural patterns & design principles
• Modular separation of concerns: data, models, training, tuning, scripts
• Plugin-style Model Zoo allows adding new models without touching core engine
• Reproducible experiments via shell scripts capturing CLI parameters
• Config file for global settings to ensure consistency
d. Key technologies & frameworks
• Python 3.9+, PyTorch
• Scikit-learn, pandas, numpy for data utilities
• Optional LightGBM for benchmarking
• WandB for experiment tracking
• Shell scripts for reproducible workflows
• Jupyter Notebook for interactive experiments