Skip to main content

A Python package for dividing a set of units into two most comparable groups based on their characteristics.

Project description

GitHub GitHub Workflow Status (with branch) Coverage PyPI - Downloads

Introduction

This project provides a Python package and REST API applications for dividing a set of units into two most comparable groups based on their characteristics.

Problem Statement

Balancing Numeric Characteristics Across Two Groups

Input:

  • A set of units, where each unit possesses one or more numeric characteristics.

  • Desired size for each of the two groups.

  • (Optional) Pre-assignment constraints:

    • Specify units that must belong to a particular group (Group A or Group B).
    • Specify units that cannot belong to a particular group (Group A or Group B).

Objective:

Partition the units into two groups (Group A and Group B) of the specified size, ensuring maximum similarity between the groups. Similarity is measured by minimizing the sum of absolute differences in mean values for each characteristic across the two groups.

Constraints:

  • Each unit is assigned to either Group A, Group B, or remains unassigned.
  • The final size of Group A and Group B must match the specified desired size.

Output:

  • A list of units assigned to Group A and Group B.
  • The mean values for each characteristic in Group A and Group B.
  • The sum of absolute differences in mean values for each characteristic across the two groups.

Local development

You are more than welcome to contribute to this project. To make your start easier we have prepared a docker image with all the necessary tools to run it as interpreter for Pycharm or to run tests.

Build docker image

docker build `
     --tag surquest/surquest/split-balancer:latest `
     --file package.base.dockerfile `
     --target test .

Run docker container

docker run --rm -it `
 -v "${pwd}:/opt/project" `
 -w "/opt/project/test" `
 surquest/surquest/split-balancer:latest pytest

REST API Quick Start

# Build the docker image

docker build `
     --no-cache `
     --tag surquest/app-split-balancer:latest `
     --file app.base.dockerfile `
     --target base .

docker build `
     --no-cache `
     --tag python/instore/pmp-integration-proxy `
     --file app.base.dockerfile `
     --target app .

# Run the docker container
docker run --rm -it `
    --name pmp-integration-proxy `
    -v "$(pwd):/opt/project" `
    -p 1010:8080 surquest/app-split-balancer:latest

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

surquest_split_balancer-0.0.6.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

surquest_split_balancer-0.0.6-py2.py3-none-any.whl (7.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file surquest_split_balancer-0.0.6.tar.gz.

File metadata

File hashes

Hashes for surquest_split_balancer-0.0.6.tar.gz
Algorithm Hash digest
SHA256 28ce67214e26a568609541adc7a0d6958057cb2ced9ecb95266baa2345bb4b8c
MD5 42f27a583ac67bb8062d03c1f14f4789
BLAKE2b-256 dccabd59f3171575f93a55c25eb04b3bf81ddb959572eb044979d2a2c1e3fef9

See more details on using hashes here.

File details

Details for the file surquest_split_balancer-0.0.6-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for surquest_split_balancer-0.0.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d576a1dab5e8a4110fc65752c1bfba6f2545b55519a9421185d7bf97000f5ff3
MD5 669d0598a7be70d39a921044785a007f
BLAKE2b-256 92c3845613cf08e00baa56065a148e47e14bb336ef95b50909c296d18df2b504

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page