Skip to main content

Introduction of BMINet

framework Machine learning and network based tool for:

  • Classify and predict different disease stages precisely
  • Understand machenism using SHAP model explanation
  • Detect Bone-Muscle Interact network and detect disease modules

Install

Dependency

  • Python>=3.9

Quick install

  • Install from pypi: pip install BMINet
  • Or install from GitHub:
git clone https://github.com/Spencer-JRWang/BMINet
cd BMINet
pip install .

Example Usage

  • First, you should prepare your data (from CT or MRI etc.): Example Data
  • Load your data
import pandas as pd
df = pd.read_csv('Example/data.txt', sep='\t')
  • Select features
# Load FeatureSelector
from BMINet.Interaction import FeatureSelector
selector = FeatureSelector(core_name="LightGBM")
# Conduct feature selection from df
selected_features = selector.select(df)

core_name should be "LightGBM", "XGBoost" or "CatBoost"

  • Build linear formula model
from BMINet.Model import Lasso_Formula
formula = Lasso_Formula(df, disease_pairs=("A", "B"))
print(formula)

Also Ridge, ElasticNet and Simple Linear

  • Build stacking model
from BMINet.Interaction import StackingModel
# Load stacking model framework
'''
default: StackingModel(
    base_models = [
            ('LGBM', LGBMClassifier(verbose=-1, n_estimators=1000, max_depth=5)),
            ('XGBoost', XGBClassifier(n_estimators=1000, max_depth=5)),
            ('CatBoost', CatBoostClassifier(verbose=False, iterations=800, max_depth=5))
        ]), 
    meta_model = LogisticRegression()
'''
Model = StackingModel()
best_scores = Model.stacking_model_search(df, selected_features)

Using default base model and meta model, you can also define it yourself

  • Predict of each group
# single predict
single_prediction_score = Model.single_predict("A vs B", [...], use_our_model=True)
# multiple predict
multiple_prediction_score = Model.multiple_predict_predict("A vs B", [[...], [...],], use_our_model=True)

If you use use_our model = True, you are predicting disease staged based on our data and model

If you are researching on a brand new project, use use_our_model = False

  • Basic machine learning plots
from BMINet.plot import plot_ml_roc
plot_ml_roc(best_scores)
from BMINet.plot import plot_precision_recall
plot_precision_recall(best_scores)
from BMINet.plot import plot_score_histogram
plot_score_histogram(best_scores)
from BMINet.plot import plot_calibration_curve
plot_calibration_curve(best_scores)
  • Model Explanation
from BMINet.Interaction import SHAPVisualizer
# Load explanation class and train it
shap_visualizer = SHAPVisualizer(core_name="LightGBM")
shap_visualizer.train_model(df, selected_features)
# The dir you want to save the files
shap_visualizer.plot_shap('./Example')
shap_visualizer.plot_dependence('./Example')
  • Network Construction
# Load NetworkConstructor
from BMINet.Interaction import NetworkConstructor
network_constructor = NetworkConstructor(core_name="LightGBM", cutoff = 1.5)

# Construct sub-network list for each group
interactions = network_constructor.construct_network(df, selected_features)
# Construct conmbined network
combined_graph = network_constructor.compose_all(interactions)
# Remove isolated nodes from the network
Graph_BMI = network_constructor.remove_isolated_nodes(combined_graph)
# Save to .graphml file
network_constructor.save_graph(Graph_BMI, './Example')
  • Network Analysis
from BMINet.Interaction import NetworkMetrics
metrics_calculator = NetworkMetrics(Graph_BMI)
metrics = metrics_calculator.compute_metrics()

You can see more Example usage at here

Update Log

  • 2024/9/5: Version 0.1.0, fix CatBoost bug
  • 2024/9/5: Version 0.1.1, update prediction threholds
  • 2024/11/8: Version 0.1.2, update linear formula model
  • 2024/11/26: Version 0.1.3, add matrix visulization

BMINet is developed by Jingran Wang

Department of Orthopedic Surgery, The First Affiliated Hospital of Soochow University

MOE Key Laboratory of Geriatric Diseases and Immunology, Suzhou Key Laboratory of Pathogen Bioscience and Anti-Infective Medicine


Organization Logo

Release files for BMINet 0.1.4

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

Source distribution (sdist)

Source distribution for BMINet 0.1.4
File Size Uploaded
bminet-0.1.4.tar.gz 118.5 kB Details

Release files / bminet-0.1.4.tar.gz

Download URL bminet-0.1.4.tar.gz
Size 118.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b8856a9ae0b46ee78c9b8cc436c699eff2e70e3a3abae3fd178c55c1c0d92c5f
BLAKE2b-256 checksum
How to use checksums
1a2d5c019a9c55f378e40f48204ff19bfd13ae5dd7c2654fe4802ad2537a896c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.5

Release history Release notifications | RSS feed

This release

0.1.4 This release

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

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