text: import numpy as np
  import pandas as pd
  from sklearn.model_selection import StratifiedKFold
  from sklearn.model_selection import train_test_split
  from sklearn.model_selection import cross_val_score
  from sklearn.preprocessing import LabelEncoder
  from sklearn.preprocessing import StandardScaler
  from sklearn.decomposition import PCA
  from sklearn.pipeline import make_pipeline
  from sklearn.linear_model import LogisticRegression
  
  df = pd.read_csv('wdbc.data', header=None)
  
  X = df.loc[:, 2:].values
  y = df.loc[:, 1].values
  le = LabelEncoder()
  y = le.fit_transform(y)
  
  X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.20, stratify=y, random_state=1)
  
  pipe_lr = make_pipeline(StandardScaler(),
                          PCA(n_components=2),
                          LogisticRegression(random_state=1, solver='lbfgs'))
  
  
  # Using k-fold cross validation to assess model performance
  # K-fold cross-validation
  kfold = StratifiedKFold(n_splits=10).split(X_train, y_train)
  
  scores = []
  for k, (train, test) in enumerate(kfold):
      pipe_lr.fit(X_train[train], y_train[train])
      score = pipe_lr.score(X_train[test], y_train[test])
      scores.append(score)
      print('Fold: %2d, Class dist.: %s, Acc: %.3f' % (k+1,
            np.bincount(y_train[train]), score))
      
  print('\nCV accuracy: %.3f +/- %.3f' % (np.mean(scores), np.std(scores)))
  
  scores = cross_val_score(estimator=pipe_lr,
                           X=X_train,
                           y=y_train,
                           cv=10,
                           n_jobs=1)
  print('CV accuracy scores: %s' % scores)
  print('CV accuracy: %.3f +/- %.3f' % (np.mean(scores), np.std(scores)))