function for calculation of confusion metrics