# ppdebreuck/modnet architecture

> Architecture diagram of the GitHub repository ppdebreuck/modnet, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ppdebreuck/modnet
- Repository: https://github.com/ppdebreuck/modnet

## Overview

##### Main Components

a. Core Components:
- Feature Processing Layer
- Featurizers module (modnet/featurizers)
- Preprocessing module (modnet/preprocessing.py)
- Model Layer
- Vanilla models (modnet/models/vanilla.py)
- Bayesian models (modnet/models/bayesian.py)
- Ensemble models (modnet/models/ensemble.py)
- Hyperparameter Optimization Layer (modnet/hyper_opt)
- External Data Handler (modnet/ext_data.py)

b. Supporting Components:
- Model Presets (modnet/model_presets)
- Featurizer Presets (modnet/featurizers/presets)
- Matbench Integration (modnet/matbench)
- Utility Functions (modnet/utils.py)

##### Input Data → Feature Processing Layer
- Both composition and crystal structure inputs

##### Specific Architectural Elements

- Use a layered architecture approach
- Modular nature of the components
- Interaction between the core ML pipeline and supporting infrastructure

##### Key Elements to Highlight

- Feature Selection Mechanism
- Joint Learning Capability
- Model Ensemble Architecture
- Hyperparameter Optimization Loop
- Integration with External Systems (MatBench)

##### Implementation Notes

Using tools like:
- UML notation for certain components
- Nested components to show hierarchical relationships
- Clear labeling of interfaces between components

This architecture should emphasize MODNet's strengths in:
- Handling limited datasets
- Supporting multiple property prediction
- Flexible input handling (composition or crystal structure)
- Integration with existing materials science infrastructure

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        IN1[Composition Data]
        IN2[Crystal Structure Data]
    end

    subgraph "Feature Processing Layer"
        FP1["Main Featurizers"]:::core
        FP2["Preprocessing"]:::core
        FP3["Featurizer Presets"]:::support
        IN1 & IN2 --> FP1
        FP1 --> FP2
        FP3 -.-> FP1
    end

    subgraph "Model Layer"
        ML1["Vanilla Models"]:::core
        ML2["Bayesian Models"]:::core
        ML3["Ensemble Models"]:::core
        MP["Model Presets"]:::support
        
        FP2 --> ML1 & ML2 & ML3
        MP -.-> ML1 & ML2 & ML3
    end

    subgraph "Optimization Layer"
        HPO["Hyperparameter Optimization"]:::opt
    end

    subgraph "Supporting Infrastructure"
        MB["Matbench Integration"]:::support
        UTIL["Utility Functions"]:::support
        EXT["External Data Handler"]:::support
    end

    subgraph "Pretrained Models"
        PTM1["Refractive Index Model"]:::model
        PTM2["Vibrational Thermo Model"]:::model
    end

    ML1 & ML2 & ML3 <--> HPO
    ML1 & ML2 & ML3 --> OUT[Predictions]

    EXT --> FP1
    MB --> ML1 & ML2 & ML3
    UTIL --> FP1
    UTIL --> ML1 & ML2 & ML3

    PTM1 & PTM2 -.-> ML1 & ML2 & ML3

    %% Click events for component mapping
    click FP1 "https://github.com/ppdebreuck/modnet/blob/master/modnet/featurizers/featurizers.py"
    click FP2 "https://github.com/ppdebreuck/modnet/blob/master/modnet/preprocessing.py"
    click FP3 "https://github.com/ppdebreuck/modnet/tree/master/modnet/featurizers/presets/"
    click ML1 "https://github.com/ppdebreuck/modnet/blob/master/modnet/models/vanilla.py"
    click ML2 "https://github.com/ppdebreuck/modnet/blob/master/modnet/models/bayesian.py"
    click ML3 "https://github.com/ppdebreuck/modnet/blob/master/modnet/models/ensemble.py"
    click HPO "https://github.com/ppdebreuck/modnet/blob/master/modnet/hyper_opt/fit_genetic.py"
    click EXT "https://github.com/ppdebreuck/modnet/blob/master/modnet/ext_data.py"
    click MP "https://github.com/ppdebreuck/modnet/blob/master/modnet/model_presets/presets.py"
    click MB "https://github.com/ppdebreuck/modnet/blob/master/modnet/matbench/benchmark.py"
    click UTIL "https://github.com/ppdebreuck/modnet/blob/master/modnet/utils.py"
    click PTM1 "https://github.com/ppdebreuck/modnet/blob/master/pretrained/refractive_index.h5"
    click PTM2 "https://github.com/ppdebreuck/modnet/blob/master/pretrained/vib_thermo.h5"

    %% Styling
    classDef core fill:#2374ab,stroke:#2374ab,color:white
    classDef support fill:#878787,stroke:#878787,color:white
    classDef opt fill:#ff7f50,stroke:#ff7f50,color:white
    classDef model fill:#4CAF50,stroke:#4CAF50,color:white

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Supporting Components"]:::support
        L3["Optimization Components"]:::opt
        L4["Pretrained Models"]:::model
    end
```
