forked from fillassuncao/fast-denser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfitness_metrics.py
51 lines (33 loc) · 848 Bytes
/
fitness_metrics.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from sklearn.metrics import accuracy_score, mean_squared_error
import numpy as np
def accuracy(y_true, y_pred):
"""
Computes the accuracy.
Parameters
----------
y_true : np.array
array of right labels
y_pred : np.array
array of class confidences for each instance
Returns
-------
accuracy : float
accuracy value
"""
y_pred_labels = np.argmax(y_pred, axis=1)
return accuracy_score(y_true, y_pred_labels)
def mse(y_true, y_pred):
"""
Computes the mean squared error (MSE).
Parameters
----------
y_true : np.array
array of right outputs
y_pred : np.array
array of predicted outputs
Returns
-------
mse : float
mean squared errr
"""
return mean_squred_error(y_true, y_pred)