The Evaluator
class in Python calculates and displays evaluation metrics such as accuracy,
precision, recall, F1 score, confusion matrix, and classification report for classification tasks.
Evaluator
This Python class Evaluator
provides methods to calculate and display evaluation metrics for
classification tasks, including precision, recall, F1 score, accuracy, confusion matrix, and
classification report.
Source code in LabeLMaker/Evaluate/evaluator.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
|
__init__(y_true, y_pred)
Initializes the Evaluator with true and predicted labels. Parameters: y_true (List): Ground truth labels. y_pred (List): Predicted labels.
Source code in LabeLMaker/Evaluate/evaluator.py
27 28 29 30 31 32 33 34 35 36 |
|
calculate_metrics(average_options=None)
Calculates evaluation metrics. Parameters: average_options (List[str], optional): Averaging methods (e.g., ['macro', 'weighted']). Returns: Dict[str, Any]: Dictionary of calculated metrics.
Source code in LabeLMaker/Evaluate/evaluator.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
|
display_metrics()
Returns calculated metrics as a DataFrame.
Source code in LabeLMaker/Evaluate/evaluator.py
101 102 103 104 105 106 107 108 109 110 111 |
|
plot_confusion_matrix(class_labels=None)
Plots the confusion matrix. Parameters: class_labels (List[str], optional): Labels for the classes. Raises: ValueError: If confusion matrix is not calculated.
Source code in LabeLMaker/Evaluate/evaluator.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
|