コード例 #1
0
def evaluateWindowsByRadius(probabilityPath, geoRadius):
    # Initialize
    print 'Evaluating windows with %s meter radius...' % geoRadius
    scanInformation = probability_store.Information(probabilityPath)
    multispectralImage, panchromaticImage, actualGeoCenters, windowPixelDimensions = scanInformation.getPackage()
    geoDiameter = float(geoRadius) * 2
    # Get predictedGeoCenters
    predictedPixelCenters = probability_store.loadPredictedPixelCenters(probabilityPath, windowPixelDimensions)
    predictedGeoCenters = multispectralImage.convertPixelLocationsToGeoLocations(predictedPixelCenters)
    # Get
    actualNotPredictedCenters = point_process.extractBadLocations(geoDiameter, actualGeoCenters, predictedGeoCenters)
    predictedNotActualCenters = point_process.extractBadLocations(geoDiameter, predictedGeoCenters, actualGeoCenters)
    # Count
    actual = len(actualGeoCenters)
    predicted = len(predictedGeoCenters)
    actualNotPredicted = len(actualNotPredictedCenters)
    predictedNotActual = len(predictedNotActualCenters)
    actualAndPredicted = len(actualGeoCenters) - actualNotPredicted
    predictedAndActual = len(predictedGeoCenters) - predictedNotActual
    return {
        'evaluation radius in meters': geoRadius,
        'actual count': actual,
        'predicted count': predicted,
        'actual not predicted count': actualNotPredicted,
        'predicted not actual count': predictedNotActual,
        'predicted and actual count': predictedAndActual,
        'actual and predicted count': actualAndPredicted,
        'pNa/p': predictedNotActual / float(predicted) if predicted else None,
        'aNp/a': actualNotPredicted / float(actual) if actual else None,
        'precision': predictedAndActual / float(predicted) if predicted else None,
        'recall': actualAndPredicted / float(actual) if actual else None,
    }
コード例 #2
0
def compareLocations(geoDiameter, rawActualLocations, rawPredictedLocations, regionGeoFrames):
    # Prepare
    actualPointMachine = point_process.PointMachine(rawActualLocations, 'REAL')
    predictedPointMachine = point_process.PointMachine(rawPredictedLocations, 'REAL')
    heap = {
        'actual': set(),
        'predicted': set(),
        'actualNotPredicted': set(),
        'predictedNotActual': set(),
    }
    # For each regionGeoFrame,
    for regionIndex, regionGeoFrame in enumerate(regionGeoFrames):
        # Filter
        actualLocations = actualPointMachine.getPointsInsideFrame(regionGeoFrame)
        predictedLocations = predictedPointMachine.getPointsInsideFrame(regionGeoFrame)
        # Get
        actualNotPredictedLocations = point_process.extractBadLocations(geoDiameter, actualLocations, rawPredictedLocations)
        predictedNotActualLocations = point_process.extractBadLocations(geoDiameter, predictedLocations, rawActualLocations)
        # Store
        heap['actual'].update(actualLocations)
        heap['predicted'].update(predictedLocations)
        heap['actualNotPredicted'].update(actualNotPredictedLocations)
        heap['predictedNotActual'].update(predictedNotActualLocations)
        # Show feedback
        view.printPercentUpdate(regionIndex, len(regionGeoFrames))
    # Show feedback
    view.printPercentFinal(len(regionGeoFrames))
    # Return
    return heap, {
        'actual count': len(heap['actual']),
        'predicted count': len(heap['predicted']),
        'actual not predicted count': len(heap['actualNotPredicted']),
        'predicted not actual count': len(heap['predictedNotActual']),
    }