Skip to main content

Automation of Pontius Matrix

Project description

Python Library developed and created to automate the generation and analysis of the PonitusMatrix.
Version History:

  • Version 1.0 (Multiple Categories)
  • Version 1.1 (Multiple Categories, Quantity, Exchange, Shift, Size, Difference)
    Python Version: 3.7
    Latest Publish Date: November, 2020

Dependencies & Usage

import pandas as pd
from pontiPy import pontiPy
  • Creating a Dataframe from an inputted Sample & Loading the pontiPy package
initialDataFrame = pd.read_csv('sample.csv', index_col= 0)
display(initialDataFrame)
NewDataFrame = pontiPy(initialDataFrame)

Functions

Available functions in pontiPy Library

Matrix

  • Displays inputted matrix
  • Generates PontiusMatrix Contingency Table
    This will generate the final output contingency table

Arguments

  • Generates Initial Contingency Table = matrix()

Examples

  • Displaying the sample data through the contingency table function
display(NewDataFrame.matrix())

Size

  • Function to Compute Size for all or one Category k
  • Axis must be specified when category k is specified
  • Determines if row or column sum for category k will be returned

Arguments

  • No category specified = size()
    Size of Extent
  • Category k specified = size(k)
    Size of category k
    a) Axis 'X' = Size of category k in X (row sum): size(k, X)
    b) Axis 'Y' = Size of category k in Y (col sum): size(k, Y)
    c) No Axis specified = Size of category k
  • Category k Specified with TRUE = size(k, X or Y, TRUE)
    Dictionary listing the size of other categories contained in category k (includes hits)
  • Category k Specified, Total = size(k, Total = TRUE)
    Returns the Total. Only works if a category is provided. If True, returns the total size (x & y) for category k

Example

print('Size of Extent:', NewDataFrame.size(), 'Hectares') 

Size of Extent: 25662 Hectares

print('Size of Category 1 in X:', NewDataFrame.size(0,'X'),'Hectares')  

Size of Category 1 in X: 2296 Hectares

print('Size of Category 1 in Y:', NewDataFrame.size(0,'Y'),'Hectares')

Size of Category 1 in Y: 2144 Hectares

Difference

  • Function to compute difference for all or one category

Arguments

  • No category specified = difference()
    Equation = (Total Size - Hits)
  • Category k specified = difference(k)
    Equation = (Size-(2Hits)) For That Category

Example

print('Total Difference:', NewDataFrame.difference(), 'Hectares')  
print('Difference for Category 1:', NewDataFrame.difference(0), 'Hectares')  

Hit, Miss, and False Alarm

  • Functions to compute Hits, Misses, and False Alarms

Arguments

  • No Category specified = hit(), miss(), false_alarm()
    Sum of Total Hits, Misses, or False Alarms
  • Category k specified = hit(k), miss(k), false_alarm(k)
    Hits, Misses, or False Alarms for Category k

Example

print('Total Hits:', NewDataFrame.hit(), 'Hectares')  

Total Hits: 3553 Hectares

print('Total Misses:', NewDataFrame.miss(), 'Hectares')  

Total Misses: 8735 Hectares

print('The Total False Alarms:', NewDataFrame.false_alarm(), 'Hectares')  

The Total False Alarms: 8735 Hectares

Quantity

Function to compute quantity between all or one category
Returns as a dictionary

Arguments

  • No Category Specified = quantity()
    Total Quantity Disagreement
    Equation = [(Sum of quantity(k) for all k) / 2 ]
  • Category k Specified: = quantity(k)
    Quantity Disagreement for k: |M-F|
  • Category k Specified with TRUE parameter): = quantity(k,TRUE)
    Quantity is returned with Miss or False Alarm labels:
    If M-F is positive = Miss Quantity
    If M-F is negative = False Alarm Quantity
    If value = 0, then Quantity is 0

Example

print('Total Quantity Disagreement:', NewDataFrame.quantity(), 'Hectares')

