Coder Social home page Coder Social logo

interpret-ml's Introduction

Purpose: The purpose of this project is first to define, train and test two XGBoost models with features to predict 10-year CV mortality, and second to interpret these two models using the SHAP library to generate insights into which features and their respective values lead to patients developing higher risks of CV mortality.

Date: June 28, 2021

This project consists of two files:

  • CACConsortium_Functions.py: Defines relevant functions.
  • CACConsortium_Xgboost_Shap_Main.ipynb: Runs the functions in the previous file to accomplish the objective defined in "Purpose" above.

Functions in CACConsortium_Functions.py:

  • get_np(df, feature_names, out_var): Converts input DataFrame to a NumPy array.
  • load_processed_features(str_file_postfix): Loads training and test data.
  • setup_classifier_training(train_data, train_label, seed_random): Initializes and tunes the model using cross-validation.
  • fit_mod(train_data, train_label, model, model_post_filename, algo_name='', toggle_perform_training=1, toggle_save_trained_model=1): Fits the model to the training data.
  • get_roc_auc_values(model, test_data, test_label, classifier_threshold): Calculates the classifier metrics for the model.

The code in CACConsortium_Xgboost_Shap_Main.ipynb does the following:

  • Runs each of the functions from CACConsortium_Functions.py.
  • Generates SHAP values for all patients in the training data set for the given model.
  • Creates SHAP summary and dependence plots.

The models are saved and loaded using Pickle in Python. Please refer to the SHAP github repository for documentation and instruction on how to use SHAP.

interpret-ml's People

Contributors

bengoebel avatar benclee avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.