@@ -76,6 +76,17 @@ class Arsenal(BaseClassifier):
76
76
The collections of estimators trained in fit.
77
77
weights_ : list of shape (n_estimators) of float
78
78
Weight of each estimator in the ensemble.
79
+ class_weight{“balanced”, “balanced_subsample”}, dict or list of dicts, default=None
80
+ From sklearn documentation:
81
+ If not given, all classes are supposed to have weight one.
82
+ The “balanced” mode uses the values of y to automatically adjust weights
83
+ inversely proportional to class frequencies in the input data as
84
+ n_samples / (n_classes * np.bincount(y))
85
+ The “balanced_subsample” mode is the same as “balanced” except that weights
86
+ are computed based on the bootstrap sample for every tree grown.
87
+ For multi-output, the weights of each column of y will be multiplied.
88
+ Note that these weights will be multiplied with sample_weight (passed through
89
+ the fit method) if sample_weight is specified.
79
90
n_estimators_ : int
80
91
The number of estimators in the ensemble.
81
92
@@ -125,6 +136,7 @@ def __init__(
125
136
n_features_per_kernel = 4 ,
126
137
time_limit_in_minutes = 0.0 ,
127
138
contract_max_n_estimators = 100 ,
139
+ class_weight = None ,
128
140
n_jobs = 1 ,
129
141
random_state = None ,
130
142
):
@@ -135,6 +147,7 @@ def __init__(
135
147
self .n_features_per_kernel = n_features_per_kernel
136
148
self .time_limit_in_minutes = time_limit_in_minutes
137
149
self .contract_max_n_estimators = contract_max_n_estimators
150
+ self .class_weight = class_weight
138
151
139
152
self .random_state = random_state
140
153
self .n_jobs = n_jobs
@@ -355,7 +368,9 @@ def _fit_ensemble_estimator(self, rocket, X, y, keep_transformed_data):
355
368
transformed_x = rocket .fit_transform (X )
356
369
scaler = StandardScaler (with_mean = False )
357
370
scaler .fit (transformed_x , y )
358
- ridge = RidgeClassifierCV (alphas = np .logspace (- 3 , 3 , 10 ))
371
+ ridge = RidgeClassifierCV (
372
+ alphas = np .logspace (- 3 , 3 , 10 ), class_weight = self .class_weight
373
+ )
359
374
ridge .fit (scaler .transform (transformed_x ), y )
360
375
return [
361
376
make_pipeline (rocket , scaler , ridge ),
@@ -380,7 +395,9 @@ def _train_probas_for_estimator(self, Xt, y, idx, rng):
380
395
381
396
clf = make_pipeline (
382
397
StandardScaler (with_mean = False ),
383
- RidgeClassifierCV (alphas = np .logspace (- 3 , 3 , 10 )),
398
+ RidgeClassifierCV (
399
+ alphas = np .logspace (- 3 , 3 , 10 ), class_weight = self .class_weight
400
+ ),
384
401
)
385
402
clf .fit (Xt [idx ][subsample ], y [subsample ])
386
403
preds = clf .predict (Xt [idx ][oob ])
0 commit comments