Skip to main content

Basic hypothesis testing made simple

Project description

medstat

https://img.shields.io/pypi/v/medstat.svg https://img.shields.io/travis/monferrand/medstat.svg Documentation Status

medstat is a library aiming to make basic hypothesis testing as simple as possible.

Getting started

This project is available on PyPI you can just:

pip install medstat

Quick Example

Load your data in a dataframe using for instance pd.read_csv() or pd.read_excel().

data = pd.read_csv("my_data.csv")

Test a single hypothesis:

>>> medstat.test_hypothesis(data, 'sex', 'age < 30')

{'contingency_table':
age < 30  False  True  All
sex
Female       26    22   48
Male         24     8   32
All          50    30   80,
'test': 'Fisher',
'p-value': 0.06541995357625573,
'significant': False}

Or test many hypothesis at the same time:

result = medstat.analyse_dataset(data,
                                 [('sex', 'age < 30'),
                                  ('sex', 'test_a'),
                                  ('test_a', 'age > 50'),
                                 ])

It prints the output:

-------------------- Test 1 --------------------
Test independence between sex and age < 30.
Use Chi-squared test.
Result is not significant.
p-value: 0.18407215636751517
Contingency table:
 age < 30  False  True  All
sex
Female       21    18   39
Male         29    12   41
All          50    30   80


-------------------- Test 2 --------------------
Test independence between sex and test_a.
Use Chi-squared test.
Result is not significant.
p-value: 0.9539453144224308
Contingency table:
 test_a  negative  positive  All
sex
Female        25        14   39
Male          25        16   41
All           50        30   80


-------------------- Test 3 --------------------
Test independence between test_a and age > 50.
Use Fisher test.
Result is significant.
p-value: 6.392910983822276e-12
Contingency table:
 age > 50  False  True  All
test_a
negative     46     4   50
positive      5    25   30
All          51    29   80

You can also save it to a text file using the file argument.

result = medstat.analyse_dataset(data,
                                 [('sex', 'age < 30'),
                                  ('sex', 'test_a'),
                                  ('test_a', 'age > 50'),
                                 ],
                                file='report.txt')

History

0.1.0 (2020-02-01)

  • First release on PyPI.

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

medstat-0.2.0.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

medstat-0.2.0-py2.py3-none-any.whl (5.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file medstat-0.2.0.tar.gz.

File metadata

  • Download URL: medstat-0.2.0.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.8.0

File hashes

Hashes for medstat-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8fcc2d4323cfc64ef4219d6023ba90c8346efce2721df8fb402f3d8bf3ed02a7
MD5 4b371306ea839418d558ac16fae23ae8
BLAKE2b-256 f72569d7991488f51530d915df03ff97b0fd7c7093f069868614e5c27f0a3406

See more details on using hashes here.

File details

Details for the file medstat-0.2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: medstat-0.2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.8.0

File hashes

Hashes for medstat-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 afe3d2c4232de529930ae4836fc4c2de917d68269954b240e23f910e829743a2
MD5 7be78209c55f0f8ac42b431c1a042bec
BLAKE2b-256 b470f74beed4c4fd3357088ae7267b127762b12da0d3d2f7ffd916383f4e9d39

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