def eval_models(eda_objs, clfs):
'''
Uses a given set of classifiers objects to evaluates a given set of pipelines
and return their CV scores.
Parameters
----------
pipelines_names: list of strings
names of the pipelines to compare
eda_objs : list of objects
clfs : list of classifiers
*kwargs : Additional arguments to pass to sikit-learn's cross_val_score
'''
if isinstance(clfs, list) is False:
clfs = [clfs]
acc = []
for clf_name, clf in clfs:
for pipe_name, obj in eda_objs:
X, y = obj.df[obj._get_input_features()], obj.df[obj.y]
cv_score = cross_val_score(estimator=clf, X=X, y=y, cv=5, scoring='r2') #neg_mean_squared_error
acc.append([(clf_name, pipe_name, v) for v in cv_score])
acc = [item for sublist in acc for item in sublist] # flatten the list of lists
return acc
评论列表
文章目录