A Python package for performance criteria visualization
Project description
Performance Criteria
criteria_performance
is a Python package that allows you to calculate and visualize performance criteria from CSV data and DataFrames. This module facilitates the evaluation of classification models by calculating essential metrics such as recall, precision, false positive rate (FPR), and false negative rate (FNR), as well as generating ROC, P-R, and DET curves.
Installation
You can install the package via pip
:
pip install criteria-performance
or
pip install criteria_performance
Usage
Loading Data
To use the module, you need to provide a URL or path to a CSV file containing at least two columns, or a DataFrame:
- The first column must contain the classes (1 for positive, -1 for negative).
- The second column must contain the prediction scores.
Example CSV
Example of a CSV file structure compatible with the module:
Class | Score |
---|---|
1 | 0.9 |
1 | 0.8 |
-1 | 0.4 |
-1 | 0.1 |
Example
Here is an example of using the PerformanceCriteria
class:
from criteria import PerformanceCriteria
# Replace 'path_to_your_file.csv' with the path to your CSV file
performance = PerformanceCriteria('path_to_your_file.csv')
# Access metrics
print("Recall:", performance.get_recall())
print("Precision:", performance.get_precision())
print("False Positives (FP):", performance.get_fp())
print("False Negatives (FN):", performance.get_fn())
Visualization
The module includes methods to display performance criteria graphs:
dispROC()
: Displays the ROC curve.dispPR()
: Displays the Precision-Recall curve.dispDET()
: Displays the DET curve.displaygraphe()
: Displays all graphs in a single figure.
Example:
performance.displaygraphe()
performance.show() # Displays the figure
Calculated Metrics
The module calculates and returns the following metrics:
- PPV (Positive Predictive Value): Positive predictive value.
- NPV (Negative Predictive Value): Negative predictive value.
- False Positives (FP): Number of false positives.
- True Positives (TP): Number of true positives.
- False Negatives (FN): Number of false negatives.
- False Negative Rate (FNR): False negative rate.
- False Positive Rate (FPR): False positive rate.
- Recall: Sensitivity or true positive rate.
- Precision: True positives divided by the total predicted positives.
Practical Tools
Here are two useful functions included in the module:
asarray2D(arrayA, arrayB)
Combines two arrays into a 2D array.
Usage:
import numpy as np
from criteria import asarray2D
arrayA = np.array([1, 2, 3])
arrayB = np.array([0.9, 0.8, 0.7])
combined_array = asarray2D(arrayA, arrayB)
print(combined_array)
asDataFrame(array)
Converts a 2D array into a Pandas DataFrame.
Usage:
from criteria import asDataFrame
import numpy as np
array = np.array([[1, 0.9], [1, 0.8], [-1, 0.4]])
df = asDataFrame(array)
print(df)
from criteria import PerformanceCriteria,Opentxt
data = Opentxt("Score_Sys_1.txt")
criter = PerformanceCriteria(data)
Authors
Developed by Olanda-Eyiba Chantry - chantryolanda85@gmail.com
License
This project is licensed under the MIT License.
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 criteria_performance-1.3.5.tar.gz
.
File metadata
- Download URL: criteria_performance-1.3.5.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f975eb17caf7acb350959fe5a485d745858f7f297f5b86b37d90ea6cb144963 |
|
MD5 | b497d88fd0b616b25e9315cf082c509c |
|
BLAKE2b-256 | c3e355a090af320c54e2cff98395d2ffce97ff12c00baaa511b497c761744adf |
File details
Details for the file criteria_performance-1.3.5-py3-none-any.whl
.
File metadata
- Download URL: criteria_performance-1.3.5-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7d69bc6cf1176596dd7310cb59c3d8315cc792d933b161cb5dd3bb89b24cdd6 |
|
MD5 | ff42da92d65031ec24139327cc0ad5f3 |
|
BLAKE2b-256 | 729e2067051ec451f9f81cfd84e0f3dc5dcd7878177c60be82300e6e4bb2c1f6 |