-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheval_scores.py
31 lines (25 loc) · 948 Bytes
/
eval_scores.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
# -*- coding: utf-8 -*-
"""
Created on Fri Oct 1 11:00:17 2021
@author: IST-AAut
"""
import numpy as np
from sklearn.metrics import mean_squared_error as MSE
from sklearn.metrics import balanced_accuracy_score as BACC
def scores(y_real,y_pred,mode):
###y_real - ground truth vector
###y_pred - vector of predictions, must have the same shape as y_real
###mode - if evaluating regression ('r') or classification ('c')
if y_real.shape != y_pred.shape:
print('confirm that both of your inputs have the same shape')
else:
if mode == 'r':
mse = MSE(y_real,y_pred)
print('The Mean Square Error is', mse)
return mse
elif mode == 'c':
bacc = BACC(y_real,y_pred)
print('The Balanced Accuracy is', bacc)
return bacc
else:
print('You must define the mode input.')