@@ -606,33 +606,32 @@ def plot_contour(self, i=0, j=1, min_z=None, max_z=None, show=True):
606606 #
607607 pylab .show ()
608608
609-
610- def print_importance (self , threshold = 0.1 , filename = None ) -> None :
611- """Print importance of each parameter and plot it.
612- Args:
613- threshold (float): Only parameters with importance >= threshold are printed.
614- filename (str): If not None, the plot is saved to the file.
615- Returns:
616- None
617- """
618- if self .surrogate .n_theta > 1 :
619- theta = np .power (10 , self .surrogate .theta )
620- print ("Importance relative to the most important parameter:" )
621- imp = 100 * theta / np .max (theta )
622- imp = imp [imp >= threshold ]
623- if self .var_name is None :
624- for i in range (len (imp )):
625- print ("x" , i , ": " , imp [i ])
626- plt .bar (range (len (imp )), imp )
627- plt .xticks (range (len (imp )), ["x" + str (i ) for i in range (len (imp ))])
609+ def print_importance (self , threshold = 0.1 , filename = None ) -> None :
610+ """Print importance of each parameter and plot it.
611+ Args:
612+ threshold (float): Only parameters with importance >= threshold are printed.
613+ filename (str): If not None, the plot is saved to the file.
614+ Returns:
615+ None
616+ """
617+ if self .surrogate .n_theta > 1 :
618+ theta = np .power (10 , self .surrogate .theta )
619+ print ("Importance relative to the most important parameter:" )
620+ imp = 100 * theta / np .max (theta )
621+ imp = imp [imp >= threshold ]
622+ if self .var_name is None :
623+ for i in range (len (imp )):
624+ print ("x" , i , ": " , imp [i ])
625+ plt .bar (range (len (imp )), imp )
626+ plt .xticks (range (len (imp )), ["x" + str (i ) for i in range (len (imp ))])
627+ else :
628+ var_name = [self .var_name [i ] for i in range (len (imp )) if imp [i ] >= threshold ]
629+ for i in range (len (imp )):
630+ print (var_name [i ] + ": " , imp [i ])
631+ plt .bar (range (len (imp )), imp )
632+ plt .xticks (range (len (imp )), var_name )
633+ if filename is not None :
634+ plt .savefig (filename )
635+ plt .show ()
628636 else :
629- var_name = [self .var_name [i ] for i in range (len (imp )) if imp [i ] >= threshold ]
630- for i in range (len (imp )):
631- print (var_name [i ] + ": " , imp [i ])
632- plt .bar (range (len (imp )), imp )
633- plt .xticks (range (len (imp )), var_name )
634- if filename is not None :
635- plt .savefig (filename )
636- plt .show ()
637- else :
638- print ("Importantance requires more than one theta values (n_theta>1)." )
637+ print ("Importantance requires more than one theta values (n_theta>1)." )
0 commit comments