Example: Normal and Shrinkage Linear Discriminant Analysis for classification

Normal and Shrinkage Linear Discriminant Analysis for classification

Shows how shrinkage improves classification.

../../_images/sphx_glr_plot_lda_001.png
from __future__ import division

import numpy as np
import matplotlib.pyplot as plt

from sklearn.datasets import make_blobs
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis


n_train = 20  # samples for training
n_test = 200  # samples for testing
n_averages = 50  # how often to repeat classification
n_features_max = 75  # maximum number of features
step = 4  # step size for the calculation


def generate_data(n_samples, n_features):
    """Generate random blob-ish data with noisy features.

    This returns an array