Skip to main content

Performing thematic analysis with OpenAI's GPT-4 models

Project description

AutoThemeGenerator is a package that allows you to perform thematic analysis in qualitative studies using OpenAI's GPT models.

<img src="https://img.shields.io/badge/Documentation-v0.0.7-orange" alt="Documentation">
<img src="https://img.shields.io/badge/pypi_package-v0.0.7-brightgreen" alt="pypi package">
<img src="https://img.shields.io/badge/github_source_code-source_code?logo=github&color=green" alt="GitHub Source Code">
<img src="https://img.shields.io/badge/-Colab_Example-grey?logo=google&logoColor=F9AB00" alt="Colab Example">

User inputs

Users are only required to specify the folder location where their interview transcripts are stored. Accepted formats of transcripts include PDF, .docx, and .txt (prefered). AutoThemeGenerator assumes that each document is a transcript of one interviewed participant.

Requirements

Required packages

To use AutoThemeGenerator, you are required to have the following packages installed:

  • openai

  • docx

  • tqdm

  • nltk

  • nltk.tokenize

  • python-docx

  • textract

  • zipfile

  • shutil

  • requests

  • json

If you do not have this packages installed in python, you can do the following:

pip install openai docx tqdm nltk nltk.tokenize python-docx textract zipfile shutil requests json

OpenAI API key

You also need an OpenAI key to be able to use this package. If you do not have one, you can apply for an OpenAI API key at platform.openai.com/api-keys.

Installation

To install in python, simply do the following:

pip install AutoThemeGenerator

Quick Start

Here we provide a quick example on how you can execute AutoThemeGenerator to conveniently perform qualitative analysis from your transcript. For details towards each of the package's functions and parameters, refer to the documention.

from AutoThemeGenerator import analyze_and_synthesize_transcripts



# Specify the folders containing your transcript

# This is the folder containing transcripts in .docx, .PDF or .txt format

directory_path = "my_transcript_folder"

# specify your OpenAI API key

api_key = "<insert your API key>"

# specify the folder you wish to save your themes. 

save_results_path = "folder_of_my_saved_results"



# specify the context of your study

context = (

    "Physical inactivity is a major risk factor for developing several chronic illness. "

    "However, university students and staff in the UK are found to be more physically inactive "

    "compared the general UK population. "

    )

# specify your research questions

research_questions = (

    "This study seeks to understand the barriers and enablers "

    "of physical activity (PA) among university staff and students in "

    "the UK under the university setting, using the Theoretical "

    "Domain Framework (TDF) to guide the investigation. "

    )

# specify your survey script

survey_script = (

    "Knowledge\n "

    "What do you know about physical activity? How might you define physical activity? "

    "... ..." # note: truncated to save space

    "... ..." 

    )



# Analyze and synthesize transcripts

initial_themes, individual_synthesized_themes, overall_synthesized_themes = \

analyze_and_synthesize_transcripts(

    directory_path = directory_path, context = context,

    research_questions = research_questions, script = survey_script,

    api_key = api_key, save_results_path = save_results_path)



# display your study-level themes

print(overall_synthesized_themes)

You can now view the themes in the form of a topic sentence, a detailed explaination and a relevant quote

Citation

Y Yang, C Alba, W Xi, M Li, C Wang, A Jami, R An. "GPT Models Can Perform Thematic Analysis in Public Health Studies, Akin to Qualitative Researchers" Working paper.

Questions?

Contact me at alba@wusl.edu

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

autothemegenerator-0.0.7.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

AutoThemeGenerator-0.0.7-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file autothemegenerator-0.0.7.tar.gz.

File metadata

  • Download URL: autothemegenerator-0.0.7.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.5

File hashes

Hashes for autothemegenerator-0.0.7.tar.gz
Algorithm Hash digest
SHA256 61358bdb1b0d99b403cd1f421604f3ba2ef777380698982e3ff1e7e6c640da2d
MD5 f40f9066f9363978e984517dbc2fba29
BLAKE2b-256 c15906138ec86bcb5f424f0cc275a3d4a440ee2eaeccab8a55ecafc1326854b2

See more details on using hashes here.

File details

Details for the file AutoThemeGenerator-0.0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for AutoThemeGenerator-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 c1d2a8ded40b47186f00c6c466c6ecf19905fd43ca9c812590d9a5c19721db97
MD5 aedd614e5756c712b747b3a124f38b25
BLAKE2b-256 812dd3b19932e72309ea485bdac5f02c9da514b4ee3ea433342391ce47678cc8

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