#NEWLINE# def _add_bias_unit( self , X , how = 'column' ) : #NEWLINE# #INDENT# 'Add bias unit (column or row of 1s) to array at index 0.' #NEWLINE# if ( how == 'column' ) : #NEWLINE# #INDENT# X_new = np . ones ( ( X . shape [ 0 ] , ( X . shape [ 1 ] + 1 ) ) ) #NEWLINE# X_new [ : , 1 : ] = X #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( how == 'row' ) : #NEWLINE# #INDENT# X_new = np . ones ( ( ( X . shape [ 0 ] + 1 ) , X_new . shape [ 1 ] ) ) #NEWLINE# X_new [ 1 : , : ] = X #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise AttributeError ( 'how must be columns or row' ) #NEWLINE# #UNINDENT# #UNINDENT# return X_new