A package to calculate BCUBED precision, recall, and F1-score for clustering evaluation.
Project description
B-Cubed Metrics
What are B-Cubed Metrics
$$ Precision = \frac{1}{\sum {elements}}\sum_{i=1}^n {\frac{(count ; of ; element)^2}{count ; of ; all ; elements ; in ; cluster}} $$
$$ Recall = \frac{1}{\sum {elements}}\sum_{i=1}^n {\frac{(count ; of ; element)^2}{count ; of ; total ; elements ; from ; this ; category}} $$
$$ F-score = \frac{1}{k}\sum_{i=1}^n {\frac{2\times Precision(C)_k \times Recall(C)_k}{Precision(C)_k + Recall(C)_k}} $$
where $n$ above denotes the number of categories in the cluster and $k$ is the number of predicted clusters. $Precision(C)_k$ and $Recall(C)_k$ are the 'partial' precision and recalls for each cluster.
Installation and Use
pip install bcubed-metrics
from bcubed_metrics.bcubed import Bcubed
predicted_clustering = [
{'blue': 4, 'red': 2, 'green': 1},
{'blue': 2, 'red': 2, 'green': 3},
{'blue': 1, 'red': 5},
{'blue': 1, 'red': 2, 'green': 3}
]
ground_truth_clustering = {'blue': 8, 'red': 11, 'green': 7}
bcubed = Bcubed(predicted_clustering=predicted_clustering, ground_truth_clustering=ground_truth_clustering)
metrics = bcubed.get_metrics() # returns all metrics as dictionary
bcubed.print_metrics() # prints all metrics
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 bcubed_metrics-1.0.1.tar.gz
.
File metadata
- Download URL: bcubed_metrics-1.0.1.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b844bbedf124789dcfa5bd47b6f4cd035a683ed807c8731bc6352105e5329319 |
|
MD5 | be3e68871998337b54cb1178ad33801f |
|
BLAKE2b-256 | 032eb4a9579578ad73eb2350eb18fe422ea4f046975f499b7fc07749003a67cd |
File details
Details for the file bcubed_metrics-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: bcubed_metrics-1.0.1-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c783d4f4c82b4550f6e2ec57d686495ce323df3275bb96e385cfcc8aa24e13dc |
|
MD5 | af3abe05e656307bfdcae54d8fc8bacd |
|
BLAKE2b-256 | 0b43b75c9908abcb520eb52c159268dfe628d57974c82d14f0f4914e86049683 |