Skip to main content

AutoPrognosis - A system for automating the design of predictive modeling pipelines tailored for clinical prognosis.

Tests Tutorials Test In Colab Test In Colab License

image

🔑 Features

  • 🚀Automatically learns ensembles of pipelines for classification or survival analysis.
  • 🌀 Easy to extend pluginable architecture.
  • 🔥 Interpretability tools.

🚀Installation

Using pip

The library can be installed from PyPI using

$ pip install autoprognosis

or from source, using

$ pip install .

AutoPrognosis can use Redis as a backend to improve the performance and quality of the searches.

For that, install the redis-server package following the steps described on the official site.

💥 Sample Usage

More advanced use cases can be found on our tutorials section.

List the available classifiers

from autoprognosis.plugins.prediction.classifiers import Classifiers
print(Classifiers().list_available())

Create a study for classifiers

from pathlib import Path

from sklearn.datasets import load_breast_cancer

from autoprognosis.studies.classifiers import ClassifierStudy
from autoprognosis.utils.serialization import load_model_from_file
from autoprognosis.utils.tester import evaluate_estimator


X, Y = load_breast_cancer(return_X_y=True, as_frame=True)

df = X.copy()
df["target"] = Y

workspace = Path("workspace")
study_name = "example"

study = ClassifierStudy(
    study_name=study_name,
    dataset=df,  # pandas DataFrame
    target="target",  # the label column in the dataset
    num_iter=100,  # how many trials to do for each candidate
    timeout=60,  # seconds
    classifiers=["logistic_regression", "lda", "qda"],
    workspace=workspace,
)

study.run()

output = workspace / study_name / "model.p"
model = load_model_from_file(output)

metrics = evaluate_estimator(model, X, Y)

print(f"model {model.name()} -> {metrics['clf']}")

List available survival analysis estimators

from autoprognosis.plugins.prediction.risk_estimation import RiskEstimation
print(RiskEstimation().list_available())

Survival analysis study

# stdlib
import os
from pathlib import Path

# third party
import numpy as np
from pycox import datasets

# autoprognosis absolute
from autoprognosis.studies.risk_estimation import RiskEstimationStudy
from autoprognosis.utils.serialization import load_model_from_file
from autoprognosis.utils.tester import evaluate_survival_estimator

df = datasets.gbsg.read_df()
df = df[df["duration"] > 0]

X = df.drop(columns = ["duration"])
T = df["duration"]
Y = df["event"]

eval_time_horizons = np.linspace(T.min(), T.max(), 5)[1:-1]

workspace = Path("workspace")
study_name = "example_risks"

study = RiskEstimationStudy(
    study_name=study_name,
    dataset=df,
    target="event",
    time_to_event="duration",
    time_horizons=eval_time_horizons,
    num_iter=10,
    num_study_iter=1,
    timeout=10,
    risk_estimators=["cox_ph", "survival_xgboost"],
    score_threshold=0.5,
    workspace=workspace,
)

study.run()

output = workspace / study_name / "model.p"

model = load_model_from_file(output)
metrics = evaluate_survival_estimator(model, X, T, Y, eval_time_horizons)

print(f"Model {model.name()} score: {metrics['clf']}")

🔆 Tutorials

Plugins

AutoML

Building a demonstrator

⚡ Plugins

Imputation methods

from autoprognosis.plugins.imputers import  Imputers

imputer = Imputers().get(<NAME>)
Name Description
hyperimpute Iterative imputer using both regression and classification methods based on linear models, trees, XGBoost, CatBoost and neural nets
mean Replace the missing values using the mean along each column with SimpleImputer
median Replace the missing values using the median along each column with SimpleImputer
most_frequent Replace the missing values using the most frequent value along each column with SimpleImputer
missforest Iterative imputation method based on Random Forests using IterativeImputer and ExtraTreesRegressor
ice Iterative imputation method based on regularized linear regression using IterativeImputer and BayesianRidge
mice Multiple imputations based on ICE using IterativeImputer and BayesianRidge
softimpute Low-rank matrix approximation via nuclear-norm regularization
EM Iterative procedure which uses other variables to impute a value (Expectation), then checks whether that is the value most likely (Maximization) - EM imputation algorithm
gain GAIN: Missing Data Imputation using Generative Adversarial Nets

Preprocessing methods

from autoprognosis.plugins.preprocessors import Preprocessors

preprocessor = Preprocessors().get(<NAME>)
Name Description
maxabs_scaler Scale each feature by its maximum absolute value. MaxAbsScaler
scaler Standardize features by removing the mean and scaling to unit variance. - StandardScaler
feature_normalizer Normalize samples individually to unit norm. Normalizer
normal_transform Transform features using quantiles information.QuantileTransformer
uniform_transform Transform features using quantiles information.QuantileTransformer
minmax_scaler Transform features by scaling each feature to a given range.MinMaxScaler

