# junyaok/ml_pyrite architecture

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

- Interactive diagram: https://gitdiagram.com/junyaok/ml_pyrite
- Repository: https://github.com/junyaok/ml_pyrite

## Overview

##### Project Type & Purpose
- This project supports geochemical research by distinguishing between different pyrite origins using trace element data.

##### Analyzing the File Structure
- Top-level Directories/Files: The project contains a LICENSE, README.md, a “code” directory with several Jupyter Notebooks, and a “data” directory with CSV files.
- The “code” directory holds four main notebooks:
- RF_XG.ipynb: Trains Random Forest/XGBoost models using a balanced dataset sampled from Training.csv.
- Ternary.ipynb: Uses predictions from RF_XG.ipynb to generate ternary plots for visual analysis.
- Cluster.ipynb: Conducts hierarchical clustering on the power-transformed trace element data.
- PCA.ipynb: Performs principal component analysis on the same power-transformed dataset.
- The “data” directory includes several CSV files for training, testing, and supplementary datasets.

- a. Main Components to Represent:
- Data Sources: Represent the different CSV files (Training.csv, OSL_Test.csv, TE_Data.csv, Xiao_Cui.csv) as a “Data Storage” or “Data Layer”.
- Data Preprocessing & Transformation: Implicit in each notebook’s pipeline where raw data may undergo power transformations.
- Data Visualization: Show processes using Ternary.ipynb and the generation of charts (ternary plots).
- Dimensionality Reduction and Pattern Discovery: Represent the PCA.ipynb and Cluster.ipynb components as performing data reduction and clustering analysis.
- External Libraries & Environment: Note key technologies (Python 3.10.4, Jupyter Notebook/JupyterLab, and libraries such as pandas, numpy, sklearn, xgboost, matplotlib, seaborn, and plotly).

- b. Relationships and Interactions:
- Data flows from the data layer (CSV files) into the notebooks.
- RF_XG.ipynb consumes training data, builds the classification models, and produces model prediction outputs.
- PCA.ipynb and Cluster.ipynb take raw or transformed trace element data to derive insights on element behavior.
- The notebooks might share intermediate processed data and even use common pre-processing steps.

- c. Architectural Patterns & Design Principles:
- Modular design: Each notebook is a self-contained analysis component that collectively forms a processing pipeline.
- Separation of Concerns: Data ingestion, model training, dimensionality reduction, clustering analysis, and visualization are all handled separately.
- Reproducibility & Dependency Management: The dedicated requirements section in the README and explicit use of Jupyter notebooks emphasize an environment where reproducible research is paramount.

- d. Relevant Technologies & Frameworks:
- Python (with version 3.10.4)
- Jupyter Notebook/JupyterLab for execution and interactive analysis.
- Scientific libraries (numpy, pandas, scipy) and specialized ones (sklearn, xgboost, plotly, matplotlib, seaborn) for machine learning and visualizations.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Data Layer"
        d1["Training.csv"]:::data
        d2["OSL_Test.csv"]:::data
        d3["TE_Data.csv"]:::data
        d4["Xiao_Cui.csv"]:::data
    end

    subgraph "Processing Modules"
        n1["RF_XG.ipynb: ML Model Training (Random Forest & XGBoost)"]:::processing
        n2["Ternary.ipynb: Data Visualization (Ternary Plots)"]:::processing
        n3["PCA.ipynb: PCA Analysis"]:::processing
        n4["Cluster.ipynb: Clustering Analysis"]:::processing
    end

    subgraph "Preprocessing & Transformation"
        p["Preprocessing & Transformation"]:::processing
    end

    subgraph "Environment & Tools"
        env["Python 3.10.4, Jupyter Notebook, Libraries"]:::env
    end

    %% Data Layer flows to Preprocessing
    d1 --> p
    d2 --> p
    d3 --> p
    d4 --> p

    %% Preprocessing feeds into ML Training, PCA and Clustering
    p --> n1
    p --> n3
    p --> n4

    %% ML Model Training output flows to Data Visualization
    n1 --> n2

    %% Environment supports preprocessing and processing modules
    env --> p

    %% Click Events for Data Layer files
    click d1 "https://github.com/junyaok/ml_pyrite/blob/main/data/Training.csv"
    click d2 "https://github.com/junyaok/ml_pyrite/blob/main/data/OSL_Test.csv"
    click d3 "https://github.com/junyaok/ml_pyrite/blob/main/data/TE_Data.csv"
    click d4 "https://github.com/junyaok/ml_pyrite/blob/main/data/Xiao_Cui.csv"

    %% Click Events for Processing Notebooks
    click n1 "https://github.com/junyaok/ml_pyrite/blob/main/code/RF_XG.ipynb"
    click n2 "https://github.com/junyaok/ml_pyrite/blob/main/code/Ternary.ipynb"
    click n3 "https://github.com/junyaok/ml_pyrite/blob/main/code/PCA.ipynb"
    click n4 "https://github.com/junyaok/ml_pyrite/blob/main/code/Cluster.ipynb"

    %% Styles
    classDef data fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef processing fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef env fill:#D5F5E3,stroke:#28B463,stroke-width:2px;
```
