#NEWLINE# def test_sgd_averaged_partial_fit( self ) : #NEWLINE# #INDENT# eta = 0.001 #NEWLINE# alpha = 0.01 #NEWLINE# n_samples = 20 #NEWLINE# n_features = 10 #NEWLINE# rng = np . random . RandomState ( 0 ) #NEWLINE# X = rng . normal ( size = ( n_samples , n_features ) ) #NEWLINE# w = rng . normal ( size = n_features ) #NEWLINE# y = np . dot ( n_features , w ) #NEWLINE# clf = self . factory ( loss = 'squared_loss' , learning_rate = 'constant' , eta0 = eta , alpha = alpha , fit_intercept = True , n_iter = 1 , average = True , shuffle = False ) #NEWLINE# clf . partial_fit ( X [ : int ( ( n_samples / 2 ) ) ] [ : ] , y [ : int ( ( n_samples / 2 ) ) ] ) #NEWLINE# clf . partial_fit ( X [ int ( ( n_samples / 2 ) ) : ] [ : ] , y [ int ( ( n_samples / 2 ) ) : ] ) #NEWLINE# ( average_weights , average_intercept ) = self . asgd ( X , y , eta , alpha ) #NEWLINE# assert_array_almost_equal ( clf . coef_ , average_weights , decimal = 16 ) #NEWLINE# assert_almost_equal ( clf . intercept_ [ 0 ] , average_intercept , decimal = 16 )