meeliskull / prg

Software to create Precision-Recall-Gain curves and calculate area under the curve
38 stars 18 forks source link

Python: inconsistent returned types for calc_auprg (int, float) #5

Open perellonieto opened 4 years ago

perellonieto commented 4 years ago

The returned types for function calc_auprg are not consitent, it may be convenient to force and return always floats.

from prg import prg
import numpy as np

y_true = np.array([0, 0, 1, 1], dtype='int')
scores = np.arange(4, 1, -1)
prg_curve = prg.create_prg_curve(y_true, scores)
auprg = prg.calc_auprg(prg_curve)
print(auprg)
print(type(auprg))

y_true = np.array([0, 1, 0], dtype='int')
scores = np.arange(3, 1, -1)
prg_curve = prg.create_prg_curve(y_true, scores)
auprg = prg.calc_auprg(prg_curve)
print(auprg)
print(type(auprg))

Output

0
<class 'int'>
0.0
<class 'numpy.float64'>