<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, X):
 """ Calculate posterior probabilities of test data. Parameters X : array Test data, of dimension N times d (rows are examples, columns are data dimensions) Returns: ------- y_prob : array An array of dimension N times n_inlier_classes+1, containing the probabilities of each row of X being one of the inlier classes, or the outlier class (last column). """

        Phi = metrics.pairwise.rbf_kernel(X, self.kernel_pos, self.gamma)
        N = X.shape[0]
        predictions = np.zeros((N, self.n_classes+1))
        for i in range(N):
            post = np.zeros(self.n_classes)
            for c in range(self.n_classes):
                post[c] = max(0,
                              np.dot(self.theta[self.classes[c]].T, Phi[i, :]))
                post[c] = min(post[c], 1.)
            predictions[i, :-1] = post
            predictions[i, -1] = max(0, 1-sum(post))

        return predictions