# gabriellazovsky/prac3ia architecture

> Architecture diagram of the GitHub repository gabriellazovsky/prac3ia, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gabriellazovsky/prac3ia
- Repository: https://github.com/gabriellazovsky/prac3ia

## Overview

#### Purpose and execution model
This is a notebook-centric machine-learning project for predicting molecular Collision Cross Section (CCS) from precomputed molecular descriptors, structural fingerprints, and categorical features. The primary execution entry point is `P3IA.ipynb`, intended for interactive execution, including Google Colab.

#### Dataset boundary
CSV files provide the complete interface between the model workflow and molecular data:
- Training features plus CCS target: `data/public_train.csv`
- Prediction-only test features: `data/public_test.csv`
- Additional train/test variants: `data/public_train2.csv`, `data/public_test2.csv`

The notebook must align training and test feature schemas while keeping the target column isolated from model inputs.

#### Preprocessing and feature selection
`P3IA.ipynb` performs preparation of tabular molecular features before fitting. The documented approach includes handling descriptor, fingerprint, and categorical inputs, followed by feature selection with LassoCV. This stage defines the feature space consumed by all candidate regressors and must apply equivalent transformations to held-out and test data.

#### Model-training and selection loop
The central modeling stage in `P3IA.ipynb` compares regression approaches for CCS prediction:
- `RandomForestRegressor`
- LightGBM

Hyperparameters are explored through `GridSearchCV` and `RandomizedSearchCV`. Training is separated from validation/error estimation so model variants can be compared before final prediction generation.

#### Evaluation and analysis
Validation quality is measured with Median Absolute Error (MEDAE), chosen for robustness to outliers. The notebook also contains result-analysis stages: predicted-versus-actual comparisons, residual/error analysis, prediction distributions, and feature importance. These analyses guide selection of the final estimator rather than serving as a deployed monitoring system.

#### Prediction output contract
After selecting or fitting the final model, `P3IA.ipynb` runs inference over the public test feature set and exports predictions. `test_preds.csv` is the repository’s material output artifact and downstream submission/consumption boundary.

#### Runtime and dependencies
The workflow runs in a Python notebook environment, explicitly supporting Google Colab for collaborative and compute-backed experimentation. Core ML infrastructure is scikit-learn-style model selection and regression, with LightGBM as an external gradient-boosting dependency; the README recommends installation through Conda Forge. No application server, API, database, or production deployment runtime is present.

