# giovanasantiagolima/welding-optuna-pytorch architecture

> Architecture diagram of the GitHub repository giovanasantiagolima/welding-optuna-pytorch, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/giovanasantiagolima/welding-optuna-pytorch
- Repository: https://github.com/giovanasantiagolima/welding-optuna-pytorch

## Overview

This repository is a welding-parameter prediction system: it prepares welding records and trains a PyTorch multi-output regressor for voltage, amperage, and welding speed. The documented workflow reshapes raw records by weld pass, cleans them, encodes features into tensors, then tunes and trains models with cross-validation before exporting ONNX. The graph preserves the README’s embedding, weighted-loss, and metric capabilities. Some preprocessing and export relationships are documented rather than fully visible in the excerpts; the separate src/treinamento.py implementation is not shown as part of the documented pipeline.

Main entry points: [`src/ml_model/train.py`](https://github.com/giovanasantiagolima/welding-optuna-pytorch/blob/main/src/ml_model/train.py) (Training and validation), [`src/ml_model/tuning.py`](https://github.com/giovanasantiagolima/welding-optuna-pytorch/blob/main/src/ml_model/tuning.py) (Optuna search), [`src/data_prep/load_data.py`](https://github.com/giovanasantiagolima/welding-optuna-pytorch/blob/main/src/data_prep/load_data.py) (Pass restructuring), [`src/data_prep/preprocess_data.py`](https://github.com/giovanasantiagolima/welding-optuna-pytorch/blob/main/src/data_prep/preprocess_data.py) (Cleaning and features)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_prep["Data preparation"]
  node_reshape["Pass restructuring<br/>[load_data.py]"]
  node_clean["Cleaning and features<br/>[preprocess_data.py]"]
  node_encode["Feature encoding"]
end

subgraph group_learn["Model training"]
  node_tensors["Tensor dataset<br/>[dataset.py]"]
  node_network["Embedding regressor<br/>[model.py]"]
  node_training["Training and validation<br/>[train.py]"]
end

subgraph group_optimize["Optimization and export"]
  node_optuna["Optuna search<br/>[tuning.py]"]
  node_trial["Best-trial metrics<br/>[tuning.py]"]
  node_onnx["ONNX model<br/>[train.py]"]
end

subgraph group_legacy["Standalone implementation"]
  node_standalone["Standalone training<br/>[treinamento.py]"]
end

node_source["Welding CSV"]

node_source -->|"loads and reshapes"| node_reshape
node_reshape -->|"feeds cleaned records"| node_clean
node_clean -->|"feeds encoding"| node_encode
node_encode -->|"saves tensors"| node_tensors
node_training -->|"loads batches"| node_tensors
node_training -->|"trains model"| node_network
node_optuna -->|"runs cross-validation"| node_training
node_optuna -->|"re-trains best trial"| node_training
node_optuna -->|"saves metrics"| node_trial
node_training -->|"exports model"| node_onnx

click node_reshape "https://github.com/giovanasantiagolima/welding-optuna-pytorch/blob/main/src/data_prep/load_data.py"
click node_clean "https://github.com/giovanasantiagolima/welding-optuna-pytorch/blob/main/src/data_prep/preprocess_data.py"
click node_encode "https://github.com/giovanasantiagolima/welding-optuna-pytorch/blob/main/src/data_prep/preprocess_encoder.py"
click node_tensors "https://github.com/giovanasantiagolima/welding-optuna-pytorch/blob/main/src/ml_model/dataset.py"
click node_network "https://github.com/giovanasantiagolima/welding-optuna-pytorch/blob/main/src/ml_model/model.py"
click node_training "https://github.com/giovanasantiagolima/welding-optuna-pytorch/blob/main/src/ml_model/train.py"
click node_optuna "https://github.com/giovanasantiagolima/welding-optuna-pytorch/blob/main/src/ml_model/tuning.py"
click node_trial "https://github.com/giovanasantiagolima/welding-optuna-pytorch/blob/main/src/ml_model/tuning.py"
click node_onnx "https://github.com/giovanasantiagolima/welding-optuna-pytorch/blob/main/src/ml_model/train.py"
click node_standalone "https://github.com/giovanasantiagolima/welding-optuna-pytorch/blob/main/src/treinamento.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_reshape,node_clean,node_encode toneBlue
class node_tensors,node_network,node_training toneAmber
class node_optuna,node_trial,node_onnx toneMint
class node_standalone toneRose
class node_source toneIndigo
```

## Components

### Data preparation

- [Pass restructuring](https://github.com/giovanasantiagolima/welding-optuna-pytorch/blob/main/src/data_prep/load_data.py): `src/data_prep/load_data.py`
- [Cleaning and features](https://github.com/giovanasantiagolima/welding-optuna-pytorch/blob/main/src/data_prep/preprocess_data.py): `src/data_prep/preprocess_data.py`
- [Feature encoding](https://github.com/giovanasantiagolima/welding-optuna-pytorch/blob/main/src/data_prep/preprocess_encoder.py): `src/data_prep/preprocess_encoder.py`

### Model training

- [Tensor dataset](https://github.com/giovanasantiagolima/welding-optuna-pytorch/blob/main/src/ml_model/dataset.py): `src/ml_model/dataset.py`
- [Embedding regressor](https://github.com/giovanasantiagolima/welding-optuna-pytorch/blob/main/src/ml_model/model.py): `src/ml_model/model.py`
- [Training and validation](https://github.com/giovanasantiagolima/welding-optuna-pytorch/blob/main/src/ml_model/train.py): `src/ml_model/train.py`

### Optimization and export

- [Optuna search](https://github.com/giovanasantiagolima/welding-optuna-pytorch/blob/main/src/ml_model/tuning.py): `src/ml_model/tuning.py`
- [Best-trial metrics](https://github.com/giovanasantiagolima/welding-optuna-pytorch/blob/main/src/ml_model/tuning.py): `src/ml_model/tuning.py`
- [ONNX model](https://github.com/giovanasantiagolima/welding-optuna-pytorch/blob/main/src/ml_model/train.py): `src/ml_model/train.py`

### Standalone implementation

- [Standalone training](https://github.com/giovanasantiagolima/welding-optuna-pytorch/blob/main/src/treinamento.py): `src/treinamento.py`

### Other components

- **Welding CSV**

## Connections

- Welding CSV → Pass restructuring: loads and reshapes (evidence: `src/data_prep/load_data.py`)
- Pass restructuring → Cleaning and features: feeds cleaned records (evidence: `README.md`)
- Cleaning and features → Feature encoding: feeds encoding (evidence: `README.md`)
- Feature encoding → Tensor dataset: saves tensors (evidence: `src/data_prep/preprocess_encoder.py`)
- Training and validation → Tensor dataset: loads batches (evidence: `src/ml_model/train.py`)
- Training and validation → Embedding regressor: trains model (evidence: `src/ml_model/train.py`)
- Optuna search → Training and validation: runs cross-validation (evidence: `src/ml_model/tuning.py`)
- Optuna search → Training and validation: re-trains best trial (evidence: `src/ml_model/tuning.py`)
- Optuna search → Best-trial metrics: saves metrics (evidence: `src/ml_model/tuning.py`)
- Training and validation → ONNX model: exports model (evidence: `README.md`)
