-
Notifications
You must be signed in to change notification settings - Fork 12
/
accuracy.py
37 lines (26 loc) · 977 Bytes
/
accuracy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from sklearn.metrics import accuracy_score
from niaaml.fitness.fitness_function import FitnessFunction
__all__ = ["Accuracy"]
class Accuracy(FitnessFunction):
r"""Class representing the accuracy as a fitness function.
Date:
2020
Author:
Luka Pečnik
License:
MIT
Documentation:
https://scikit-learn.org/stable/modules/generated/sklearn.metrics.accuracy_score.html
See Also:
* :class:`niaaml.fitness.FitnessFunction`
"""
Name = "Accuracy"
def get_fitness(self, predicted, expected):
r"""Return fitness value. The larger return value should represent a better fitness for the framework to work properly.
Arguments:
predicted (pandas.core.series.Series): Predicted values.
expected (pandas.core.series.Series): Expected values.
Returns:
float: Calculated fitness value.
"""
return accuracy_score(expected, predicted)