Giter VIP home page Giter VIP logo

group_stratification's Introduction

group_stratification

Stratify data rows by group, to ensure that the probability distribution per group per split will be as similar as possible.

Can be used to split medical images, with patients as groups. Thus, the splitter splits the data into 2 sets, in which there is no overlap of patients between the sets, and the patients in each set have similar distributions (similar amounts of images).

Similarity between probability distribution of splits, is determined by the Jensen-Shannon distance.

Usage

# df:
# --- image_id --- group_id ----
# --- 0 --- patient_0 ----
# --- 1 --- patient_1 ----
# --- 2 --- patient_0 ----
# --- 3 --- patient_1 ----

from group_stratification.splitter import SplitOptimizer

splitOptimizer = SplitOptimizer(group_id='group_id')

a_data_df_joined, b_data_df_joined, results_df = splitOptimizer.find_optimal_split(df,test_size=0.2,max_iter=200)

# 100%|██████████| 200/200 [00:01<00:00, 164.03it/s]
# best splits are: [5, 10, 1, 6, 7, 3, 15, 0, 13, 16, 18, 8, 14, 2, 9, 12, 17, 11],[4, 19]

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.