code: def paired_ttest_kfold_cv(
      estimator1,
      estimator2,
      X,
      y,
      cv=10,
      scoring=None,
      shuffle=False,
      random_seed=None,
  ):
      """
      Implements the k-fold paired t test procedure
      to compare the performance of two models.
  
      Parameters
      ----------
      estimator1 : scikit-learn classifier or regressor
  
      estimator2 : scikit-learn classifier or regressor
  
      X : {array-like, sparse matrix}, shape = [n_samples, n_features]
          Training vectors, where n_samples is the number of samples and
          n_features is the number of features.
  
      y : array-like, shape = [n_samples]
          Target values.
  
      cv : int (default: 10)
          Number of splits and iteration for the
          cross-validation procedure
  
      scoring : str, callable, or None (default: None)
          If None (default), uses 'accuracy' for sklearn classifiers
          and 'r2' for sklearn regressors.
          If str, uses a sklearn scoring metric string identifier, for example
          {accuracy, f1, precision, recall, roc_auc} for classifiers,
          {'mean_absolute_error', 'mean_squared_error'/'neg_mean_squared_error',
          'median_absolute_error', 'r2'} for regressors.
          If a callable object or function is provided, it has to be conform with
          sklearn's signature ``scorer(estimator, X, y)``; see
          https://scikit-learn.org/stable/modules/generated/sklearn.metrics.make_scorer.html
          for more information.
  
      shuffle : bool (default: True)
          Whether to shuffle the dataset for generating
          the k-fold splits.
  
      random_seed : int or None (default: None)
          Random seed for shuffling the dataset
          for generating the k-fold splits.
          Ignored if shuffle=False.
  
      Returns
      ----------
      t : float
          The t-statistic
  
      pvalue : float
          Two-tailed p-value.
          If the chosen significance level is larger
          than the p-value, we reject the null hypothesis
          and accept that there are significant differences
          in the two compared models.
  
      Examples
      -----------
      For usage examples, please see
      https://rasbt.github.io/mlxtend/user_guide/evaluate/paired_ttest_kfold_cv/
  
      """
  
      if not shuffle:
          kf = KFold(n_splits=cv, shuffle=shuffle)
      else:
          kf = KFold(
              n_splits=cv, random_state=random_seed, shuffle=shuffle
          )
  
      if scoring is None:
          if estimator1._estimator_type == "classifier":
              scoring = "accuracy"
          elif estimator1._estimator_type == "regressor":
              scoring = "r2"
          else:
              raise AttributeError(
                  "Estimator must " "be a Classifier or Regressor."
              )
      if isinstance(scoring, str):
          scorer = get_scorer(scoring)
      else:
          scorer = scoring
  
      score_diff = []
  
      for train_index, test_index in kf.split(X):
          X_train, X_test = X[train_index], X[test_index]
          y_train, y_test = y[train_index], y[test_index]
  
          estimator1.fit(X_train, y_train)
          estimator2.fit(X_train, y_train)
  
          est1_score = scorer(estimator1, X_test, y_test)
          est2_score = scorer(estimator2, X_test, y_test)
          score_diff.append(est1_score - est2_score)
  
      avg_diff = np.mean(score_diff)
  
      numerator = avg_diff * np.sqrt(cv)
      denominator = np.sqrt(
          sum([(diff - avg_diff) ** 2 for diff in score_diff])
          / (cv - 1)
      )
      t_stat = numerator / denominator
  
      pvalue = stats.t.sf(np.abs(t_stat), cv - 1) * 2.0
      return float(t_stat), float(pvalue)
  
imports: import numpy
  from scipy import stats
  from sklearn.metrics import get_scorer
  from sklearn.model_selection import KFold, train_test_split
label_desc: Use image node_id 2 for calling a global function with example usage: paired_ttest_kfold_cv(estimator1, estimator2, X, y, cv, scoring, shuffle, random_seed) and returns: float,  float