# Path: datarobot_batch_scoring/consts.py
# class TargetType(object):
#     REGRESSION = 'Regression'
#     BINARY = 'Binary'
# 
# Path: datarobot_batch_scoring/exceptions.py
# class UnexpectedKeptColumnCount(Exception):
#     pass


import operator
import json
from datarobot_batch_scoring.consts import TargetType
from datarobot_batch_scoring.exceptions import UnexpectedKeptColumnCount
    elif result['task'] == TargetType.REGRESSION:
        pred = [[p['row_id'] + batch.id, p['prediction']]
                for p in
                sorted(predictions,
                       key=operator.itemgetter('row_id'))]
        out_fields = ['row_id', pred_name if pred_name else '']
    else:
        raise ValueError('task "{}" not supported'
                         ''.format(result['task']))

    if keep_cols:
        # stack columns

        feature_indices = {col: i for i, col in
                           enumerate(batch.fieldnames)}
        indices = [feature_indices[col] for col in keep_cols]

        written_fields = []

        if not skip_row_id:
            written_fields.append('row_id')

        written_fields += keep_cols + out_fields[1:]

        # first column is row_id
        comb = []
        for row, predicted in zip(batch.data, pred):
            if fast_mode:
                # row is a full line, we need to cut it into fields
                if len(row) != len(batch.fieldnames):

# Path: datarobot_batch_scoring/consts.py
# class TargetType(object):
#     REGRESSION = 'Regression'
#     BINARY = 'Binary'
# 
# Path: datarobot_batch_scoring/exceptions.py
# class UnexpectedKeptColumnCount(Exception):
#     pass


# Path: datarobot_batch_scoring/api_response_handlers/api_v1.py
import operator
import json
from datarobot_batch_scoring.consts import TargetType
from datarobot_batch_scoring.exceptions import UnexpectedKeptColumnCount

    elif result['task'] == TargetType.REGRESSION:
        pred = [[p['row_id'] + batch.id, p['prediction']]
                for p in
                sorted(predictions,
                       key=operator.itemgetter('row_id'))]
        out_fields = ['row_id', pred_name if pred_name else '']
    else:
        raise ValueError('task "{}" not supported'
                         ''.format(result['task']))

    if keep_cols:
        # stack columns

        feature_indices = {col: i for i, col in
                           enumerate(batch.fieldnames)}
        indices = [feature_indices[col] for col in keep_cols]

        written_fields = []

        if not skip_row_id:
            written_fields.append('row_id')

        written_fields += keep_cols + out_fields[1:]

        # first column is row_id
        comb = []
        for row, predicted in zip(batch.data, pred):
            if fast_mode:
                # row is a full line, we need to cut it into fields
                if len(row) != len(batch.fieldnames):

                    raise UnexpectedKeptColumnCount()