#NEWLINE# def set_params( self , **params ) : #NEWLINE# #INDENT# "Set the parameters of this estimator.\n        The method works on simple estimators as well as on nested objects\n        (such as pipelines). The former have parameters of the form\n        ``<component>__<parameter>`` so that it's possible to update each\n        component of a nested object.\n        Returns\n        -------\n        self\n        " #NEWLINE# if ( not params ) : #NEWLINE# #INDENT# return self #NEWLINE# #UNINDENT# valid_params = self . get_params ( deep = True ) #NEWLINE# for ( key , value ) in iteritems ( params ) : #NEWLINE# #INDENT# split = key . split ( '__' , 1 ) #NEWLINE# if ( len ( split ) > 1 ) : #NEWLINE# #INDENT# ( name , sub_name ) = split #NEWLINE# if ( name not in valid_params ) : #NEWLINE# #INDENT# raise ValueError ( ( 'Invalid parameter %s for estimator %s. Check the list of available parameters with `estimator.get_params().keys()`.' % ( name , self ) ) ) #NEWLINE# #UNINDENT# sub_object = valid_params [ name ] #NEWLINE# sub_object . set_params ( ** { #NEWLINE# #INDENT# sub_name : value , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( key not in valid_params ) : #NEWLINE# #INDENT# raise ValueError ( ( 'Invalid parameter %s for estimator %s. Check the list of available parameters with `estimator.get_params().keys()`.' % ( key , self . __class__ . __name__ ) ) ) #NEWLINE# #UNINDENT# setattr ( self , key , value ) #NEWLINE# #UNINDENT# #UNINDENT# return self