@@ -128,7 +128,9 @@ def boost(
128
128
state_idx = 0
129
129
130
130
nominals = native .extract_nominals (dataset )
131
- random_cyclic_ordering = np .arange (len (term_features ), dtype = np .int64 )
131
+ random_cyclic_ordering = np .arange (
132
+ len (term_features ), dtype = np .int64
133
+ )
132
134
133
135
while step_idx < max_steps :
134
136
if state_idx >= 0 :
@@ -142,7 +144,9 @@ def boost(
142
144
and develop .get_option (
143
145
"randomize_initial_feature_order"
144
146
)
145
- or develop .get_option ("randomize_greedy_feature_order" )
147
+ or develop .get_option (
148
+ "randomize_greedy_feature_order"
149
+ )
146
150
and greedy_steps > 0
147
151
or develop .get_option ("randomize_feature_order" )
148
152
):
@@ -169,7 +173,10 @@ def boost(
169
173
if contains_nominals :
170
174
reg_lambda_local += develop .get_option ("cat_l2" )
171
175
172
- if develop .get_option ("min_samples_leaf_nominal" ) is not None :
176
+ if (
177
+ develop .get_option ("min_samples_leaf_nominal" )
178
+ is not None
179
+ ):
173
180
min_samples_leaf_local = develop .get_option (
174
181
"min_samples_leaf_nominal"
175
182
)
@@ -179,7 +186,9 @@ def boost(
179
186
elif missing == "high" :
180
187
term_boost_flags_local |= Native .TermBoostFlags_MissingHigh
181
188
elif missing == "separate" :
182
- term_boost_flags_local |= Native .TermBoostFlags_MissingSeparate
189
+ term_boost_flags_local |= (
190
+ Native .TermBoostFlags_MissingSeparate
191
+ )
183
192
elif missing != "gain" :
184
193
msg = f"Unrecognized missing option { missing } ."
185
194
raise Exception (msg )
@@ -219,7 +228,9 @@ def boost(
219
228
max_delta_step = max_delta_step ,
220
229
min_cat_samples = min_cat_samples ,
221
230
cat_smooth = cat_smooth ,
222
- max_cat_threshold = develop .get_option ("max_cat_threshold" ),
231
+ max_cat_threshold = develop .get_option (
232
+ "max_cat_threshold"
233
+ ),
223
234
cat_include = develop .get_option ("cat_include" ),
224
235
max_leaves = max_leaves ,
225
236
monotone_constraints = term_monotone ,
@@ -260,7 +271,9 @@ def boost(
260
271
for f , s , noise in zip (
261
272
splits_iter [:- 1 ], splits_iter [1 :], noises
262
273
):
263
- noisy_update_tensor [f :s ] = term_update_tensor [f :s ] + noise
274
+ noisy_update_tensor [f :s ] = (
275
+ term_update_tensor [f :s ] + noise
276
+ )
264
277
265
278
# Native code will be returning sums of residuals in slices, not averages.
266
279
# Compute noisy average by dividing noisy sum by noisy bin weights
@@ -292,7 +305,9 @@ def boost(
292
305
min (abs (min_metric ), abs (min_prev_metric ))
293
306
* early_stopping_tolerance
294
307
)
295
- if np .isnan (modified_tolerance ) or np .isinf (modified_tolerance ):
308
+ if np .isnan (modified_tolerance ) or np .isinf (
309
+ modified_tolerance
310
+ ):
296
311
modified_tolerance = 0.0
297
312
298
313
if cur_metric <= min_metric - min (0.0 , modified_tolerance ):
@@ -319,14 +334,19 @@ def boost(
319
334
circular_idx = (circular_idx + 1 ) % len (circular )
320
335
min_prev_metric = min (toss , min_prev_metric )
321
336
322
- if min_prev_metric - modified_tolerance <= circular .min ():
337
+ if (
338
+ min_prev_metric - modified_tolerance
339
+ <= circular .min ()
340
+ ):
323
341
break
324
342
325
343
if stop_flag is not None and stop_flag [0 ]:
326
344
break
327
345
328
346
if callback is not None :
329
- is_done = callback (bag_idx , step_idx , make_progress , cur_metric )
347
+ is_done = callback (
348
+ bag_idx , step_idx , make_progress , cur_metric
349
+ )
330
350
if is_done :
331
351
if stop_flag is not None :
332
352
stop_flag [0 ] = True
0 commit comments