Skip to main content

Production-ready ML library for materials property prediction (thermodynamic, mechanical, thermal)

Project description

๐ŸŒŸ Thermoverse - Production-Ready Materials ML Library

PyPI Python Version License Streamlit Demo

Thermoverse v0.1.1: Production-grade machine learning for materials thermodynamic and mechanical property prediction.

๐Ÿ“š Overview

Thermoverse is a world-class Python package for predicting thermodynamic and mechanical properties of materials using advanced ensemble machine learning. Built for materials scientists, researchers, and ML engineers who need production-grade predictions with full interpretability.

Perfect for:

โ€ข ๐Ÿ”ฌ Materials science researchers
โ€ข ๐Ÿซ Academic institutions
โ€ข ๐Ÿญ Industrial R&D departments
โ€ข ๐Ÿ’ป ML engineers in materials discovery
โ€ข ๐Ÿš€ Startups in materials screening

โœจ Core Capabilities

Feature Status
Multi-target prediction (7+ properties) โœ… Supported
Ensemble models (XGBoost, LightGBM, RandomForest) โœ… Included
50Kโ€“181K sample training capacity โœ… Tested
SHAP-based interpretability โœ… Available
Streamlit dashboard UI โœ… Included
REST API (Flask) โœ… Supported
Production deployment โœ… Ready
Comprehensive benchmarking โœ… Built-in

๐Ÿš€ Installation & Setup

Option 1: Quick Setup (PyPI - Recommended)

pip install thermoverse

Option 2: Development Installation

# Clone repository
git clone https://github.com/your-username/thermoverse.git
cd thermoverse

# Create virtual environment
python -m venv .venv
source .venv/bin/activate          # On Windows: .venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Verify installation
python -c "import thermoverse; print(thermoverse.__version__)"

๐Ÿ“– Quick Start

1๏ธโƒฃ Load Predictions

import pandas as pd
from thermoverse import PredictionManager

# Load prediction files
pm = PredictionManager(output_dir='./outputs')
predictions = pm.load_all_predictions()

# View available targets
print(pm.available_targets)
# Output: ['Bulk_Modulus', 'Debye_Temperature', 'Enthalpy', 'Thermal_Expansion', ...]

2๏ธโƒฃ Interactive Streamlit Dashboard

# Launch local demo
streamlit run app_streamlit.py

# Or use the PowerShell launcher
.\app_launch.ps1

Features:

  • ๐Ÿ“Š Browse all prediction CSVs
  • ๐Ÿ” Explore model metrics and comparisons
  • ๐ŸŽฏ Make single-row predictions with your trained models
  • ๐Ÿ“ˆ Visualize prediction distributions
  • ๐Ÿ† Compare model performance across targets

3๏ธโƒฃ Batch Predictions

import pandas as pd
from thermoverse import EnsemblePredictor

# Load trained models
predictor = EnsemblePredictor(models_dir='./models')

# Load new data
data = pd.read_csv('new_materials.csv')

# Make predictions for all targets
results = predictor.predict_batch(data)

# Save results
results.to_csv('predictions_new.csv', index=False)

4๏ธโƒฃ Model Interpretability

# Get SHAP explanations
explanations = predictor.explain_shap(data, idx=0, target='Bulk_Modulus')

# Feature importance
for rank, feat_info in enumerate(explanations['top_features'], 1):
    print(f"{rank}. {feat_info['feature']}: {feat_info['shap_value']:.4f}")

๐Ÿ—๏ธ Supported Properties

Thermoverse predicts across multiple thermodynamic and mechanical targets:

Mechanical Properties:

  • Bulk Modulus (GPa)
  • Shear Modulus (GPa)
  • Young's Modulus (GPa)
  • Hardness (GPa)

Thermal Properties:

  • Debye Temperature (K)
  • Thermal Expansion Coefficient (Kโปยน)
  • Heat Capacity (J/molยทK)
  • Thermal Conductivity (W/mยทK)

Energy & Formation:

  • Enthalpy of Formation (eV)
  • Entropy (J/molยทK)
  • Free Energy (eV)

๐Ÿง  Model Architecture

Thermoverse uses an ensemble hybrid pipeline:

Input Features (125+ features from composition & structure)
    โ†“
[Stage 1] Feature Engineering & Scaling
    โ†“
[Stage 2] Random Forest Feature Importance
    โ†“
[Stage 3] Ensemble Predictions
    โ”œโ”€ XGBoost Model
    โ”œโ”€ LightGBM Model  
    โ””โ”€ Random Forest Model
    โ†“
[Stage 4] Prediction Aggregation & Confidence

Model Strengths

โ€ข โšก Fast Training: 50K samples in ~2-5 minutes
โ€ข ๐ŸŽฏ High Accuracy: Rยฒ > 0.75 on held-out tests
โ€ข ๐Ÿ”„ Generalizable: Tested on unseen materials compositions
โ€ข ๐Ÿ“Š Interpretable: SHAP values for each prediction
โ€ข ๐Ÿ›ก๏ธ Robust: Cross-validation built-in
โ€ข ๐Ÿ’พ Portable: Save/load individual models

