Implement the cal_precision_recall function.