@@ -23,9 +23,7 @@ def create_credit_scoring_data(n_samples=2000, random_state=42):
2323 np .random .seed (random_state )
2424
2525 # Generate base features
26- income = np .random .lognormal (
27- mean = 10 , sigma = 0.5 , size = n_samples
28- ) # Income in thousands
26+ income = np .random .lognormal (mean = 10 , sigma = 0.5 , size = n_samples ) # Income in thousands
2927 age = np .random .normal (35 , 12 , n_samples )
3028 age = np .clip (age , 18 , 80 ) # Reasonable age range
3129 credit_score = np .random .normal (650 , 100 , n_samples )
@@ -116,9 +114,7 @@ def compare_binning_methods(X, y):
116114 print ("-" * len (method_name ))
117115
118116 try :
119- woe = FastWoe (
120- monotonic_cst = monotonic_cst , numerical_threshold = 10 , ** method_config
121- )
117+ woe = FastWoe (monotonic_cst = monotonic_cst , numerical_threshold = 10 , ** method_config )
122118
123119 woe .fit (X , y )
124120
@@ -143,9 +139,7 @@ def compare_binning_methods(X, y):
143139 print ("📋 Constraints applied:" )
144140 for _ , row in summary .iterrows ():
145141 constraint_map = {- 1 : "Decreasing" , 1 : "Increasing" , 0 : "None" }
146- print (
147- f" { row ['feature' ]} : { constraint_map [row ['monotonic_constraint' ]]} "
148- )
142+ print (f" { row ['feature' ]} : { constraint_map [row ['monotonic_constraint' ]]} " )
149143
150144 except ImportError as e :
151145 if "faiss" not in str (e ).lower ():
@@ -223,9 +217,7 @@ def compare_kbins_strategies(X, y):
223217 print ("📋 Constraints applied:" )
224218 for _ , row in summary .iterrows ():
225219 constraint_map = {- 1 : "Decreasing" , 1 : "Increasing" , 0 : "None" }
226- print (
227- f" { row ['feature' ]} : { constraint_map [row ['monotonic_constraint' ]]} "
228- )
220+ print (f" { row ['feature' ]} : { constraint_map [row ['monotonic_constraint' ]]} " )
229221
230222 except (ValueError , RuntimeError , AttributeError ) as e :
231223 print (f"❌ Error with { strategy_name } : { e } " )
@@ -414,16 +406,8 @@ def print_detailed_woe_analysis(results, X, y):
414406 sorted_woe = np .array (woe_values )[sorted_indices ]
415407 sorted_rates = np .array (event_rates )[sorted_indices ]
416408
417- for center , woe_val , rate in zip (
418- sorted_centers , sorted_woe , sorted_rates
419- ):
420- print (
421- f"{ center :8.1f} "
422- + " " * 20
423- + f"{ woe_val :8.3f} "
424- + " " * 8
425- + f"{ rate :.3f} "
426- )
409+ for center , woe_val , rate in zip (sorted_centers , sorted_woe , sorted_rates ):
410+ print (f"{ center :8.1f} " + " " * 20 + f"{ woe_val :8.3f} " + " " * 8 + f"{ rate :.3f} " )
427411
428412
429413def main ():
0 commit comments