Skip to main content

jarvAIs: just a really versatile AI service

Project description

jarvAIs

DOI BUILD DOCS CI tests

Overview

jarvAIs is a Python package designed to automate and enhance machine learning workflows. The primary goal of this project is to reduce redundancy in repetitive tasks, improve consistency, and elevate the quality of standardized processes in oncology research.

Follow pixi installation process found here

  1. Clone Repo and Navigate

    git clone https://github.com/pmcdi/jarvais.git
    cd jarvais
    
  2. Install Dependencies

    pixi install
    

Modules

This package consists of 3 different modules:

  • Analyzer: A module that analyzes and processes data, providing valuable insights for downstream tasks.
  • Trainer: A module for training machine learning models, designed to be flexible and efficient.
  • Explainer: A module that explains model predictions, offering interpretability and transparency in decision-making.

Analyzer

The Analyzer module is designed for data visualization and exploration. It helps to gain insights into the data, identify patterns, and assess relationships between different features, which is essential for building effective models.

Example Usage

from jarvais.analyzer import Analyzer

analyzer = Analyzer(data, target_variable='target', output_dir='.')
analyzer.run()

Example Output

Feature Types:
  - Categorical: ['Gender', 'Disease Type', 'Treatment']
  - Continuous: ['Age', 'Tumor Size']

Outlier Detection:
  - Outliers found in Gender: ['Male: 5 out of 1000']
  - Outliers found in Disease Type: ['Lung Cancer: 10 out of 1000']
  - No Outliers found in Treatment
  - Outliers found in Tumor Size: ['12.5: 2 out of 1000']
TableOne(Data Summary):
Feature Category Missing Overall
n 1000
Age, mean (SD) 0 58.2 (12.3)
Tumor Size, mean (SD) 0 4.5 (1.2)
Gender, n (%) Female 520 (52%)
Male 480 (48%)
Disease Type, n (%) Breast Cancer 300 (30%)
Lung Cancer 150 (15%)
Prostate Cancer 100 (10%)

Output Files:

The Analyzer module generates the following files and directories:

  • analysis_report.pdf: A PDF report summarizing the analysis results.
  • config.yaml: Configuration file for the analysis setup.

Figures:

  • frequency_tables: Contains visualizations comparing different categorical features.

  • multiplots: Visualizations showing combinations of features for deeper analysis.

  • Additional Figures:

    • pairplot.png: Pairwise relationships between continuous variables.
    • pearson_correlation.png: Pearson correlation matrix.
    • spearman_correlation.png: Spearman correlation matrix.
    • umap_continuous_data.png: UMAP visualization of continuous data.
  • Data Files:

    • tableone.csv: CSV file containing summary statistics for the dataset.
    • updated_data.csv: CSV file with the cleaned and processed data.

Trainer Module

The Trainer module simplifies and automates the process of feature reduction, model training, and evaluation for various machine learning tasks, ensuring flexibility and efficiency.

Key Features

  1. Feature Reduction:
    • Supports methods such as mrmr, variance_threshold, corr, and chi2 to identify and retain relevant features.
  2. Automated Model Training:
    • Integrates with AutoGluon for model training, selection, and optimization.
    • Handles tasks such as binary classification, multiclass classification, regression, and survival.

Example Usage

from jarvais.trainer import TrainerSupervised

trainer = TrainerSupervised(task='binary', output_dir='./trainer_outputs')
trainer.run(data=data, target_variable='target', save_data=True)

Example Output

Training fold 1/5...  
Fold 1 score: `0.8467207586933614`

Training fold 2/5...  
Fold 2 score: `0.8487846136306914`
...
Model Leaderboard

Displays values in mean [min, max] format across training folds.

Model Score Test Score Val Score Train
WeightedEnsemble_L2 AUROC: 0.82 [0.82, 0.83] AUROC: 0.85 [0.85, 0.85] AUROC: 1.0 [1.0, 1.0]
F1: 0.13 [0.11, 0.14] F1: 0.09 [0.07, 0.12] F1: 0.95 [0.9, 1.0]
AUPRC: 0.48 [0.45, 0.52] AUPRC: 0.47 [0.44, 0.49] AUPRC: 0.96 [0.91, 1.0]
ExtraTreesGini AUROC: 0.82 [0.82, 0.82] AUROC: 0.84 [0.84, 0.84] AUROC: 1.0 [1.0, 1.0]
F1: 0.21 [0.19, 0.22] F1: 0.16 [0.14, 0.18] F1: 1.0 [1.0, 1.0]
AUPRC: 0.45 [0.45, 0.45] AUPRC: 0.43 [0.41, 0.45] AUPRC: 1.0 [1.0, 1.0]

Explainer Module

The Explainer module is designed to evaluate trained models by generating diagnostic plots, auditing bias, and producing comprehensive reports. It supports various supervised learning tasks, including classification, regression, and survival models.

The module provides an easy-to-use interface for model diagnostics, bias analysis, and feature importance visualization, facilitating deeper insights into the model's performance and fairness.

Features

  • Diagnostic Plots: Generates performance diagnostics, including classification metrics, regression plots, and SHAP value visualizations.
  • Bias Audit: Identifies potential biases in model predictions with respect to sensitive features.
  • Feature Importance: Calculates and visualizes feature importance using permutation importance or model-specific methods.
  • Comprehensive Reports: Creates a detailed PDF report summarizing all diagnostic results.

Example Usage

from jarvais.explainer import Explainer

# Prefered method is to initialize from trainer
exp = Explainer.from_trainer(trainer)
exp.run()

Output Files:

The Explainer module generates the following files and directories:

  • explainer_report.pdf: A PDF report summarizing the model diagnostics, bias audit results, and feature importance.
  • bias/: Contains CSV files with bias metrics for different sensitive features.
  • figures/: Contains diagnostic plots for model evaluation and feature importance.
    • confusion_matrix.png: Visual representation of the model’s confusion matrix.
    • feature_importance.png: A plot visualizing the importance of features used by the model.
    • model_evaluation.png: A visual summary of model evaluation.
    • shap_barplot.png: SHAP value bar plot for model interpretability.
    • shap_heatmap.png: SHAP value heatmap for model interpretability.

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

jarvais-0.10.1.tar.gz (10.0 MB view details)

Uploaded Source

Built Distribution

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

jarvais-0.10.1-py3-none-any.whl (396.6 kB view details)

Uploaded Python 3

File details

Details for the file jarvais-0.10.1.tar.gz.

File metadata

  • Download URL: jarvais-0.10.1.tar.gz
  • Upload date:
  • Size: 10.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for jarvais-0.10.1.tar.gz
Algorithm Hash digest
SHA256 9bb8f33226c883c01afabe7c249bf607bcbf2e47cc0934796aab446a38d2c5c6
MD5 3535f642d6c0c378846f964d0ef482e2
BLAKE2b-256 640194ffc50f37b1a138e0ee8d2f1f7c54bfede92e2c24bae14e60c7cdcbaf97

See more details on using hashes here.

File details

Details for the file jarvais-0.10.1-py3-none-any.whl.

File metadata

  • Download URL: jarvais-0.10.1-py3-none-any.whl
  • Upload date:
  • Size: 396.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for jarvais-0.10.1-py3-none-any.whl
Algorithm Hash digest
SHA256 88a235d8a908fd1156ad64a40a2f8ef78d74592df8d540b64e30af6c0028016c
MD5 e38e7188f4911c9a65c1720971ac023c
BLAKE2b-256 7773e04a46414625efa8398d59b4ff61e3a5eb52b6d658cac7a85125b5550c49

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