#NEWLINE# def train( self , x , y ) : #NEWLINE# #INDENT# ' Calculate response surface equation coefficients using least\n        squares regression.\n\n        Args\n        ----\n        x : array-like\n            Training input locations\n\n        y : array-like\n            Model responses at given inputs.\n        ' #NEWLINE# super ( ResponseSurface , self ) . train ( x , y ) #NEWLINE# m = self . m = x . shape [ 0 ] #NEWLINE# n = self . n = r . shape [ 1 ] #NEWLINE# X = zeros ( ( m , ( ( ( n + 1 ) * ( n + 2 ) ) // 2 ) ) ) #NEWLINE# X [ : , 0 ] = 1.0 #NEWLINE# X [ : , 1 : ( n + 1 ) ] = x #NEWLINE# X_offset = X [ : , ( n + 1 ) : ] #NEWLINE# for i in range ( n ) : #NEWLINE# #INDENT# X_offset [ : , : ( n - i ) ] = einsum ( 'i,ij->ij' , x [ : , i ] , x [ : , i : ] ) #NEWLINE# X_offset = X_offset [ : , ( n - i ) : ] #NEWLINE# #UNINDENT# ( self . betas , rs , r , s ) = lstsq ( X , y )