Skip to main content

# Likelycause2

Likelycause is an utility package that uses several functions to attribute causes to variations. Using a combination of arithmetical decompositions and bayesian techniques, this was built to facilitate the workflow of a data-analyst working for the private sector.

## What the package contains This package has everything built under the likelycause2 module, so all the functions should be called using “likelycause2.”. Currently, we have 1 auxiliary function and 1 causal function.

### Auxiliary functions - likelycause2.last_period: The last period function is a utility function that builds variation variables in a dataframe._

### Causal functions - likelycause2.bayes_suspects: The bayes_suspects function calculates the conditional probabilities of the event and each suspicious causes or a combination of those causes. It also suggests an attribution to each individual cause, by adjusting the intersections of causes

## Likelycause2.last_period

### Description: The last period function is a utility function that builds variation variables in a dataframe. Variations are defined between moment t and a moment in the past.

### Arguments:

  • df (pd.DataFrame): the dataframe

  • unique_id (string): unique identifier of each line. Must be unique, and can only be 1 column

  • interval (string): what is the interval you want to calculate variations for. Accepts days, weeks and hours

  • periods (int): number of periods you want to look back on that interval. For last variations, for example, the argument period would be 1

  • date_column (string): the date column in your dateframe. Must be a datetime. To convert, use pandas.to_datetime function

  • to_past (list): list of columns you want to calculate the variations for

### Returns: Returns the dataframe that was inputed with additinal columns named v+name of the columns in the to_past argument. Those columns represent the variation of that variable between moment t and t-periods. This variation is calculated as (Variable in moment t)/(Variable in moment t-periods).

## Likelycause2.bayes_suspects

### Description: The bayes_suspects function calculates the conditional probabilities of the event and each suspicious causes or a combination of those causes. It also suggests an attribution to each individual cause, by adjusting the intersections of causes

### Arguments:

  • df (pd.DataFrame): the dataframe

  • event (string): name of the column that contains the event that we want to explain

  • suspects (list): list with name of the columns that contains the potential causes for what we want to explain

  • point (dictionary): dictionary with the point for which we want to calculate the probability. Must be a combination of the cause and all the individual points of suspects

### Returns: Returns a dataframe with all the possible probabilities combinations, and the conditional probabilities:

  • name: name of that conditional combination. If it has one event, it represents P(event|a). If it has 2 events it represents P(event1 & event2|a)

  • prob_ba: P(cause | event)

  • prob_a: P(cause)

  • prob_b: P(event)

  • pbayes: confitional probability

  • pbayes_attribution: suggested probability attribution if we want to attribute to individual causes

Release files for likelycause2 0.1.8

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

Source distribution (sdist)

Source distribution for likelycause2 0.1.8
File Size Uploaded
likelycause2-0.1.8.tar.gz 4.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for likelycause2 0.1.8
File Interpreter ABI Platform
likelycause2-0.1.8-py3-none-any.whl Python 3 none any Details

Total release size: 10.1 kB

Release files / likelycause2-0.1.8.tar.gz

Download URL likelycause2-0.1.8.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c4c848833f6382f8a46f7098edd660d02700e3f10069ae9cdf0e4dfc6611b6ca
BLAKE2b-256 checksum
How to use checksums
662dbddfedbbbbb03c0e38c5713944b0bd63a9afe8924fe170806019f014d4e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3

Release files / likelycause2-0.1.8-py3-none-any.whl

Download URL likelycause2-0.1.8-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
04e7b035883c8fd1c8d1844790a5a83694b7f68cb492ccb9e23ff29f3ee1b67c
BLAKE2b-256 checksum
How to use checksums
c792eb81054c7c2865a5ee782f7c2e5cf4365dd256d2f9ba43a492cfe3c07ab1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.1.8 This release

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.1

2 release files

0.0.0

2 release files

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