How zzhustc2016/raremed works
Main Components
• Data Layer:
• Files under the data folder (data/input and data/process.py) indicate a dedicated component for data ingestion, pre-processing, and preparation.
• External dependencies include MIMIC-III and MIMIC-IV datasets along with supplementary files from DrugBank.
• Model Components:
• src/models: Contains implementations of the RAREMed model and baseline models (e.g., COGNet, GAMENet, GBert, LEAP, MICRON, MoleRec, RETAIN, SafeDrug).
• The models sub-directory is further organized to encapsulate submodules such as gnn components (like GNNConv, GNNs) which hint at a graph neural network usage.
• Baselines Module:
• src/Baselines contains separate executable scripts to run experiments for each baseline—this is key to showing alternatives and comparisons with the primary RAREMed method.
• Utility and Support Functions:
• src/utils: Contains utility functions for beam search, data loading, layer definitions, and overall helper functions that support model training and evaluation.
• Experimentation & Visualization:
• Notebooks (e.g., src/figs.ipynb) and figs directory supply visualizations and potentially in-depth analysis artifacts.
• Deployment and Installation:
• Files like install.sh, .gitignore, and LICENSE represent environment setup and legal documentation aspects.
Relationships and Interactions
• The Data Layer processes raw input files from the specified directories, likely feeding preprocessed data into the models.
• The Models (including the central RAREMed model as well as baselines) ingest processed data via functions defined in the utils module (like data_loader.py) and use various neural network components (including transformer encoders and GNN layers) to generate medication recommendations.
• Baseline scripts interact with the same utility modules and hence share dependencies with the main RAREMed pipeline.
• There’s an integration layer between the experimental setup (command-line driven via main_RAREMed.py and similar scripts) and the actual deep learning models.
• Visual outputs are generated both during training (logs, tensorboard which might be created via logging utilities) and then visualizations are stored in the figs folder or Jupyter notebooks.
Architectural Patterns and Design Principles
• Modular design: Separation of concerns into data processing, model definitions, utility functions, and experiment execution.
• Extensibility: Separate directories for Baselines and models indicate a design that supports plugging in or comparing additional models.
• Use of standard deep learning practices using PyTorch, configuration through command-line arguments (as seen in main_RAREMed.py).
• If following best practices, dependency injection for datasets and logging should be visible though the file organization supports clear integration.
Relevant Technologies, Frameworks, and Libraries
• PyTorch as the deep learning framework.
• Likely use of Python libraries for data manipulation (e.g., pandas, numpy) as indicated by the processing scripts.
• Graph neural network components (potential GNN frameworks integrated into PyTorch) for handling relational data modeling in medication recommendations.
• Possibly Jupyter Notebook for visualization and experiment tracking.
Elements
• Clear Labels: Each major component (Data Layer, Models, Baselines, Utilities, Experiment Scripts) should be explicitly labeled.
• Blue blocks for data ingestion and pre-processing.
• Green blocks for model implementations.
• Subdivision for “model internals” if further detail is desired: Indicate parts such as transformer encoder layers, adapter layers, GNN components as used in RAREMed.
Putting It Together
• Link these inputs to the “Data Processing” module (represented by process.py in the data folder).
• Processed data feeding into the core "Model Training and Evaluation" module (main_RAREMed.py in the src folder).
• Split out the “Models” architecture – with a node for RAREMed and nodes for each baseline (perhaps clustering baseline models together under the Baselines directory).
• Connections between the primary model binaries (using modules from src/models and src/models/gnn) and their supporting utilities (src/utils) demonstrating dependency.
• Finally, optionally include a section for “Results & Visualization” linking to the figs directory and Jupyter notebooks.