<s> """<STR_LIT>""" <EOL> from __future__ import division <EOL> import numpy as np <EOL> import matplotlib . pyplot as plt <EOL> from sklearn . datasets import make_blobs <EOL> from sklearn . discriminant_analysis import LinearDiscriminantAnalysis <EOL> n_train = <NUM_LIT:20> <EOL> n_test = <NUM_LIT:200> <EOL> n_averages = <NUM_LIT:50> <EOL> n_features_max = <NUM_LIT> <EOL> step = <NUM_LIT:4> <EOL> def generate_data ( n_samples , n_features ) : <EOL> """<STR_LIT>""" <EOL> X , y = make_blobs ( n_samples = n_samples , n_features = <NUM_LIT:1> , centers = [ [ - <NUM_LIT:2> ] , [ <NUM_LIT:2> ] ] ) <EOL> if n_features > <NUM_LIT:1> : <EOL> X = np . hstack ( [ X , np . random . randn ( n_samples , n_features - <NUM_LIT:1> ) ] ) <EOL> return X , y <EOL> acc_clf1 , acc_clf2 = [ ] , [ ] <EOL> n_features_range = range ( <NUM_LIT:1> , n_features_max + <NUM_LIT:1> , step ) <EOL> for n_features in n_features_range : <EOL> score_clf1 , score_clf2 = <NUM_LIT:0> , <NUM_LIT:0> <EOL> for _ in range ( n_averages ) : <EOL> X , y = generate_data ( n_train , n_features ) <EOL> clf1 = LinearDiscriminantAnalysis ( solver = '<STR_LIT>' , shrinkage = '<STR_LIT>' ) . fit ( X , y ) <EOL> clf2 = LinearDiscriminantAnalysis ( solver = '<STR_LIT>' , shrinkage = None ) . fit ( X , y ) <EOL> X , y = generate_data ( n_test , n_features ) <EOL> score_clf1 += clf1 . score ( X , y ) <EOL> score_clf2 += clf2 . score ( X , y ) <EOL> acc_clf1 . append ( score_clf1 / n_averages ) <EOL> acc_clf2 . append ( score_clf2 / n_averages ) <EOL> features_samples_ratio = np . array ( n_features_range ) / n_train <EOL> plt . plot ( features_samples_ratio , acc_clf1 , linewidth = <NUM_LIT:2> , <EOL> label = "<STR_LIT>" , color = '<STR_LIT>' ) <EOL> plt . plot ( features_samples_ratio , acc_clf2 , linewidth = <NUM_LIT:2> , <EOL> label = "<STR_LIT>" , color = '<STR_LIT>' ) <EOL> plt . xlabel ( '<STR_LIT>' ) <EOL> plt . ylabel ( '<STR_LIT>' ) <EOL> plt . legend ( loc = <NUM_LIT:1> , prop = { '<STR_LIT:size>' : <NUM_LIT:12> } ) <EOL> plt . suptitle ( '<STR_LIT>' ) <EOL> plt . show ( ) </s>
