Skip to main content

CTApy

Python package for the "Conditional Topic Allocation" (CTA): a text-analysis method that identifies topics that correlate with numerical outcomes.

How does CTA work?

CTA finds topics by conditioning on observables. For example, do Republicans write differently about politics than Democrats? It consists of three steps:


1. Predict the outcome variable with text.
  • Uses DistilBERT to predict outcome.

2. Select words with high predictive power (positive or negative).
  • Calculates SHAP values for each word and select words with a statistically significant SHAP value.

3. Group words by semantic similarity.
  • Returns topics with either positive or negative correlation with the outcome.

CTA supports all languages.

Installation

CTApy requires Python 3.9 and pip.
It is highly recommended to use a virtual environment (or conda environment) for the installation.

# upgrade pip, wheel and setuptools
python -m pip install -U pip wheel setuptools

# install the package
python -m pip install -U CTApy

If you want to use Jupyter, make sure you have it installed in the current environment.

Quickstart

Please see the hands-on tutorials, which replicate the research paper: https://github.com/twekhof/CTA/tree/main/tutorials.

Author

CTApy was developed by

Tobias Wekhof, ETH Zurich

Disclaimer

This Python package is a research tool currently under development. The authors take no responsibility for the accuracy or reliability of the results produced by it.

Metadata

Release files for CTApy 0.1.4

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

Source distribution (sdist)

Source distribution for CTApy 0.1.4
File Size Uploaded Provenance
ctapy-0.1.4.tar.gz 9.7 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 22.5 kB

Release files / ctapy-0.1.4.tar.gz

Download URL ctapy-0.1.4.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
166cf8ea9e2b8e93b07a2df359d995ea55ddb5cf2e288b6be50f5b93369b7de9
BLAKE2b-256 checksum
How to use checksums
10f05911f184262209332830461edf159a2aff137e786675285fc3497cacf159
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.5

Release files / CTApy-0.1.4-py3-none-any.whl

Download URL CTApy-0.1.4-py3-none-any.whl
Size 12.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
51e9eb7f901fbb50fec3f4b9e5a651daca2c848ce73240f805675cbda7af65bf
BLAKE2b-256 checksum
How to use checksums
04a33142356f920c0532354531a37ed08e7f2c32d298eb323d6d9bb0182014ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.5

Security for CTApy 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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