def evaluate(datasource, select, result_table, model, label_name=None, model_params=None, result_column_names=[], pai_table=None):
    'TBD\n    '
    if (model_params is None):
        model_params = {}
    validation_metrics = model_params.get('validation.metrics', 'accuracy_score')
    validation_metrics = [m.strip() for m in validation_metrics.split(',')]
    bst = xgb.Booster()
    if isinstance(model, six.string_types):
        with temp_file.TemporaryDirectory(as_cwd=True):
            model = Model.load_from_db(datasource, model)
            bst.load_model('my_model')
    else:
        assert isinstance(model, Model), ('not supported model type %s' % type(model))
        bst.load_model('my_model')
    model_params = model.get_meta('attributes')
    fc_map_ir = model.get_meta('features')
    train_label = model.get_meta('label')
    train_label_desc = train_label.get_field_desc()[0]
    if label_name:
        train_label_desc.name = label_name
    feature_columns = compile_ir_feature_columns(fc_map_ir, EstimatorType.XGBOOST)
    field_descs = get_ordered_field_descs(fc_map_ir)
    feature_column_names = [fd.name for fd in field_descs]
    feature_metas = dict([(fd.name, fd.to_dict(dtype_to_string=True)) for fd in field_descs])
    transform_fn = ComposedColumnTransformer(feature_column_names, *feature_columns['feature_columns'])
    is_pai = (True if pai_table else False)
    if is_pai:
        conn = PaiIOConnection.from_table(pai_table)
    else:
        conn = db.connect_with_data_source(datasource)
    with temp_file.TemporaryDirectory() as tmp_dir_name:
        pred_fn = os.path.join(tmp_dir_name, 'predict.txt')
        dpred = xgb_dataset(datasource=datasource, fn=pred_fn, dataset_sql=select, feature_metas=feature_metas, feature_column_names=feature_column_names, label_meta=train_label_desc.to_dict(dtype_to_string=True), cache=True, batch_size=10000, transform_fn=transform_fn, is_pai=is_pai, pai_table=pai_table, pai_single_file=True, feature_column_code=fc_map_ir)
        for (i, pred_dmatrix) in enumerate(dpred):
            if is_pai:
                feature_file_name = pred_fn
            else:
                feature_file_name = (pred_fn + ('_%d' % i))
            preds = _calc_predict_result(bst, pred_dmatrix, model_params)
            _store_evaluate_result(preds, feature_file_name, train_label_desc, result_table, result_column_names, validation_metrics, conn)
    conn.close()
TBD
def evaluate(datasource, select, result_table, model, label_name=None, model_params=None, result_column_names=[], pai_table=None):
    '\n    '
    if (model_params is None):
        model_params = {}
    validation_metrics = model_params.get('validation.metrics', 'accuracy_score')
    validation_metrics = [m.strip() for m in validation_metrics.split(',')]
    bst = xgb.Booster()
    if isinstance(model, six.string_types):
        with temp_file.TemporaryDirectory(as_cwd=True):
            model = Model.load_from_db(datasource, model)
            bst.load_model('my_model')
    else:
        assert isinstance(model, Model), ('not supported model type %s' % type(model))
        bst.load_model('my_model')
    model_params = model.get_meta('attributes')
    fc_map_ir = model.get_meta('features')
    train_label = model.get_meta('label')
    train_label_desc = train_label.get_field_desc()[0]
    if label_name:
        train_label_desc.name = label_name
    feature_columns = compile_ir_feature_columns(fc_map_ir, EstimatorType.XGBOOST)
    field_descs = get_ordered_field_descs(fc_map_ir)
    feature_column_names = [fd.name for fd in field_descs]
    feature_metas = dict([(fd.name, fd.to_dict(dtype_to_string=True)) for fd in field_descs])
    transform_fn = ComposedColumnTransformer(feature_column_names, *feature_columns['feature_columns'])
    is_pai = (True if pai_table else False)
    if is_pai:
        conn = PaiIOConnection.from_table(pai_table)
    else:
        conn = db.connect_with_data_source(datasource)
    with temp_file.TemporaryDirectory() as tmp_dir_name:
        pred_fn = os.path.join(tmp_dir_name, 'predict.txt')
        dpred = xgb_dataset(datasource=datasource, fn=pred_fn, dataset_sql=select, feature_metas=feature_metas, feature_column_names=feature_column_names, label_meta=train_label_desc.to_dict(dtype_to_string=True), cache=True, batch_size=10000, transform_fn=transform_fn, is_pai=is_pai, pai_table=pai_table, pai_single_file=True, feature_column_code=fc_map_ir)
        for (i, pred_dmatrix) in enumerate(dpred):
            if is_pai:
                feature_file_name = pred_fn
            else:
                feature_file_name = (pred_fn + ('_%d' % i))
            preds = _calc_predict_result(bst, pred_dmatrix, model_params)
            _store_evaluate_result(preds, feature_file_name, train_label_desc, result_table, result_column_names, validation_metrics, conn)
    conn.close()