Skip to content

About

Python weak-supervision demo using rule-based labeling functions, majority-vote aggregation, automated testing, Docker, and GitHub Actions.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Weak Supervision Demo

A lightweight Python project that demonstrates how multiple labeling functions can generate training labels without manually annotating every example.

Features

  • Rule-based labeling functions
  • Positive, negative, and abstain labels
  • Majority-vote label aggregation
  • Coverage and label-distribution metrics
  • JSON report generation
  • Automated Pytest test suite
  • Docker support
  • GitHub Actions continuous integration

How It Works

The project applies several independent labeling functions to each text example.

Each labeling function returns one of these values:

  • POSITIVE
  • NEGATIVE
  • ABSTAIN

The votes are combined using majority voting. A tie produces an abstain result.

Project Structure

.
├── .github/
│   └── workflows/
│       └── ci.yml
├── tests/
│   └── test_labeling.py
├── .gitignore
├── Dockerfile
├── labeling.py
├── README.md
├── requirements.txt
└── train.py

Installation

Create a virtual environment:

python -m venv venv

Activate it:

.\venv\Scripts\Activate.ps1

Install dependencies:

python -m pip install -r requirements.txt

Run Tests

python -m pytest -q

Expected result:

11 passed

Run the Demo

python train.py

This creates:

weak_supervision_report.json

Use a Custom Text File

Create a file with one example per line:

I love this product.
This is terrible.
The package arrived today.

Run:

python train.py --input examples.txt

Use a JSON File

Example:

[
  {"text": "This product is amazing."},
  {"text": "I want a refund."}
]

Run:

python train.py --input examples.json

Docker

Build the image:

docker build -t weak-supervision-demo .

Run it:

docker run --rm weak-supervision-demo

Technology

  • Python 3.11
  • Weak supervision
  • Rule-based labeling
  • Pytest
  • Docker
  • GitHub Actions

License

MIT

About

Python weak-supervision demo using rule-based labeling functions, majority-vote aggregation, automated testing, Docker, and GitHub Actions.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages