accuracy
Bases: metric
The accuracy evaluation metric.
The class inherits from the base metric class.
...
Attributes:
Name | Type | Description |
---|---|---|
name |
str, default = 'accuracy'
|
Name of the accuracy evaluation metric. |
metric |
object
|
The accuracy evaluation metric calculation method. |
Methods:
Name | Description |
---|---|
__init__ |
It performs the initialization of the accuracy evaluation metric. Its internal metric calculation method is declared to be accuracy_score from sklearn. |
evaluate |
It implements the abstract evaluate method declared in the base metric class. The method calculates the accuracy score of the inputs. |
__call__ |
It reimplements the abstract callable method declared in the base metric class. |
Source code in tinybig/metric/classification_metric.py
16 17 18 19 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 |
|
__call__(y_true, y_pred, *args, **kwargs)
The callable method of the accuracy metric class.
It re-implements the build-in callable method. This method will call the evaluate method to calculate the accuracy of the input parameters.
Examples:
>>> from tinybig.metric import accuracy as accuracy_metric
>>> acc_metric = accuracy_metric(name='accuracy_metric')
>>> y_true = [1, 1, 0, 0]
>>> y_pred = [1, 1, 0, 1]
>>> acc_metric(y_pred=y_pred, y_true=y_true)
0.75
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y_true
|
list
|
The list of true labels of data instances. |
required |
y_pred
|
list
|
The list of predicted labels of data instances. |
required |
args
|
Other parameters |
()
|
|
kwargs
|
Other parameters |
{}
|
Returns:
Type | Description |
---|---|
float | list
|
The calculated accuracy score of the input parameters. |
Source code in tinybig/metric/classification_metric.py
__init__(name='accuracy')
The initialization method of the accuracy evaluation metric.
It initializes an accuracy evaluation metric object based on the input metric name. This method will also call the initialization method of the base class as well. The metric calculation approach is initialized as the sklearn.metrics.accuracy_score.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the evaluation metric. |
'accuracy'
|
Source code in tinybig/metric/classification_metric.py
evaluate(y_true, y_pred, *args, **kwargs)
The evaluate method of the accuracy evaluation metric class.
It calculates the accuracy scores based on the provided input parameters "y_true" and "y_pred". The method will return calculated accuracy score as the output.
Examples:
>>> from tinybig.metric import accuracy as accuracy_metric
>>> acc_metric = accuracy_metric(name='accuracy_metric')
>>> y_true = [1, 1, 0, 0]
>>> y_pred = [1, 1, 0, 1]
>>> acc_metric.evaluate(y_pred=y_pred, y_true=y_true)
0.75
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y_true
|
list
|
The list of true labels of data instances. |
required |
y_pred
|
list
|
The list of predicted labels of data instances. |
required |
args
|
Other parameters |
()
|
|
kwargs
|
Other parameters |
{}
|
Returns:
Type | Description |
---|---|
float | list
|
The calculated accuracy score of the input parameters. |