Total Quantity Disagreement: 76 Hectares

print('Quantity Disagreement for Category 1 w/ label:', NewDataFrame.quantity(0, True), 'Hectares')

Quantity Disagreement for Category 1 w/ label: {'False Alarm': 152} Hectares

Exchange

Function to compute Exchange between ALL, ONE or TWO categories

Arguments

  • No Category Specified = exchange()
    Sum of total exchange is returned
    Total must be false
  • If total is False and 1 category is specified: = exchange(TRUE,k)
    Return is exchange for that category with all other categories + a total value in dictionary
  • If Total is True and 1 category is specified: = exchange(FALSE,k)
    Return is total exchange for that category
  • If 2 categories are specified (Total must be false): = exchange(FALSE,k,k)
    Return exchange between 2 categories

Example

print('Total Exchange Disagreement:', NewDataFrame.exchange(), 'Hectares')

Total Exchange Disagreement: 0 Hectares

print('Exchange between Category 1 and 2:', NewDataFrame.exchange(0,1), 'Hectares')

Exchange between Category 1 and 2: 0 Hectares

Shift

Function to compute shift between ALL or ONE categories

Arguments

  • No Category Specified = shift()
    Total Shift Disagreement
    Equation = [(sum of shift(k) for all k) / 2 ]
  • Category k specified = shift(k)
    Shift Disagreement for k
    Equation = (difference(k) – quantity(k) – exchange(k))

Example

print('Total Shift Disagreement:', NewDataFrame.shift(), 'Hectares')
print('Shift Disagreement for Category 1:', NewDataFrame.shift(0), 'Hectares')

Further Information & Contact

Acknowledgements

Dr. Robert Gilmore Pontius Jr created the first version of this workbook in 2001. Pontius has revised this workbook several times, and each revision has a larger number for the suffix of the filename. Pontius created version 42 in 2019.

Visit www.clarku.edu/~rpontius for publications on this workbook's methods. Specificaly, see: Pontius Jr, Robert Gilmore and Ali Santacruz. 2014. Quantity, Exchange and Shift Components of Differences in a Square Contingency Table. International Journal of Remote Sensing 35(21): 7543-7554.

Pontius Jr, Robert Gilmore. 2019. Component intensities to relate difference by category with difference overall. International Journal of Applied Earth Observations and Geoinformation 77: 94-99.

Pontius Jr, Robert Gilmore and Marco Millones. 2011. Death to Kappa: birth of quantity disagreement and allocation disagreement for accuracy assessment. International Journal of Remote Sensing 32(15): 4407-4429.

Aldwaik, Safaa Zakaria, Jeffrey A Onsted, and Robert Gilmore Pontius Jr. 2015. Behavior-based aggregation of land categories for temporal change analysis. International Journal of Applied Earth Observation and Geoinformation 35(Part B): 229-238.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pontiPy-2.6.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pontiPy-2.6-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file pontiPy-2.6.tar.gz.

File metadata

  • Download URL: pontiPy-2.6.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.0

File hashes

Hashes for pontiPy-2.6.tar.gz
Algorithm Hash digest
SHA256 61767477dabbcf282febca5664af6cc9095e81a709d6d60b682a778fb13bc68b
MD5 2a1897f1f3cb00ba2a50cfc80d84ccec
BLAKE2b-256 a5219e333de6020cc614bc3b4684913c300d23020c74996689fe6d96417cbb4e

See more details on using hashes here.

File details

Details for the file pontiPy-2.6-py3-none-any.whl.

File metadata

  • Download URL: pontiPy-2.6-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.0

File hashes

Hashes for pontiPy-2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 b061f4c504b6bc1b355c93adf14378842c2240f444aba3c4121ea8894aed7491
MD5 62b538a6d5ebebf32a8d69ca613d9b9e
BLAKE2b-256 68613ae4a8e1dc2724208521c46ea61a301a381fdf3149fa0b3129886ba3938f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page