Skip to main content

AITW_viscosity_surrogate

Four approaches used to predict the viscosity of chemical compounds from their SMILES representations. Together they span classical machine learning, pure deep learning on molecular language, a hybrid architecture combining both, and a final ensemble that unifies all three.

Dataset

Installation

cd <PATH to folder with pyproject.toml>
pip install .

Usage

CLI

The installation will make available a aitw-viscosity-surrogate command line interface.

  • Run aitw-viscosity-surrogate --help to see the available commands.

More information on the CLI can be found in the approach-specific subsections

Tab autocompletion

Enabling tab autocompletion https://click.palletsprojects.com/en/stable/shell-completion/

E.G for bash run the command

eval "$(_AITW_INFILTRATION_SURROGATE_COMPLETE=bash_source aitw-viscosity-surrogate)"

You can also add it to either ~/.bashrc or, if you are using a virtual environment, to bin/activate of the virtual environment to avoid running the command for every new shell.

Approaches

Dataset format

For all approaches, the input dataset must be a CSV file containing the following columns:

  • compound_name: The name of the compound.
  • SMILES: The SMILES representation of the compound.
  • log_visc_calc: The calculated log-viscosity of the compound.
  • log_visc_exp: The experimentally measured log-viscosity of the compound.
  • visc_mPas_calc: The calculated viscosity of the compound in mPa·s.
  • visc_mPas_exp: The experimentally measured viscosity of the compound in mPa·

1. Baseline: XGBoost with Molecular Fingerprints and Descriptors

The first approach represents a classical cheminformatics pipeline in which each molecule is converted into a fixed-length numerical vector composed of a 2048-bit Morgan fingerprint and the full set of RDKit-computed physicochemical descriptors, including molecular weight, polarity, hydrogen-bonding capacity, and topological complexity. These features are fed into an XGBoost gradient-boosted tree regressor, which learns nonlinear relationships between molecular structure and log-viscosity without requiring any deep learning. This approach serves as a strong, interpretable baseline against which more complex models can be compared.

Training

aitw-viscosity-surrogate xgboost train --help
aitw-viscosity-surrogate xgboost train \
  --input-file examples/dataset.csv

The output of the training command contains the following files:

  • {output_dir}/xgboost_model.json: The trained XGBoost model in JSON format.
  • {output_dir}/xgboost_performance.png: A plot of predicted vs. experimental log-viscosity values for the training set.
  • {output_dir}/xgboost_predictions.csv: A CSV file containing the predicted log-viscosity values and errors for the training set.
  • {output_dir}/xgboost_training.log: A log file containing the training process.

Inference

Inference can be ran using a pre-trained model included in the package or a custom model trained using the train command. The input file must be a CSV file containing the following columns:

  • compound_name: The name of the compound.
  • SMILES: The SMILES representation of the compound.
  • visc_mPas_exp: OPTIONAL. The reference viscosity of the compound in mPa·s. If provided, the error between predicted and reference values will be calculated and included in the output.
aitw-viscosity-surrogate xgboost inference --help
aitw-viscosity-surrogate xgboost inference \
  --input-file examples/dataset.csv \
  --output-file xgboost_predictions.csv

It will produce a CSV file containing the predicted log-viscosity values for the input compounds.

The xgboost_model.json file included in the package was trained on the dataset provided in examples/dataset.csv.

XGBoost training performance

2. Pure LLM: Fine-Tuned ChemBERTa

The second approach treats each molecule's SMILES string as a sentence in a chemical ``language'' and fine-tunes ChemBERTa, a transformer model pretrained on millions of molecules, to predict viscosity directly from this textual representation. No hand-crafted descriptors are used; instead, the model relies entirely on the contextual embeddings it has learned during pretraining, with a small feed-forward regression head mapping the resulting molecular embedding to a single viscosity value. This approach tests whether a language model can capture the structure-property relationships needed for viscosity prediction without any explicit chemical feature engineering.

Training

aitw-viscosity-surrogate chemberta train --help
aitw-viscosity-surrogate chemberta train \
  --input-file examples/dataset.csv

The output of the training command contains the following files:

  • {output_dir}/chemberta_model_base.pt: The trained ChemBERTa model in PyTorch format. This will be a dictionary containing the model_state_dict and the ChemBERTa model name used for training (model_name).
  • {output_dir}/chemberta_base_performance.png: A plot of predicted vs. experimental log-viscosity values for the training set.
  • {output_dir}/chemberta_base_predictions.csv: A CSV file containing the predicted log-viscosity values and errors for the training set.
  • {output_dir}/chemberta_base_training.log: A log file containing the training process.
  • {output_dir}/chemberta_base_indexes.json: A JSON file containing the indexes of the training and test sets used for training and validation.

Inference

Inference can be ran using a pre-trained model included in the package or a custom model trained using the train command. The input file must be a CSV file containing the following columns:

  • compound_name: The name of the compound.
  • SMILES: The SMILES representation of the compound.
  • visc_mPas_exp: OPTIONAL. The reference viscosity of the compound in mPa·s. If provided, the error between predicted and reference values will be calculated and included in the output.
aitw-viscosity-surrogate chemberta inference --help
aitw-viscosity-surrogate chemberta inference \
  --input-file examples/dataset.csv \
  --output-file chemberta_predictions.csv

It will produce a CSV file containing the predicted log-viscosity values for the input compounds.

The chemberta_model_base.pt file included in the package was trained on the dataset provided in examples/dataset.csv.

ChemBERTa base training performance

3. Hybrid: ChemBERTa with Residual Descriptor Fusion

