Skip to main content

Package for error detecting and correcting code

Project description

Logo

License: MIT

What is this?

PyEDCR is a Python implementation of Error Detection and Correction Rules. The goal of PyEDCR is to use a set of conditions to learn when a machine learning model makes an incorrect prediction and to fix it to the correct prediction. The rules used in this package were constructed in this article:

Installation

To install this package run this from the command prompt:

pip install PyEDCR

The package was tested for Python >= 3.10, along with the listed packages versions in requirements.txt

Tutorial

To demonstrate the use of the package, we provide running examples. The main function of this package is run_EDCR_pipeline from the EDCR_pipeline module.

from PyEDCR.EDCR_pipeline import run_EDCR_pipeline

combined = False
conditions_from_main = True
print(utils.red_text(f'\nconditions_from_secondary={not conditions_from_main}, '
                     f'conditions_from_main={conditions_from_main}\n' +
                     f'combined={combined}\n' + '#' * 100 + '\n'))

run_EDCR_pipeline(main_lr=0.0001,
                  combined=combined,
                  loss='soft_marginal',
                  conditions_from_secondary=not conditions_from_main,
                  conditions_from_main=conditions_from_main,
                  consistency_constraints=True,
                  multiprocessing=True)

Here, 'main_lr' refers to the learning rate of the model in question. 'combined' is a flag for individual vs combined models. Combined models predict both fine and coarse grain while individual predicts one or the other. 'loss' refers to the specified loss. In our development, we used soft_marginal and BCE. 'conditions_from_main' specifies where the conditions for EDCR come from. If 'conditions_from_main' is true, a combined model will use it's own predictions as conditions for EDCR. If false, conditions will be from another model. 'consistency_constraints' is a flag to print the information for the recovered constraints and the mean constraints among all fine and coarse classes. 'multiprocessing' is used to enable multiprocessing.

To specify a model for EDCR, predictions from the model to be improved must be specified in the form of numpy arrays. Main and Secondary fine and coarse paths should be changed in the load_priors function under EDCR_pipeline to work with the user's paths. Below is the implementation of how our model predictions were loaded.

from PyEDCR.EDCR_pipeline import run_EDCR_pipeline

combined = False
conditions_from_main = True
print(utils.red_text(f'\nconditions_from_secondary={not conditions_from_main}, '
                     f'conditions_from_main={conditions_from_main}\n' +
                     f'combined={combined}\n' + '#' * 100 + '\n'))

run_EDCR_pipeline(main_lr=0.0001,
                  combined=combined,
                  loss='soft_marginal',
                  conditions_from_secondary=not conditions_from_main,
                  conditions_from_main=conditions_from_main,
                  consistency_constraints=True,
                  multiprocessing=True)

Acknowledgments

This research was supported in part by ...

This research was also supported by ...

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

PyEDCR-0.1.29.tar.gz (117.0 kB view details)

Uploaded Source

File details

Details for the file PyEDCR-0.1.29.tar.gz.

File metadata

  • Download URL: PyEDCR-0.1.29.tar.gz
  • Upload date:
  • Size: 117.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for PyEDCR-0.1.29.tar.gz
Algorithm Hash digest
SHA256 bd03c2c92861d2f4da71e89a8f6cf57870726780d91e373a776e88a8763446ea
MD5 01e1bf1952771772227052354db65a75
BLAKE2b-256 93b983eda9c118890199af3b22575753d2640ce5a549ba3f28ee9c75e5ec402e

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