7474from sklearn import cluster , covariance , manifold
7575
7676
77- ###############################################################################
7877# Retrieve the data from Internet
7978
8079def quotes_historical_google (symbol , date1 , date2 ):
@@ -189,7 +188,6 @@ def quotes_historical_google(symbol, date1, date2):
189188variation = close_prices - open_prices
190189
191190
192- ###############################################################################
193191# Learn a graphical structure from the correlations
194192edge_model = covariance .GraphLassoCV ()
195193
@@ -199,7 +197,6 @@ def quotes_historical_google(symbol, date1, date2):
199197X /= X .std (axis = 0 )
200198edge_model .fit (X )
201199
202- ###############################################################################
203200# Cluster using affinity propagation
204201
205202_ , labels = cluster .affinity_propagation (edge_model .covariance_ )
@@ -208,7 +205,6 @@ def quotes_historical_google(symbol, date1, date2):
208205for i in range (n_labels + 1 ):
209206 print ('Cluster %i: %s' % ((i + 1 ), ', ' .join (names [labels == i ])))
210207
211- ###############################################################################
212208# Find a low-dimension embedding for visualization: find the best position of
213209# the nodes (the stocks) on a 2D plane
214210
@@ -220,7 +216,6 @@ def quotes_historical_google(symbol, date1, date2):
220216
221217embedding = node_position_model .fit_transform (X .T ).T
222218
223- ###############################################################################
224219# Visualization
225220plt .figure (1 , facecolor = 'w' , figsize = (10 , 8 ))
226221plt .clf ()
0 commit comments