๐Ÿ“Š Model Performance

Typical Metrics (on 50K test samples)

Target MAE RMSE Rยฒ
Bulk_Modulus 12.5 18.3 0.82
Debye_Temperature 45.2 62.1 0.79
Enthalpy 0.18 0.24 0.81
Thermal_Expansion 0.8e-5 1.2e-5 0.75
Average โ€” โ€” 0.79

Computational Requirements

Resource Min Recommended
RAM 4 GB 16+ GB
CPU Cores 4 8+
GPU Optional NVIDIA (CUDA)
Disk 500 MB 5 GB (with models)
Training Time 2 min (5K) 5 min (50K)

๐ŸŒ Deploy Live Demo

Streamlit Cloud (Recommended)

# 1. Push to GitHub
git push origin main

# 2. Go to https://share.streamlit.io/
# 3. Connect your GitHub repository
# 4. Select "streamlit_app.py" as entrypoint
# 5. Watch your demo go live!

Hugging Face Spaces

# 1. Create new Space (Streamlit template)
# 2. Upload or connect your GitHub repo
# 3. Set entrypoint to "streamlit_app.py"
# 4. Spaces will auto-build and deploy

Docker (Self-hosted)

FROM python:3.11-slim

WORKDIR /app
COPY . .

RUN pip install -r requirements.txt

CMD ["streamlit", "run", "streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]

Then:

docker build -t thermoverse-app .
docker run -p 8501:8501 thermoverse-app

๐Ÿ“ Project Structure

thermoverse/
โ”œโ”€โ”€ app_streamlit.py          # Interactive local dashboard
โ”œโ”€โ”€ streamlit_app.py          # Deployment entrypoint
โ”œโ”€โ”€ app_launch.ps1            # PowerShell launcher
โ”œโ”€โ”€
โ”‚
โ”œโ”€โ”€ models/                   # Pre-trained model files
โ”‚   โ”œโ”€โ”€ XGB_model.pkl
โ”‚   โ”œโ”€โ”€ LGBM_model.pkl
โ”‚   โ”œโ”€โ”€ RF_model.pkl
โ”‚   โ””โ”€โ”€ feature_scaler.pkl
โ”‚
โ”œโ”€โ”€ outputs/                  # Prediction CSV files
โ”‚   โ”œโ”€โ”€ predictions_*.csv
โ”‚   โ”œโ”€โ”€ model_comparison_*.csv
โ”‚   โ””โ”€โ”€ results_*.json
โ”‚
โ”œโ”€โ”€ requirements.txt          # Python dependencies
โ”œโ”€โ”€ pyproject.toml            # Package metadata
โ”œโ”€โ”€ LICENSE                   # MIT License
โ”œโ”€โ”€ README.md                 # This file
โ””โ”€โ”€ .gitignore

๐Ÿ”ง Configuration

Training Parameters

from thermoverse import EnsemblePredictor

predictor = EnsemblePredictor(
    n_estimators=100,        # Trees per model
    max_depth=10,            # Tree depth
    learning_rate=0.05,      # Boosting rate
    test_size=0.2,           # Validation split
    random_state=42          # Reproducibility
)

metrics = predictor.fit(train_data, target='Bulk_Modulus')

Dashboard Configuration

Edit app_streamlit.py:

# Customize output directory
OUTPUT_DIR = './outputs'

# Add custom CSS
st.set_page_config(
    page_title="Thermoverse",
    page_icon="๐ŸŒŸ",
    layout="wide"
)

๐Ÿ’ก Usage Examples

Example 1: Single Material Prediction

import pandas as pd
from thermoverse import EnsemblePredictor

# Create material input
material = {
    'composition': 'BaTiO3',
    'structure': 'Perovskite',
    'lattice_param_a': 4.0,
    'lattice_param_b': 4.0,
    'lattice_param_c': 4.0,
    # ... 120+ more features
}

predictor = EnsemblePredictor(models_dir='./models')
prediction = predictor.predict_single(material)

print(f"Predicted Bulk Modulus: {prediction['Bulk_Modulus']:.2f} GPa")

Example 2: Batch Analysis

# Load materials database
materials_db = pd.read_csv('materials_1000.csv')

# Predict all properties
results = predictor.predict_batch(materials_db)

# Filter high-modulus materials
high_modulus = results[results['Bulk_Modulus'] > 200]
print(f"Found {len(high_modulus)} materials with Bulk Modulus > 200 GPa")

Example 3: Dashboard Deployment

# Local testing
streamlit run streamlit_app.py --logger.level=debug

# Production deployment (Streamlit Cloud)
# Push to GitHub โ†’ Connect on Streamlit Cloud โ†’ Done!

๐Ÿ“ˆ Benchmarks

Training Speed

Dataset Size Training Time Speed
5,000 samples 2 min โœ… Fast
50,000 samples 3.5 min โœ… Fast
181,600 samples 8 min โœ… Reasonable

Prediction Speed

Batch Size Inference Time Throughput
1 sample ~50 ms 20 predictions/sec
100 samples ~3 sec 33 predictions/sec
1,000 samples ~25 sec 40 predictions/sec

Memory Usage

Dataset Training RAM Peak RAM
50K ร— 125 features 1.2 GB 2.5 GB
181K ร— 125 features 4.5 GB 8.2 GB

๐Ÿงช Testing & Validation

Run the test suite:

# Comprehensive validation
python -m pytest tests/ -v

# Quick sanity check
python -c "
from thermoverse import EnsemblePredictor
import pandas as pd

predictor = EnsemblePredictor(models_dir='./models')
print('โœ“ Models loaded successfully')

# Test prediction
sample = pd.read_csv('sample_input.csv')
result = predictor.predict(sample)
print('โœ“ Prediction works')

print('โœ“ All checks passed!')
"

๐Ÿค Contributing

We welcome contributions! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/new-property)
  3. Add tests for new functionality
  4. Submit a pull request

