<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def predict_proba(self, p):
 """ Calculate the calibrated probabilities Parameters y_prob : array-like of shape = [n_samples, 2] Predicted probabilities to be calibrated using calibration map Returns ------- y_prob_cal : array-like of shape = [n_samples, 1] Predicted calibrated probabilities """


        # TODO: Check input
        if p.size != p.shape[0]:
            p = p[:, 1]

        calibrated_proba = np.zeros(p.shape[0])
        for i in range(self.calibration_map.shape[0]):
            calibrated_proba[np.logical_and(self.calibration_map[i, 1] <= p, self.calibration_map[i, 0] > p)] = \
                self.calibration_map[i, 2]

        # TODO: return 2D and refactor
        return calibrated_proba