<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _average_precision(self, rec, prec):
 """ calculate average precision, override the default one, special 11-point metric Params: rec : numpy.array cumulated recall prec : numpy.array cumulated precision Returns: ap as float """

        ap = 0.
        for t in np.arange(0., 1.1, 0.1):
            if np.sum(rec >= t) == 0:
                p = 0
            else:
                p = np.max(prec[rec >= t])
            ap += p / 11.
        return ap