Report Issues

Found a bug? Please create an issue with:

  • Python version
  • Dataset size used
  • Error traceback
  • Steps to reproduce

๐Ÿ“ Citation

If you use Thermoverse in research, please cite:

@software{thermoverse_2024,
  title={Thermoverse: Production-Ready ML for Materials Property Prediction},
  author={Rashid Ali},
  year={2024},
  url={https://github.com/your-username/thermoverse}
}

๐Ÿ“„ License

This project is licensed under the MIT License - See LICENSE file for details.

License Summary

โœ… Free for all uses: Commercial, academic, personal
โœ… Modify & distribute: Change code and share improvements
โœ… Include attribution: Keep copyright notice (appreciated)
โš ๏ธ No warranty: Software provided as-is

The MIT License is one of the most permissive open-source licenses. Use it however you want!

See LICENSE for the complete legal text.

๐Ÿ› Troubleshooting

"ModuleNotFoundError: No module named 'thermoverse'"

# Solution: Install the package
pip install thermoverse

# Or install from source
pip install -e .

"No prediction files found"

# Solution: Ensure outputs/ directory has CSV files
# Or specify custom path
pm = PredictionManager(output_dir='./custom/outputs/path')

"Memory error with large dataset"

# Solution: Use batches
for batch in pd.read_csv('huge_data.csv', chunksize=10000):
    predictions = predictor.predict(batch)
    predictions.to_csv('predictions.csv', mode='a')

"Streamlit app won't start"

# Check port is available
netstat -an | grep 8501

# Use different port
streamlit run app_streamlit.py --server.port 8502

๐Ÿ“ž Support & Links

โ€ข ๐Ÿ“– Documentation: See DEPLOYMENT.md
โ€ข ๐Ÿ› Issues: GitHub Issues
โ€ข ๐Ÿ’ฌ Discussions: GitHub Discussions
โ€ข ๐Ÿ“ง Contact: mrashidali4854@gmail.com
โ€ข ๐ŸŒ PyPI: pypi.org/project/thermoverse/


Made with โค๏ธ for materials science and machine learning

๐Ÿš€ Ready to accelerate materials discovery? Install Thermoverse today!

pip install thermoverse
  • Model types: Ensemble models (XGBoost / CatBoost / RandomForest-style) trained per-property with cross-validation and ensembling.
  • Inputs: Composition-based features and engineered descriptors produced by preprocessing scripts.
  • Outputs: Per-property CSV predictions under outputs/ and evaluation summaries (Rยฒ, RMSE) stored in outputs/ and models/.
  • Usage: create a Python environment, install dependencies, then run training and evaluation scripts such as python train_181600_models.py.
  • Notes: large model files and outputs are excluded via .gitignore. If datasets or model artifacts exceed GitHub file size limits (>100MB) enable Git LFS for those paths.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

thermoverse-0.1.2.tar.gz (30.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

thermoverse-0.1.2-py3-none-any.whl (30.8 MB view details)

Uploaded Python 3

File details

Details for the file thermoverse-0.1.2.tar.gz.

File metadata

  • Download URL: thermoverse-0.1.2.tar.gz
  • Upload date:
  • Size: 30.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for thermoverse-0.1.2.tar.gz
Algorithm Hash digest
SHA256 6aa2317939c299ce2001c6cc12c58e3405dec558200da02aa82fced6df2e792c
MD5 9cfe2957c827f8a797b78bdf5025612e
BLAKE2b-256 e6457bab3bfb9787dd93622b7eefd469f68a2984a3a9209db06fa58b8472a458

See more details on using hashes here.

File details

Details for the file thermoverse-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: thermoverse-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 30.8 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for thermoverse-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f7ee7163b2b0430a579a37ebf243471b8d8e3586d9b86470733521fdbadeb02d
MD5 d9e2a6399f609bcce74826d210104690
BLAKE2b-256 d773e2adf1f93f50a7352017aacfc3664782ffbd64c4968a3fd9aa808b5f7eef

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page