Historical Map
1.0
Plugin for automatic extraction of old forest from historical map
Main Page
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Files
Functions
Variables
accuracy_index.py
Go to the documentation of this file.
1
'''!@brief Accuracy index by Mathieu Fauvel
2
'''
3
import
scipy
as
sp
4
5
class
CONFUSION_MATRIX
:
6
def
__init__
(self):
7
self.
confusion_matrix
=
None
8
self.
OA
=
None
9
self.
Kappa
=
None
10
11
def
compute_confusion_matrix
(self,yp,yr):
12
'''
13
Compute the confusion matrix
14
'''
15
# Initialization
16
n = yp.size
17
C=int(yr.max())
18
self.
confusion_matrix
=sp.zeros((C,C))
19
20
# Compute confusion matrix
21
for
i
in
range(n):
22
self.
confusion_matrix
[yp[i].astype(int)-1,yr[i].astype(int)-1] +=1
23
24
# Compute overall accuracy
25
self.
OA
=sp.sum(sp.diag(self.
confusion_matrix
))/n
26
27
# Compute Kappa
28
nl = sp.sum(self.
confusion_matrix
,axis=1)
29
nc = sp.sum(self.
confusion_matrix
,axis=0)
30
self.
Kappa
= ((n**2)*self.
OA
- sp.sum(nc*nl))/(n**2-sp.sum(nc*nl))
31
32
# TBD Variance du Kappa
HistoricalMap.accuracy_index.CONFUSION_MATRIX.confusion_matrix
confusion_matrix
Definition:
accuracy_index.py:7
HistoricalMap.accuracy_index.CONFUSION_MATRIX.OA
OA
Definition:
accuracy_index.py:8
HistoricalMap.accuracy_index.CONFUSION_MATRIX.__init__
def __init__
Definition:
accuracy_index.py:6
HistoricalMap.accuracy_index.CONFUSION_MATRIX.Kappa
Kappa
Definition:
accuracy_index.py:9
HistoricalMap.accuracy_index.CONFUSION_MATRIX.compute_confusion_matrix
def compute_confusion_matrix
Definition:
accuracy_index.py:11
HistoricalMap.accuracy_index.CONFUSION_MATRIX
Definition:
accuracy_index.py:5
Generated on Mon Feb 22 2016 15:13:05 for Historical Map by
1.8.6