def evaluate_approach(result, ground_truth, region, fractional=False):
    ground_truth = ground_truth.mask(ground_truth.mask().And(result.mask()))

    # TODO: Fix this!
    if fractional:  # Apply a MODIS pixel sized smoothing kernel ground truth
        ground_truth = ground_truth.convolve(ee.Kernel.square(250, 'meters', True))
    
    # Correct detections mean water detected in the same location.
    # - This does not include correct non-detections!
    correct = ground_truth.min(result)
    
    # Keep reducing the evaluation resolution until Earth Engine finishes without timing out
    MIN_EVAL_POINTS =  5000
    eval_points     = 60000
    while True:
        try:
            # This probably works now
            #correct_sum = correct.reduceRegion(     ee.Reducer.sum(), region, eval_res, 'EPSG:4326' ).getInfo()['b1'] # Correct detections
            #result_sum  = result.reduceRegion(      ee.Reducer.sum(), region, eval_res, 'EPSG:4326' ).getInfo()['b1'] # Total detections
            #truth_sum   = ground_truth.reduceRegion(ee.Reducer.sum(), region, eval_res, 'EPSG:4326' ).getInfo()['b1'] # Total water
    
            # Evaluate the results at a large number of random sample points
            correct_sum = ee.data.getValue({'image': correct.stats(     eval_points, region, 'EPSG:4326').serialize(), 'fields': 'b1'})['properties']['b1']['values']['sum']
            result_sum  = ee.data.getValue({'image': result.stats(      eval_points, region, 'EPSG:4326').serialize(), 'fields': 'b1'})['properties']['b1']['values']['sum']
            truth_sum   = ee.data.getValue({'image': ground_truth.stats(eval_points, region, 'EPSG:4326').serialize(), 'fields': 'b1'})['properties']['b1']['values']['sum']
            
            break # Quit the loop if the calculations were successful
        except Exception,e: # On failure coursen the resolution and try again
            print str(e)
            eval_points /= 2
            if eval_points < MIN_EVAL_POINTS:
                raise Exception('Unable to evaluate results at resolution ' + str(eval_points*2))

    # Compute ratios, avoiding divide by zero.
    precision   = 1.0 if (result_sum == 0.0) else (correct_sum / result_sum)
    recall      = 1.0 if (truth_sum  == 0.0) else (correct_sum / truth_sum)
    
    if (precision > 1.0) or (recall > 1.0):
        print 'EVALUATION_ERROR'
        print 'correct_sum = ' + str(correct_sum)
        print 'result_sum  = ' + str(result_sum)
        print 'truth_sum   = ' + str(truth_sum)
        #cmt.mapclient_qt.addToMap(correct, {}, 'CORRECT')
 
    ## A test of our result evaluation that does not depend on the ground truth!
    #no_truth_result = evaluate_result_quality(result, region)
    no_truth_result = 0 # For now skip calculating this to reduce the computation time
    
    return (precision, recall, eval_points, no_truth_result)
Modify a stack.
dataset/ETHPy150Open nasa/CrisisMappingToolkit/cmt/util/evaluation.py/evaluate_approach--crossover with--dataset/ETHPy150Open openstack/solum/solum/api/handlers/infrastructure_handler.py/InfrastructureStackHandler.update