|
n_train = int(numpy.round(n_samples * (1. - valid_portion))) |
In this line:
n_train = int(np.round(n_samples * (1. - valid_portion)))
Since the rounding here is simply to get the nearest integer (not rounding to specific decimal places), you might consider using:
n_train = int(np.rint(n_samples * (1. - valid_portion)))
np.rint() is a lightweight function that directly wraps the C standard library's rint() function. It performs the same rounding behavior (round half to even), but is more efficient and has less overhead compared to np.round(), which is a higher-level wrapper designed to support decimals.