Classification

from autoprognosis.plugins.prediction.classifiers import Classifiers

classifier = Classifiers().get(<NAME>)
Name Description
neural_nets PyTorch based neural net classifier.
logistic_regression LogisticRegression
catboost Gradient boosting on decision trees - CatBoost
random_forest A random forest classifier. RandomForestClassifier
tabnet TabNet : Attentive Interpretable Tabular Learning
xgboost XGBoostClassifier

Survival Analysis

from autoprognosis.plugins.prediction.risk_estimation import RiskEstimation

predictor = RiskEstimation().get(<NAME>)
Name Description
survival_xgboost XGBoost Survival Embeddings
loglogistic_aft Log-Logistic AFT model
deephit DeepHit: A Deep Learning Approach to Survival Analysis with Competing Risks
cox_ph Cox’s proportional hazard model
weibull_aft Weibull AFT model.
lognormal_aft Log-Normal AFT model
coxnet CoxNet is a Cox proportional hazards model also referred to as DeepSurv

Regression

from autoprognosis.plugins.prediction.regression import Regression

regressor = Regression().get(<NAME>)
Name Description
tabnet_regressor TabNet : Attentive Interpretable Tabular Learning
catboost_regressor Gradient boosting on decision trees - CatBoost
random_forest_regressor RandomForestRegressor
xgboost_regressor XGBoostClassifier
neural_nets_regression PyTorch-based neural net regressor.
linear_regression LinearRegression

Explainers

from autoprognosis.plugins.explainers import Explainers

explainer = Explainers().get(<NAME>)
Name Description
risk_effect_size Feature importance using Cohen's distance between probabilities
lime Lime: Explaining the predictions of any machine learning classifier
symbolic_pursuit [Symbolic Pursuit](Learning outside the black-box: at the pursuit of interpretable models)
shap_permutation_sampler SHAP Permutation Sampler
kernel_shap SHAP KernelExplainer
invase INVASE: Instance-wise Variable Selection

Uncertainty

from autoprognosis.plugins.uncertainty import UncertaintyQuantification
model = UncertaintyQuantification().get(<NAME>)
Name Description
cohort_explainer
conformal_prediction
jackknife

🔨 Test

After installing the library, the tests can be executed using pytest

$ pip install .[testing]
$ pytest -vxs -m "not slow"

Citing

If you use this code, please cite the associated paper:

TODO

References

  1. AutoPrognosis: Automated Clinical Prognostic Modeling via Bayesian Optimization with Structured Kernel Learning
  2. Prognostication and Risk Factors for Cystic Fibrosis via Automated Machine Learning
  3. Cardiovascular Disease Risk Prediction using Automated Machine Learning: A Prospective Study of 423,604 UK Biobank Participants

Metadata

Release files for autoprognosis 0.1.2

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

Built distributions (wheels)

Table of built distributions (wheels) for autoprognosis 0.1.2
File Interpreter ABI Platform Actions
autoprognosis-0.1.2-py2.py3-none-macosx_10_14_x86_64.whl Python 3, Python 2 none macOS 10.14+ x86-64 Details for autoprognosis-0.1.2-py2.py3-none-macosx_10_14_x86_64.whl
autoprognosis-0.1.2-py2.py3-none-any.whl Python 2, Python 3 none any Details for autoprognosis-0.1.2-py2.py3-none-any.whl

Total release size: 467.3 kB

Release files / autoprognosis-0.1.2-py2.py3-none-macosx_10_14_x86_64.whl

Download URL autoprognosis-0.1.2-py2.py3-none-macosx_10_14_x86_64.whl
Size 232.5 kB
Tags Python 2 Python 3 macOS 10.14+ x86-64
SHA-256 checksum
How to use checksums
ee5f9086ab36c2ad5957cd699736a94f23baa84454d0788a65aa91037960f2eb
BLAKE2b-256 checksum
How to use checksums
b738520172f953d08555e28f332730cc9fafeb47d58bde42c1825718e79623fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.14

Release files / autoprognosis-0.1.2-py2.py3-none-any.whl

Download URL autoprognosis-0.1.2-py2.py3-none-any.whl
Size 234.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
f3099f960f05c197a1fb36e72c5183513a00c2402312ab38ea4d51f3b9e14ce1
BLAKE2b-256 checksum
How to use checksums
8cbdcd9e273bfc477d64c61948d5c000fe56f13489f02d4eb552589ceb475f98
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Security for autoprognosis 0.1.2

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.

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