AI Metrics
AI Metrics is a Python library for basic Natural Language Processing (NLP) metric score implementations. This library provides various metrics commonly used in evaluating NLP models, such as accuracy, BERT score, BLEU score, and ROUGE score.
Table of Contents
Installation
You can install the library using pip. First, clone the repository:
git clone https://github.com/hari-hud/ai-metrics.git
cd ai-metrics
Then, install the dependencies:
pip install -r requirements.txt
Finally, install the library in editable mode:
pip install -e .
Usage
Here are some examples of how to use the different metrics provided by the library:
Metrics
Accuracy Score
from metrics.nlp.accuracy_score import AccuracyScore
ground_truths = ["label1", "label2", "label3"]
predictions = ["label1", "label2", "label3"]
accuracy = AccuracyScore()
score = accuracy.get_score(ground_truths, predictions)
print(score) # Output: {'accuracy': 1.0}
BERT Score
from metrics.nlp.bert_score import BertScore
ground_truths = ["The cat is on the mat."]
predictions = ["The cat is sitting on the mat."]
bert_score = BertScore()
score = bert_score.get_score(ground_truths, predictions)
print(score) # Output: {'bert_f1': <float_value>}
BLEU Score
from metrics.nlp.bleu_score import BLEUScore
ground_truths = ["The cat is on the mat."]
predictions = ["The cat is on the mat."]
bleu = BLEUScore()
score = bleu.get_score(ground_truths, predictions)
print(score) # Output: {'bleu_score': <float_value>}
ROUGE Score
from metrics.nlp.rouge_score import ROUGEScores
ground_truths = ["The cat sat on the mat."]
predictions = ["The cat sat on the mat."]
rouge = ROUGEScores()
score = rouge.get_score(ground_truths, predictions)
print(score) # Output: {'rouge_1_score': <float_value>, 'rouge_2_score': <float_value>, ...}
Running Tests
You can run the tests using pytest. To run all tests, execute:
pytest tests/
Contributing
Contributions are welcome! Please feel free to submit a pull request or open an issue.
- Fork the repository
- Create your feature branch (e.g.,
git checkout -b feature/YourFeature) - Commit your changes (e.g.,
git commit -m 'Add some feature') - Push to the branch (e.g.,
git push origin feature/YourFeature) - Open a pull request
License
This project is licensed under the Apache License 2.0. See the LICENSE file for details.
Contact
For any questions or suggestions, please contact:
Hari Hud
Email: hudharibhau@nvidia.com
GitHub: hari-hud
Metadata
Release files for ai-metrics 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| ai_metrics-0.0.1.tar.gz | 6.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ai_metrics-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.1 kB
Release files / ai_metrics-0.0.1.tar.gz
| Download URL | ai_metrics-0.0.1.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5ede574a7f03bc28eb8a6f061cb2c480b1d8dcd2b1aec8223e41ba249c3cf88a
|
|
BLAKE2b-256 checksum How to use checksums |
0a0656b38087a4a68590b7e1537deda7f9e5736fe070c08c12ae97a500cc255a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.7
|
Release files / ai_metrics-0.0.1-py3-none-any.whl
| Download URL | ai_metrics-0.0.1-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
804777a73021f871464647fa4657182647a9ceafe28c51bf84b11a5fa1e87c7e
|
|
BLAKE2b-256 checksum How to use checksums |
9a0c3d56cc1092cb36563b7f531b0663350b4744240a95f53c033b3ace2e9eb1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.7
|
Security for ai-metrics 0.0.1
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.