The third approach combines the strengths of the previous two methods by fusing ChemBERTa's learned molecular embedding with ten classical RDKit descriptors, projecting the combined representation through a residual neural network with skip connections to preserve information across layers. This architecture allows the model to leverage both the rich, pretrained chemical knowledge encoded in ChemBERTa and the well-established physical intuition captured by classical descriptors, resulting in improved predictive accuracy over either approach used alone.

Training

aitw-viscosity-surrogate chemberta-residuals train --help
aitw-viscosity-surrogate chemberta-residuals train \
  --input-file examples/dataset.csv

The output of the training command contains the following files:

  • {output_dir}/chemberta_model_residuals.pt: The trained ChemBERTa model in PyTorch format. This will be a dictionary containing the model_state_dict, the ChemBERTa model name used for training (model_name) and the scaler (scaler).
  • {output_dir}/chemberta_residuals_performance.png: A plot of predicted vs. experimental log-viscosity values for the training set.
  • {output_dir}/chemberta_residuals_predictions.csv: A CSV file containing the predicted log-viscosity values and errors for the training set.
  • {output_dir}/chemberta_residuals_training.log: A log file containing the training process.
  • {output_dir}/chemberta_residuals_indexes.json: A JSON file containing the indexes of the training and test sets used for training and validation.

Inference

Inference can be ran using a pre-trained model included in the package or a custom model trained using the train command. The input file must be a CSV file containing the following columns:

  • compound_name: The name of the compound.
  • SMILES: The SMILES representation of the compound.
  • visc_mPas_exp: OPTIONAL. The reference viscosity of the compound in mPa·s. If provided, the error between predicted and reference values will be calculated and included in the output.
aitw-viscosity-surrogate chemberta-residuals inference --help
aitw-viscosity-surrogate chemberta-residuals inference \
  --input-file examples/dataset.csv \
  --output-file chemberta_residuals_predictions.csv

It will produce a CSV file containing the predicted log-viscosity values for the input compounds.

The chemberta_model_residuals.pt file included in the package was trained on the dataset provided in examples/dataset.csv.

ChemBERTa residual training performance

4. Ensemble: Combining XGBoost and Two ChemBERTa Variants

The final approach trains three separate models, an XGBoost regressor, a simple fine-tuned ChemBERTa model, and the residual ChemBERTa-descriptor hybrid, and then searches over weighted combinations of their predictions to find the optimal blend. By systematically testing different weightings across all three models on a held-out test set, this ensemble approach demonstrates that combining diverse modeling strategies, each capturing different aspects of molecular structure, yields more robust and accurate viscosity predictions than any single model in isolation.

Training

The training of all the three previous approaches will be performed in a single command. The only difference is that the XGBoost model will be trained using only the 10 descriptors used in the ChemBERTa residuals approach, instead of the full set of descriptors.

aitw-viscosity-surrogate chemberta train --help
aitw-viscosity-surrogate chemberta train \
  --input-file examples/dataset.csv

The output of the training command contains the files from the three previous approaches, plus the following files:

  • {output_dir}/ensemble_config.json: A JSON file containing the optimal weights for each model in the ensemble.
  • {output_dir}/ensemble_performance.png: A plot of predicted vs. experimental log-viscosity values for the ensemble on the training set.
  • {output_dir}/ensemble_predictions.csv: A CSV file containing the predicted log-viscosity values and errors for the ensemble on the training set.

Inference

Inference can be ran using pre-trained models included in the package or custom models trained using the train command. The input file must be a CSV file containing the following columns:

  • compound_name: The name of the compound.
  • SMILES: The SMILES representation of the compound.
aitw-viscosity-surrogate ensemble inference --help
aitw-viscosity-surrogate ensemble inference \
  --input-file examples/dataset.csv \
  --output-file ensemble_predictions.csv

The output CSV will contain the predicted log-viscosity and viscosity values with all models plus the ensemble prediction denoted with a suffix of _ensemble.

Ensemble training performance

Metadata

Release files for AITW_viscosity_surrogate 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for AITW_viscosity_surrogate 1.0.0
File Size Uploaded Provenance Actions
aitw_viscosity_surrogate-1.0.0.tar.gz 31.5 MB Without provenance Details for aitw_viscosity_surrogate-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for AITW_viscosity_surrogate 1.0.0
File Interpreter ABI Platform Actions
aitw_viscosity_surrogate-1.0.0-py3-none-any.whl Python 3 none any Details for aitw_viscosity_surrogate-1.0.0-py3-none-any.whl

Total release size: 63.1 MB

Release files / aitw_viscosity_surrogate-1.0.0.tar.gz

Download URL aitw_viscosity_surrogate-1.0.0.tar.gz
Size 31.5 MB
Tags Source
SHA-256 checksum
How to use checksums
51b1fb1e9959310f77160e2aa664adee411a0cacd2ccceb32b60b92a6d8a9d0d
BLAKE2b-256 checksum
How to use checksums
aa6225e0c07d019074ed9c0d5bfb490b59630c1aafc76ba8eafcbb9a8185fdf1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.34.2

Release files / aitw_viscosity_surrogate-1.0.0-py3-none-any.whl

Download URL aitw_viscosity_surrogate-1.0.0-py3-none-any.whl
Size 31.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
c504956f770b604b04e4ad7325543e49994c97f1422d0517724b3f26ea59be57
BLAKE2b-256 checksum
How to use checksums
b5b8cee9ac043bf86a26e32b371db35f9208fea77c1f55b43dd98bbcd517ebc0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.34.2

Security for AITW_viscosity_surrogate 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page