Main entry points: [`P3IA.ipynb`](https://github.com/gabriellazovsky/prac3ia/blob/main/P3IA.ipynb) (Schema alignment & target split), [`data/public_train.csv`](https://github.com/gabriellazovsky/prac3ia/blob/main/data/public_train.csv) (Training data + CCS), [`data/public_test.csv`](https://github.com/gabriellazovsky/prac3ia/blob/main/data/public_test.csv) (Public test features), [`data/public_train2.csv`](https://github.com/gabriellazovsky/prac3ia/blob/main/data/public_train2.csv) (Additional data variants)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Dataset boundary"]
  node_train_data["Training data + CCS<br/>CSV dataset<br/>[public_train.csv]"]
  node_test_data["Public test features<br/>CSV dataset<br/>[public_test.csv]"]
  node_data_variants["Additional data variants<br/>CSV datasets<br/>[public_train2.csv]"]
end

subgraph group_workflow["Notebook ML workflow"]
  node_notebook["P3IA notebook<br/>Python notebook<br/>[P3IA.ipynb]"]
  node_schema_target["Schema alignment &amp; target split<br/>data preparation<br/>[P3IA.ipynb]"]
  node_feature_prep["Feature preprocessing<br/>feature pipeline<br/>[P3IA.ipynb]"]
  node_lasso_selection["LassoCV selection<br/>feature selection<br/>[P3IA.ipynb]"]
  node_validation["Validation split<br/>evaluation data<br/>[P3IA.ipynb]"]
  node_model_search["Model search<br/>model selection<br/>[P3IA.ipynb]"]
  node_random_forest["Random forest<br/>regressor<br/>[P3IA.ipynb]"]
  node_lightgbm["LightGBM<br/>regressor<br/>[P3IA.ipynb]"]
  node_medae["MEDAE evaluation<br/>metric<br/>[P3IA.ipynb]"]
  node_analysis["Result analysis<br/>notebook analysis<br/>[P3IA.ipynb]"]
  node_final_model["Selected final model<br/>CCS estimator<br/>[P3IA.ipynb]"]
  node_predictions["Test inference<br/>batch prediction<br/>[P3IA.ipynb]"]
end

subgraph group_output["Prediction artifact"]
  node_output_csv["Test predictions<br/>CSV output<br/>[test_preds.csv]"]
end

node_train_data -->|"load"| node_schema_target
node_test_data -->|"load"| node_schema_target
node_data_variants -.->|"alternate train set"| node_schema_target
node_schema_target -->|"aligned features"| node_feature_prep
node_schema_target -->|"features + CCS"| node_validation
node_feature_prep -->|"prepared features"| node_lasso_selection
node_lasso_selection -->|"selected features"| node_validation
node_validation -->|"train/validation folds"| node_model_search
node_random_forest -->|"candidate"| node_model_search
node_lightgbm -->|"candidate"| node_model_search
node_model_search -->|"validation predictions"| node_medae
node_medae -->|"compare variants"| node_analysis
node_analysis -->|"select estimator"| node_final_model
node_feature_prep -->|"transform test features"| node_predictions
node_lasso_selection -->|"select test columns"| node_predictions
node_final_model -->|"predict CCS"| node_predictions
node_predictions -->|"export"| node_output_csv

click node_train_data "https://github.com/gabriellazovsky/prac3ia/blob/main/data/public_train.csv"
click node_test_data "https://github.com/gabriellazovsky/prac3ia/blob/main/data/public_test.csv"
click node_data_variants "https://github.com/gabriellazovsky/prac3ia/blob/main/data/public_train2.csv"
click node_notebook "https://github.com/gabriellazovsky/prac3ia/blob/main/P3IA.ipynb"
click node_schema_target "https://github.com/gabriellazovsky/prac3ia/blob/main/P3IA.ipynb"
click node_feature_prep "https://github.com/gabriellazovsky/prac3ia/blob/main/P3IA.ipynb"
click node_lasso_selection "https://github.com/gabriellazovsky/prac3ia/blob/main/P3IA.ipynb"
click node_validation "https://github.com/gabriellazovsky/prac3ia/blob/main/P3IA.ipynb"
click node_model_search "https://github.com/gabriellazovsky/prac3ia/blob/main/P3IA.ipynb"
click node_random_forest "https://github.com/gabriellazovsky/prac3ia/blob/main/P3IA.ipynb"
click node_lightgbm "https://github.com/gabriellazovsky/prac3ia/blob/main/P3IA.ipynb"
click node_medae "https://github.com/gabriellazovsky/prac3ia/blob/main/P3IA.ipynb"
click node_analysis "https://github.com/gabriellazovsky/prac3ia/blob/main/P3IA.ipynb"
click node_final_model "https://github.com/gabriellazovsky/prac3ia/blob/main/P3IA.ipynb"
click node_predictions "https://github.com/gabriellazovsky/prac3ia/blob/main/P3IA.ipynb"
click node_output_csv "https://github.com/gabriellazovsky/prac3ia/blob/main/test_preds.csv"

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_train_data,node_test_data,node_data_variants toneBlue
class node_notebook,node_schema_target,node_feature_prep,node_lasso_selection,node_validation,node_model_search,node_random_forest,node_lightgbm,node_medae,node_analysis,node_final_model,node_predictions toneAmber
class node_output_csv toneMint
```

## Components

### Dataset boundary

CSV files are the interface to molecular data.

- [Training data + CCS](https://github.com/gabriellazovsky/prac3ia/blob/main/data/public_train.csv): CSV dataset · Features and target for fitting and validation. · `data/public_train.csv`
- [Public test features](https://github.com/gabriellazovsky/prac3ia/blob/main/data/public_test.csv): CSV dataset · Prediction-only molecular features. · `data/public_test.csv`
- [Additional data variants](https://github.com/gabriellazovsky/prac3ia/blob/main/data/public_train2.csv): CSV datasets · `data/public_train2.csv`

### Notebook ML workflow

Interactive Python and Colab execution in P3IA.ipynb.

- [P3IA notebook](https://github.com/gabriellazovsky/prac3ia/blob/main/P3IA.ipynb): Python notebook · Primary interactive execution entry point. · `P3IA.ipynb`
- [Schema alignment & target split](https://github.com/gabriellazovsky/prac3ia/blob/main/P3IA.ipynb): data preparation · Aligns train/test features while isolating CCS. · `P3IA.ipynb`
- [Feature preprocessing](https://github.com/gabriellazovsky/prac3ia/blob/main/P3IA.ipynb): feature pipeline · Processes descriptors, fingerprints, and categorical inputs. · `P3IA.ipynb`
- [LassoCV selection](https://github.com/gabriellazovsky/prac3ia/blob/main/P3IA.ipynb): feature selection · Defines the shared regressor feature space. · `P3IA.ipynb`
- [Validation split](https://github.com/gabriellazovsky/prac3ia/blob/main/P3IA.ipynb): evaluation data · Separates error estimation from final inference. · `P3IA.ipynb`
- [Model search](https://github.com/gabriellazovsky/prac3ia/blob/main/P3IA.ipynb): model selection · GridSearchCV and RandomizedSearchCV tune candidate regressors. · `P3IA.ipynb`
- [Random forest](https://github.com/gabriellazovsky/prac3ia/blob/main/P3IA.ipynb): regressor · `P3IA.ipynb`
- [LightGBM](https://github.com/gabriellazovsky/prac3ia/blob/main/P3IA.ipynb): regressor · External gradient-boosting dependency. · `P3IA.ipynb`
- [MEDAE evaluation](https://github.com/gabriellazovsky/prac3ia/blob/main/P3IA.ipynb): metric · Median Absolute Error compares validation quality. · `P3IA.ipynb`
- [Result analysis](https://github.com/gabriellazovsky/prac3ia/blob/main/P3IA.ipynb): notebook analysis · Examines predictions, residuals, distributions, and feature importance. · `P3IA.ipynb`
- [Selected final model](https://github.com/gabriellazovsky/prac3ia/blob/main/P3IA.ipynb): CCS estimator · `P3IA.ipynb`
- [Test inference](https://github.com/gabriellazovsky/prac3ia/blob/main/P3IA.ipynb): batch prediction · `P3IA.ipynb`

### Prediction artifact

- [Test predictions](https://github.com/gabriellazovsky/prac3ia/blob/main/test_preds.csv): CSV output · Submission and downstream consumption boundary. · `test_preds.csv`

## Connections

- Training data + CCS → Schema alignment & target split: load
- Public test features → Schema alignment & target split: load
- Additional data variants → Schema alignment & target split: alternate train set
- Schema alignment & target split → Feature preprocessing: aligned features
- Schema alignment & target split → Validation split: features + CCS
- Feature preprocessing → LassoCV selection: prepared features
- LassoCV selection → Validation split: selected features
- Validation split → Model search: train/validation folds
- Random forest → Model search: candidate
- LightGBM → Model search: candidate
- Model search → MEDAE evaluation: validation predictions
- MEDAE evaluation → Result analysis: compare variants
- Result analysis → Selected final model: select estimator
- Feature preprocessing → Test inference: transform test features
- LassoCV selection → Test inference: select test columns
- Selected final model → Test inference: predict CCS
- Test inference → Test predictions: export
