def METHOD_NAME(self, x_train, y_train, n_folds, random_state=None):
    """Performs k-fold cross validation on a training dataset. Note that this is the function used to fill entries
    of the error matrix.
    Args:
        x_train (np.ndarray): Features of the training dataset.
        y_train (np.ndarray): Labels of the training dataset.
        n_folds (int):        Number of folds to use for cross validation.
    Returns:
        float: Mean of k-fold cross validation error.
        np.ndarray: Predictions on the training dataset from cross validation.
    """
    y_predicted = np.empty(y_train.shape)
    cv_errors = np.empty(n_folds)
    kf = StratifiedKFold(n_folds, shuffle=True, random_state=random_state)
    for i, (train_idx, test_idx) in enumerate(kf.split(x_train, y_train)):
        x_tr = x_train[train_idx, :]
        y_tr = y_train[train_idx]
        x_te = x_train[test_idx, :]
        y_te = y_train[test_idx]
        model = self.instantiate()
        if len(np.unique(y_tr)) > 1:
            model.fit(x_tr, y_tr)
            y_predicted[test_idx] = np.expand_dims(model.predict(x_te), axis=1)
        else:
            y_predicted[test_idx] = y_tr[0]
        cv_errors[i] = self.error(y_te, y_predicted[test_idx])
    self.cv_error = cv_errors.mean()
    self.cv_predictions = y_predicted
    self.sampled = True
    if self.verbose:
        print("{} {} complete.".format(self.algorithm, self.hyperparameters))
    return cv_errors, y_predicted