Mother-ML - A ML framework that takes care.
Mother is a machine-learning framework for predicting properties of mainly chemical molecules. The major features are:
- 🔬 SMILES preprocessing and standardisation
- 💾 Generation of feature vectors from molecules: RDKit descriptors, Morgan, MACCS and other RDKit fingerprints, and pretrained CheMeleon embeddings
- 📈 Grouping and cross-validation based on chemical similarity, scaffolds or time
- 💻 Model training with CatBoost, random forest and lasso, Gaussian-process CatBoost, learning-to-rank, the tabular foundation models TabPFN and TabICL, and NODE neural networks, plus feature selection
- 🎯 A common uncertainty interface (
predict_uncertainty) across model backends - 🚴 Cross-validation and hyperparameter optimisation of complete pipelines with Optuna
- 🌀 Handling of gene expression data from transcriptomics experiments, including different normalisation techniques
- ✨ Explainability with SHAP for TabICL models (support for other models will follow)
Mother provides methods for each of these steps in the form of sklearn transformer objects. By that, all methods are designed to be easily accessible and usable in a modular way. The methods can be combined to ML workflows with sklearn pipelines, column transformers, and feature unions.
All methods can be used as sklearn transformer or estimator. Combination with other methods, or own methods and models (e.g. using mother preprocessing with other model) is therefore straightforward. To be as compatible as possible, every transformer can be constructed using a dictionary containing the required parameters. However, to provide some convenience to the users, a settings class MotherSettings is provided. This class can be used to store all relevant settings for your ML project.
📖 Documentation: bayer-group.github.io/MotherML
Why Mother?
Mother keeps the parts of a molecular ML workflow connected without requiring you to leave the scikit-learn ecosystem.
- Tune an entire workflow from one place. Mother model wrappers define their own Optuna search spaces, and
PipelineWithHyperparameterRooting,ColumnTransformerWithHyperparameterRooting, andFeatureUnionWithHyperparameterRootingcollect them across nested steps using familiarstep__parameternames. You can therefore tune preprocessing, feature selection, and the final estimator together while retaining scikit-learn composition. - Exchange compatible transformers and estimators. Preprocessing, molecular feature generation, feature selection, cross-validation grouping, and models follow scikit-learn's estimator and transformer interfaces. Mother components work in
Pipeline,ColumnTransformer, andFeatureUnion, and can be combined with your own scikit-learn components. - Use consistent, analysis-ready outputs. Components preserve pandas-friendly tabular data where appropriate.
predict_uncertainty(...)exposes a common prediction and uncertainty schema across model backends, whilemother_cv(...)returns fold-level predictions together with evaluation metadata for straightforward comparison and downstream analysis. - Evaluate chemical models more realistically. Chemistry-aware grouping, including Tanimoto-similarity and Murcko-scaffold groups, makes it practical to use group-aware splits that better test generalisation to dissimilar compounds.
- Choose models without rewriting the workflow. The model registry discovers integrated model wrappers and presents a common interface for CatBoost, random forest, lasso, TabPFN, TabICL and NODE (when their extras are installed), and compatible custom models.
- Make workflows reproducible and configurable.
MotherSettingskeeps input, preprocessing, feature generation, cross-validation, model, and tuning configuration in one validated object that can be loaded from or written to YAML.
Install
Mother supports Python 3.11 to 3.14.
uv add mother-ml
# or
pip install mother-ml
Optional Features and Extras
To keep the package size small, some dependencies are added as optional extras. These extras provide additional functionality for specific use cases:
| Extra | Description | Key Packages | Notes |
|---|---|---|---|
report |
Visualisation and reporting tools | matplotlib, seaborn, plotly, umap-learn, igraph, leidenalg | For plots, cluster reports and Optuna QC |
rna |
Gene expression (transcriptomics) preprocessing | anndata, scanpy | Needed for mother.ml.rna |
clustering |
K-medoids compound clustering | kmedoids | Needed for KMedoidsGroupingFromMols |
torch |
PyTorch | torch | Adds several GB to the environment! |
tabpfn |
TabPFN models | tabpfn, torch | Tabular foundation model; downloads a checkpoint on first use |
tabicl |
TabICL models and SHAP explainability | tabicl[shap], torch, matplotlib | Tabular foundation model; downloads a checkpoint on first use |
node |
NODE neural networks with uncertainty heads | skorch, zuko, torch | Neural oblivious decision ensembles |
chemprop |
CheMeleon / GNN molecular fingerprints | chemprop | Pretrained molecular embeddings |
The extras that pull in torch add several GB to the environment.
Installation Examples
Using pip:
# Install with report generation support
pip install 'mother-ml[report]'
# Install with TabICL support (includes torch)
pip install 'mother-ml[tabicl]'
# Install multiple extras
pip install 'mother-ml[report,tabpfn,tabicl,node]'
Using uv:
# Install with specific extras
uv add mother-ml --extra report --extra tabicl --extra node
Usage
A basic example can be found in the example regression notebook. Other examples are in the examples folder (see Examples below).
🔬 SMILES preprocessing and mol-object generation
SMILES preprocessing is done with the StandardizerTransformer class. The class is used to preprocess SMILES strings to construct a pipeline from SMILES to rdkit mol-objects with:
import pandas as pd
from sklearn import pipeline as sklearn_pipeline
from mother.preprocessing.core import SmilesToMolTransformer, StandardizerTransformer
structure_data = pd.DataFrame(
{
"smiles": [
"CCO",
"CCN",
"c1ccccc1",
"CC(=O)O",
"CC(C)O",
"CCCC",
]
}
)
preprocessor: sklearn_pipeline.Pipeline = sklearn_pipeline.Pipeline(
[
(
"smiles_standardizer",
StandardizerTransformer(
flags=["STANDARDIZE", "DESALT", "NEUTRALIZE"],
smiles_col="smiles",
),
),
("smiles_to_mol", SmilesToMolTransformer(molecule_col="Molecule")),
# Add other column transformations here if needed
],
memory=None,
).set_output(transform="pandas")
mol_data: pd.DataFrame = preprocessor.fit_transform(structure_data)
Customise by changing the flags attribute. All available flags are described in the standardisation docs.
💾 Feature Generation
Mother provides several feature generators, among them MaccsFingerprints, MorganFingerprints, and ChemicalDescriptors:
from sklearn import pipeline as sklearn_pipeline
from mother.feature_generation.core import (
ChemicalDescriptors,
MaccsFingerprints,
MorganFingerprints,
)
feature_generator = sklearn_pipeline.FeatureUnion(
transformer_list=[
("maccs", MaccsFingerprints()),
("morgan", MorganFingerprints()),
("desc", ChemicalDescriptors()),
],
).set_output(transform="pandas")
features: pd.DataFrame = feature_generator.fit_transform(mol_data["Molecule"])
The FeatureUnion class is used to combine the feature generators. Each feature generator can be configured.
Morgan and generic fingerprints are count-based by default; set use_counts=False for bit vectors.
Other RDKit fingerprints (RDKitFP, MorganFP, AtomPairFP, TopologicalTorsionFP) are available through FingerprintsGeneric:
from mother.feature_generation import FingerprintsGeneric
atom_pairs = FingerprintsGeneric(fp_type="AtomPairFP", parameters={"fpSize": 2048})
atom_pair_features = atom_pairs.fit_transform(mol_data["Molecule"])
Pretrained CheMeleon embeddings from a graph neural network are available with the chemprop extra via
CheMeleonFingerprintFactory / CheMeleonFingerprintTransformer; see the
CheMeleon notebook.
📈 Grouping and Cross-Validation
For cross-validation, or test-set selection based on chemical similarity, mother provides transformer classes for
generating groups, for example TanimotoGroupingFromMols:
import mother.cv as cv_module
groups_engine = cv_module.TanimotoGroupingFromMols(similarity_threshold=0.3)
groups: pd.DataFrame = groups_engine.set_output(transform="pandas").fit_transform(mol_data["Molecule"])
These groups can be used, e.g. in the GroupKFold class from the sklearn.model_selection module:
from sklearn.model_selection import GroupKFold
cv = GroupKFold(n_splits=3)
Other grouping strategies:
| Class | Groups molecules by | Typical use |
|---|---|---|
TanimotoGroupingFromMols |
Tanimoto similarity clusters (sphere exclusion) | Default for testing generalisation to dissimilar compounds |
MurckoScaffoldGroupingFromMols |
Bemis-Murcko scaffold | Testing generalisation to new scaffolds |
TimeSeriesGrouping |
Time / date column | Prospective validation (train on the past, test on the future) |
HdbscanGroupingFromMols, KMedoidsGroupingFromMols (in mother.cv.core) |
Density- or medoid-based clusters | Alternative cluster-based splits; k-medoids needs the clustering extra |
DefaultGrouping |
No grouping (one group per row) | Random splits |
💻 Model Training
The standard model setup of Mother consists of a feature selection, and a classification- or regression
model. Both are based on Catboost. The standard setup for a regression task would be:
import mother.pipeline_utils as mother_takes_care
from mother import ml
model_settings = {
"feature_selection_flags": ["DROP_CORRELATED", "DROP_CONSTANT", "DROP_DUPLICATES"],
"correlation_threshold": 0.9,
"categorical_features": [],
"feature_selection_type": "catboost",
"model_type": "regression",
"target_type": "single_target",
}
pipeline_settings = {
"remainder": "drop",
"verbose_feature_names_out": False,
}
model = ml.PipelineWithHyperparameterRooting(
[
(
"feature_selector",
mother_takes_care.get_feature_selection_pipeline(
settings=model_settings,
pipeline_settings=pipeline_settings,
data=features,
cv=cv,
).set_output(transform="pandas"),
),
(
"ml_model",
ml.CatboostRegressorMother(
target_type="single_target",
logging_level="Silent",
random_seed=42,
iterations=10,
),
),
]
)
targets = pd.Series([0.2, 0.4, 0.7, 1.1, 1.5, 2.0], name="target")
model.fit(features, targets)
Here, we use the extended sklearn pipeline PipelineWithHyperparameterRooting for some additional methods for hyperparameter
tuning.
Without feature selection, this is simplified:
model = ml.CatboostRegressorMother(target_type="single_target", logging_level="Silent")
Any other sklearn model, or own model can be used instead of CatboostRegressorMother. An example, on how a custom
preprocessing step is added to the model, can be found in the
example notebook on custom preprocessing.
Available models
| Algorithm key | Model class | Unique selling points | Extra |
|---|---|---|---|
catboost |
CatboostRegressorMother |
Strong, fast default for tabular and fingerprint data; handles categorical features and missing values natively; multi-target regression with missing labels (MultiRMSEWithMissingValues); data and knowledge uncertainty with RMSEWithUncertainty and virtual ensembles |
— |
catboost |
CatboostClassifierMother |
Binary, multiclass and multi-label classification; tunes Logloss against Focal loss for imbalanced data; balanced class weights by default; knowledge uncertainty from virtual ensembles (binary, single target) | — |
catboost |
CatboostGaussianProcessRegressorMother |
Gaussian-process-like knowledge uncertainty from an ensemble of posterior samples (Ustimenko et al.); scales to large datasets and many or mixed features where an exact Gaussian process becomes impractical | — |
catboost |
CatboostRankerMother |
Learning-to-rank within groups (e.g. series or assays) with YetiRank, PairLogit and other ranking losses; returns ranks and uncertainty; useful when only the order matters or measurements are not comparable across groups | — |
randomforest |
RandomForestRegressorMother |
Robust baseline that needs little tuning; quantile regression forest, so it predicts arbitrary quantiles and prediction intervals without assuming a distribution | — |
randomforest |
RandomForestClassifierMother |
Robust, low-variance classification baseline with balanced class weights; hard to overfit on small datasets | — |
lasso |
LassoRegressorMother, LassoClassifierBinaryMother, LassoClassifierMulticlassMother |
Sparse linear models: fast, interpretable coefficients and built-in feature selection; good baseline for small datasets with many features (e.g. gene expression) | — |
tabpfn |
TabPFNRegressorMother, TabPFNClassifierMother |
Pretrained tabular foundation model: strong accuracy on small datasets (up to about 10,000 samples) with little or no tuning; regression uncertainty from predicted quantiles; embeddings via TabPFNEmbeddingTransformer |
tabpfn |
tabicl |
TabICLRegressorMother, TabICLClassifierMother |
Pretrained in-context-learning foundation model that scales to larger tables than TabPFN; SHAP explanations via explain and plot_shap; regression uncertainty from predicted quantiles; embeddings via TabICLEmbeddingTransformer |
tabicl |
node |
NODERegressor, NODEClassifier |
Differentiable decision-tree ensembles (neural oblivious decision ensembles); full predictive distributions with normalising-flow heads; data and knowledge uncertainty via MC dropout (BALD or BALSA-EMD); multi-target, categorical features and learned embeddings | node |
The model registry lists what is available in your environment and returns model classes by algorithm and task:
from mother import ml
print(ml.get_available_algorithms())
regressor_class = ml.get_model_class_by_algorithm_and_type("catboost", "regression")
Own models can be registered with the @ml.register_model decorator; see the
models documentation.
🎯 Uncertainty
Models that support it implement predict_uncertainty, which returns one table with the same columns for every backend:
pred, mean_predictions, knowledge_uncertainty (epistemic: lack of similar training data),
data_uncertainty (aleatoric: noise in the labels) and total_uncertainty. Columns a model does not estimate are left empty.
uncertainty_model = ml.CatboostRegressorMother(
target_type="single_target",
loss_function="RMSEWithUncertainty",
logging_level="Silent",
iterations=100,
)
uncertainty_model.fit(features, targets)
uncertainty = uncertainty_model.predict_uncertainty(features)
Which uncertainty a model provides depends on the backend. CatBoost uses virtual ensembles and, with RMSEWithUncertainty,
also a data uncertainty. CatboostGaussianProcessRegressorMother gives a Gaussian-process knowledge uncertainty. The random
forest regressor is a quantile regression forest, TabPFN and TabICL predict quantiles, and NODE uses MC dropout or a normalising-flow head.
See the uncertainty interface notebook.
Cross-validation
Having used any sklearn pipeline, or sklearn estimator or transformer classes, we can use the sklearn
methods for e.g. cross-validation (cross_validate):
from sklearn.model_selection import cross_validate
cross_validate(model, features, targets, groups=groups.values.ravel(), cv=cv, n_jobs=1)
A more convenient method is provided by mother. It returns the out-of-fold predictions, and the uncertainties if the model supports them, together with the fold and group of each row:
import mother.pipeline_utils as mother_takes_care
mother_takes_care.mother_cv(
estimator=model,
X=features,
y=targets,
groups=groups,
cv=cv,
)
🚴 Hyperparameter Optimization
The Mother object MotherTuner uses optuna to optimize hyperparameters:
import mother.optimization as opt
tuner = opt.MotherTuner(
scorer="r2",
n_trials_optuna=2,
n_threads_optuna=1,
)
model_tuned = tuner.optimize(
model,
features,
targets,
cv,
groups=groups.values.ravel(),
)
The function model.get_hyperparameter_space returns the hyperparameter space for the model. It is implemented for all
Mother models and is collected automatically through PipelineWithHyperparameterRooting and the other
*WithHyperparameterRooting classes.
For examples, on how to customize the hyperparameter optimization, or define hyperparameters for your own models, see the example notebook.
✨ Explainability
TabICL models provide SHAP values directly (with the tabicl extra):
from mother.ml.models.m_tabicl import TabICLRegressorMother
tabicl_model = TabICLRegressorMother().fit(features, targets)
tabicl_model.explain(features.iloc[:5], max_evals=2 * features.shape[1] + 1)
tabicl_model.plot_shap(kind="beeswarm")
🌀 Handling Gene expression data from transcriptomics experiments including different normalisation techniques
The RNA processing pipeline is implemented in the RNA class, which incorporates various preprocessing steps tailored for RNA sequencing data. All RNA code can be found in the rna.py file and needs the rna extra.
The pipeline includes normalization, feature selection, and discretization, utilizing the power of the scikit-learn framework. The normalization methods available are "Scanpy," "UQ," "CUF," and "CPM.". You can customise the pipeline to your needs, or try different normalisation methods and bin sizes in hyper-parameter tuning. The pipeline can be fitted and re-applied to avoid data-leakage during the normalisation.
Here's how to set up and use the RNA processing pipeline:
from mother.ml.rna import RNA
import numpy as np
import pandas as pd
rna_model = RNA(
n_features=3, # Number of features (=genes) to keep for the prediction.
n_bins=20, # Number of bins to use for the discretisation of the target variable.
normalisation_method="UQ", # Which normalisation to use
)
rng = np.random.default_rng(42)
rna_data_train = pd.DataFrame(
rng.integers(0, 200, size=(20, 8)),
columns=[f"gene_{i}" for i in range(8)],
)
rna_data_test = pd.DataFrame(
rng.integers(0, 200, size=(5, 8)),
columns=rna_data_train.columns,
)
y_train = (rna_data_train["gene_0"] > 100).astype(int).rename("class")
# Fit the pipeline to your RNA sequencing data
transformed_train_data: pd.DataFrame = rna_model.fit_transform(rna_data_train, y_train)
transformed_test_data: pd.DataFrame = rna_model.transform(rna_data_test)
A complete walkthrough of the RNA functionality is found in the example notebook.
Examples
The example notebooks are grouped by topic:
| Folder | Topics |
|---|---|
01_basics |
Framework overview, configuration with MotherSettings, custom preprocessing, compound clustering, the prediction and uncertainty interface |
02_regression |
CatBoost and random forest regression, regression with uncertainty, multi-task models, TabICL |
03_classification |
Lasso, binary classification with uncertainty, ordinal classification, TabICL |
04_feature_engineering |
Feature selection, Boruta, RNA preprocessing, CheMeleon fingerprints |
05_advanced |
Custom hyperparameter optimisation, TabPFN, learning-to-rank, NODE, CheMeleon with CatBoost, TabICL embeddings |
Contributing
Contributions are welcome. See CONTRIBUTING.md for the pull-request workflow and the development docs for setting up the environment, running the tests and the conventional-commit messages used for automatic releases.
Acknowledgements
Thank you to the following contributors:
- Thomas Wolf
- Lukas Hebing
- Kai Sommer
and all the others.
Metadata
Release files for mother-ml 3.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mother_ml-3.1.3.tar.gz | 222.5 kB | With provenance | Details for mother_ml-3.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mother_ml-3.1.3-py3-none-any.whl | Python 3 | none | any | Details for mother_ml-3.1.3-py3-none-any.whl |
Total release size: 452.2 kB
Release files / mother_ml-3.1.3.tar.gz
| Download URL | mother_ml-3.1.3.tar.gz |
|---|---|
| Size | 222.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8c9d1af9ba787c76905d719b4c4df37e2c2b065d080031f70204c14117b60c4a
|
|
BLAKE2b-256 checksum How to use checksums |
28be85932e7bd67a46b8d5538d68526b8f861e5ea900f6ac45ab62000cccc66e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logRelease files / mother_ml-3.1.3-py3-none-any.whl
| Download URL | mother_ml-3.1.3-py3-none-any.whl |
|---|---|
| Size | 229.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
703f985065afaf7066e71011821d5093f4f6a9a3a5136aba88101450cfd3d47d
|
|
BLAKE2b-256 checksum How to use checksums |
2884e26c037bed6de4dcffa7ab7c4d3ec2c69158e95adb9416105dc256797da8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logSecurity for mother-ml 3.1.3
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for mother_ml-3.1.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logA 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.