12
12
from sklearn .externals .joblib import Memory , Parallel , delayed
13
13
14
14
15
- def fit_estimator (clf , X , y ):
15
+ def _fit_estimator (clf , X , y ):
16
+ """Helper to fit estimator"""
16
17
return clf .fit (X , y )
17
18
18
19
19
- def predict_estimator (clf , X ):
20
+ def _predict_estimator (clf , X ):
21
+ """Helper tor predict"""
20
22
return clf .predict (X )
21
23
22
24
23
- def predict_proba_estimator (clf , X ):
25
+ def _predict_proba_estimator (clf , X ):
26
+ """Helper to get prediction method"""
24
27
# try predict_proba
25
28
predict_proba = getattr (clf , "predict_proba" , None )
26
29
if callable (predict_proba ):
@@ -56,11 +59,11 @@ def fit(self, X, y):
56
59
"""
57
60
58
61
self .estimators = Parallel (n_jobs = self .n_jobs )(
59
- delayed (fit_estimator )(clf , x , y )
62
+ delayed (_fit_estimator )(clf , x , y )
60
63
for x , clf in zip (X , self .estimators ))
61
64
62
65
predictions_ = Parallel (n_jobs = self .n_jobs )(
63
- delayed (predict_proba_estimator )(clf , x )
66
+ delayed (_predict_proba_estimator )(clf , x )
64
67
for x , clf in zip (X , self .estimators ))
65
68
predictions_ = np .array (predictions_ ).T
66
69
@@ -73,7 +76,7 @@ def predict(self, X):
73
76
"""
74
77
75
78
predictions_ = Parallel (n_jobs = self .n_jobs )(
76
- delayed (predict_proba_estimator )(clf , x )
79
+ delayed (_predict_proba_estimator )(clf , x )
77
80
for x , clf in zip (X , self .estimators ))
78
81
predictions_ = np .array (predictions_ ).T
79
82
@@ -88,7 +91,7 @@ def predict_estimators(self, X):
88
91
""" prediction from separate estimators
89
92
"""
90
93
predictions_ = Parallel (n_jobs = self .n_jobs )(
91
- delayed (predict_estimator )(clf , x )
94
+ delayed (_predict_estimator )(clf , x )
92
95
for x , clf in zip (X , self .estimators ))
93
96
return np .array (predictions_ ).T
94
97
0 commit comments