# Path: datarobot_batch_scoring/exceptions.py
# class UnexpectedKeptColumnCount(Exception):
#     pass
# 
# class NoPredictionThresholdInResult(Exception):
#     pass


import operator
import json
from itertools import chain
from six.moves import zip
from datarobot_batch_scoring.exceptions import UnexpectedKeptColumnCount, \
    NoPredictionThresholdInResult
    # Prediction value columns
    fields.append(prediction_values_fields(result_sorted, pred_name))

    # Explanations columns
    single_row = result_sorted[0]
    prediction_explanations_keys = ('predictionExplanations', 'reasonCodes',
                                    None)

    def _find_prediction_explanations_key():
        return [key for key in prediction_explanations_keys
                if key in single_row or key is None][0]

    prediction_explanations_key = _find_prediction_explanations_key()
    if prediction_explanations_key:
        fields.append(
            prediction_explanation_fields(
                result_sorted,
                prediction_explanations_key,
                max_prediction_explanations,
            )
        )

    # Threshold field for classification
    # ('predictionThreshold' value from result)
    if pred_threshold_name:
        if 'predictionThreshold' in single_row:
            fields.append(
                pred_threshold_field(result_sorted, pred_threshold_name)
            )
        else:

# Path: datarobot_batch_scoring/exceptions.py
# class UnexpectedKeptColumnCount(Exception):
#     pass
# 
# class NoPredictionThresholdInResult(Exception):
#     pass


# Path: datarobot_batch_scoring/api_response_handlers/pred_api_v10.py
import operator
import json
from itertools import chain
from six.moves import zip
from datarobot_batch_scoring.exceptions import UnexpectedKeptColumnCount, \
    NoPredictionThresholdInResult

    # Prediction value columns
    fields.append(prediction_values_fields(result_sorted, pred_name))

    # Explanations columns
    single_row = result_sorted[0]
    prediction_explanations_keys = ('predictionExplanations', 'reasonCodes',
                                    None)

    def _find_prediction_explanations_key():
        return [key for key in prediction_explanations_keys
                if key in single_row or key is None][0]

    prediction_explanations_key = _find_prediction_explanations_key()
    if prediction_explanations_key:
        fields.append(
            prediction_explanation_fields(
                result_sorted,
                prediction_explanations_key,
                max_prediction_explanations,
            )
        )

    # Threshold field for classification
    # ('predictionThreshold' value from result)
    if pred_threshold_name:
        if 'predictionThreshold' in single_row:
            fields.append(
                pred_threshold_field(result_sorted, pred_threshold_name)
            )
        else:

            raise NoPredictionThresholdInResult()