This package is used to estimate certainty for scientific findings
Project description
certainty-estimator
Intro
certainty-estimator is a package used to estimate the certainty of scientfic findings. It is released with
EMNLP 2021 paper Measuring Sentence-level and Aspect-level (Un)Certainty in Science Communications
by Jiaxin Pei and David Jurgens.
Install
Use pip
If pip
is installed, certainty-estimator could be installed directly from it:
pip3 install certainty-estimator
Dependencies
python>=3.6.0
torch>=1.6.0
transformers >= 3.1.0
numpy
math
tqdm
Example:
clone this repo to your machine: git clone https://github.com/Jiaxin-Pei/certainty-estimator.git
run the example code: python3 play.py
Estimating sentence-level certainty
Notes: During your first usage, the package will download a model file automatically, which is about 500MB.
Construct the Predictor Object
>>> from certainty_estimator.predict_certainty import CertaintyEstimator
>>> estimator = CertaintyEstimator('sentence-level')
Cuda is disabled by default, to allow GPU calculation, please use
>>> from certainty_estimator.predict_certainty import CertaintyEstimator
>>> estimator = CertaintyEstimator('sentence-level',cuda=True)
predict
predict
is the core method of this package,
which takes a single text or a list of texts, and returns a list of raw values in [1,6]
(higher means more certain, while lower means less).
# Predict certainty for a single scientific finding
>>> text = 'The reason for this might be that the fetal central nervous system, which controls movements in general and facial movements in particular did not develop at the same rate and in the same manner as in fetuses of mothers who did not smoke during pregnancy.'
>>> estimator.predict(text)
>>> [2.6891987]
# Predict certainty for a list of scientific finding
>>> text = ['The reason for this might be that the fetal central nervous system, which controls movements in general and facial movements in particular did not develop at the same rate and in the same manner as in fetuses of mothers who did not smoke during pregnancy.', 'Mice lacking the tet1 gene were able to learn to navigate a water maze, but were unable to extinguish the memory.']
>>> estimator.predict(text)
>>> [2.6891987, 5.01066]
# when calculating certainty for a long list of findings, use the following code to display the progress
>>> from tqdm import tqdm
>>> text = [a long list of findings]
>>> estimator.predict(text,tqdm=tqdm)
>>> [2.6891987, 5.01066, ... ,4.28066, 5.77066]
Estimating aspect-level certainty
Notes: During your first usage, the package will download a model file automatically, which is about 500MB.
Construct the Predictor Object
>>> from certainty_estimator.predict_certainty import CertaintyEstimator
>>> estimator = CertaintyEstimator('aspect-level')
Cuda is disabled by default, to allow GPU calculation, please use
>>> from certainty_estimator.predict_certainty import CertaintyEstimator
>>> estimator = CertaintyEstimator('aspect-level',cuda=True)
predict
predict
is the core method of this package,
which takes a single text or a list of texts, and returns a list of tuples for aspect-level certainty.
# Predict certainty for a single scientific finding
>>> text = 'Mice lacking tet1 had much lower levels of hydroxymethylation -- an intermediate step in the removal of methylation -- in the hippocampus and the cortex, which are both key to learning and memory.'
>>> result = estimator.predict(text)
>>> print(result)
>>> [[('Extent', 'Uncertain'), ('Probability', 'Certain')]]
#By default, only returns the presented aspects and their certainty.
# Predict certainty for a list of scientific finding
>>> text = ['Mice lacking tet1 had much lower levels of hydroxymethylation -- an intermediate step in the removal of methylation -- in the hippocampus and the cortex, which are both key to learning and memory.', 'Dopamine and serotonin are important for different forms of flexibility associated with receiving reward and punishment.']
>>> result = estimator.predict(text)
>>> print(result)
>>> [[('Extent', 'Uncertain'), ('Probability', 'Certain')], [('Probability', 'Certain')]]
# when calculating certainty for a long list of findings, use the tqdm to display the progress
>>> from tqdm import tqdm
>>> text = [a long list of findings]
>>> estimator.predict(text,tqdm=tqdm)
Contact
Jiaxin Pei (pedropei@umich.edu)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file certainty-estimator-1.6.tar.gz
.
File metadata
- Download URL: certainty-estimator-1.6.tar.gz
- Upload date:
- Size: 20.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd37aa9d4504ba8fff4e9fed73b7580fa8a5178fe89cfd61a12dac89e9c4f12c |
|
MD5 | 33c13ab2bcdc60c86dc6f412e4310ada |
|
BLAKE2b-256 | 8d1c1b63d40a65cb2ab13f4cfc33f0954377a7e9c31bb49e5cc40f849df12e27 |
File details
Details for the file certainty_estimator-1.6-py3-none-any.whl
.
File metadata
- Download URL: certainty_estimator-1.6-py3-none-any.whl
- Upload date:
- Size: 19.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 572cecf467a3aef943602971586ca5bb75d07684616d75172a4bbfc40aa53ced |
|
MD5 | 7e5ca01880d35f458731fb79b4cafa06 |
|
BLAKE2b-256 | 0695502f41cf635b077e691a6a973d8039a3a5c975ad099e485f071e8696ad14 |