@@ -115,6 +115,9 @@ class StackingClassifier(BaseEstimator, ClassifierMixin, TransformerMixin):
115
115
features_indices : list of indexers
116
116
Index epxressions to be applied on the columns of X_stacked.
117
117
Can be slices, lists of intgers or bool.
118
+
119
+ n_jobs : int (default: 1)
120
+ The number of jobs to run in parallel (across estimators).
118
121
"""
119
122
120
123
def __init__ (self , estimators ,
@@ -260,6 +263,27 @@ def predict_estimators(self, X):
260
263
for x , clf in zip (X_list , self .estimators ))
261
264
return np .array (predictions_ ).T
262
265
266
+ def predict_proba_estimators (self , X ):
267
+ """Predict class label probability for samples in X for each estimators.
268
+
269
+ Parameters
270
+ ----------
271
+ X : {array-like, sparse matrix}, shape = (n_samples, n_features)
272
+ The multi-input samples.
273
+
274
+ Returns
275
+ -------
276
+ C : array, shape = (n_samples, n_classes, n_estimators)
277
+ Predicted class label per sample and estimators.
278
+ """
279
+ _check_Xy (self , X )
280
+ X_list = _split_features (X , self .feature_indices )
281
+ predictions_ = Parallel (n_jobs = self .n_jobs )(
282
+ delayed (_predict_proba_estimator )(clf , x )
283
+ for x , clf in zip (X_list , self .estimators ))
284
+ return np .transpose (np .array (predictions_ ),
285
+ (1 , 2 , 0 ))
286
+
263
287
def score_estimators (self , X , y ):
264
288
"""Returns the mean accuracy for each estimators.
265
289
0 commit comments