from concurrent.futures import ProcessPoolExecutor
from sklearn.externals import joblib
future = X_train.columns.values.tolist()
def multiproc_iter_func(max_workers, an_iter, func, item_kwarg, **kwargs):
with ProcessPoolExecutor(max_workers=max_workers) as executor:
future_results = [executor.submit(func, **{item_kwarg: item}, **kwargs)
for item in an_iter]
results = [future.result() for future in future_results]
return results
import eli5
train_expl_list = multiproc_iter_func(12, X_train.as_matrix(),
eli5.explain_prediction_df, 'doc',
estimator=gbrt,
feature_names=future)
X_train.as_matrix()