Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
geopyck
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alice Brenon
geopyck
Commits
09712adc
Commit
09712adc
authored
10 months ago
by
Alice Brenon
Browse files
Options
Downloads
Patches
Plain Diff
Rename the Nearest-Neighbour matrix now that I've recognised it
parent
226437a9
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
GEODE/Visualisation/ConfusionMatrix.py
+8
-7
8 additions, 7 deletions
GEODE/Visualisation/ConfusionMatrix.py
GEODE/Visualisation/__init__.py
+1
-1
1 addition, 1 deletion
GEODE/Visualisation/__init__.py
GEODE/__init__.py
+1
-1
1 addition, 1 deletion
GEODE/__init__.py
with
10 additions
and
9 deletions
GEODE/Visualisation/ConfusionMatrix.py
+
8
−
7
View file @
09712adc
...
...
@@ -30,7 +30,7 @@ def maxOutOfDiagonal(n, row):
m
=
max
([
row
[
i
]
for
i
in
range
(
l
)
if
i
!=
n
])
return
[
row
[
i
]
if
i
!=
n
and
row
[
i
]
==
m
else
0
for
i
in
range
(
l
)]
def
maxConfusionMatrix
(
m
):
def
nearestNeighbour
(
m
):
return
[
maxOutOfDiagonal
(
i
,
m
[
i
])
for
i
in
range
(
len
(
m
))]
def
confusionMatrix
(
data
,
labels
):
...
...
@@ -44,10 +44,10 @@ def getConfusionMatrix(inputFile, labels=None):
elif
inputFile
[
-
5
:]
==
'
.json
'
:
return
JSON
.
load
(
inputFile
)
def
extractConfusionMatrix
(
inputFile
,
outputJSON
,
labels
=
None
,
maximal
=
False
):
def
extractConfusionMatrix
(
inputFile
,
outputJSON
,
labels
=
None
,
nearest
=
False
):
data
=
getConfusionMatrix
(
inputFile
,
labels
)
if
maximal
:
data
[
'
matrix
'
]
=
maxConfusionMatrix
(
data
[
'
matrix
'
])
if
nearest
:
data
[
'
matrix
'
]
=
nearestNeighbour
(
data
[
'
matrix
'
])
JSON
.
save
(
data
,
outputJSON
)
def
getArgs
(
arguments
):
...
...
@@ -57,8 +57,9 @@ def getArgs(arguments):
cli
.
add_argument
(
'
inputFile
'
)
cli
.
add_argument
(
'
outputJSON
'
)
add_labels_argument
(
cli
)
cli
.
add_argument
(
'
-m
'
,
'
--maximal
'
,
action
=
'
store_const
'
,
const
=
True
,
default
=
False
,
help
=
"
Simplify the matrix into an MCM
"
)
cli
.
add_argument
(
'
-n
'
,
'
--nearestNeighbour
'
,
action
=
'
store_const
'
,
const
=
True
,
default
=
False
,
help
=
"
Simplify the matrix into an MCM
"
)
return
cli
.
parse_args
(
arguments
)
def
extractConfusionMatrixCLI
(
arguments
):
...
...
@@ -67,4 +68,4 @@ def extractConfusionMatrixCLI(arguments):
extractConfusionMatrix
(
args
.
inputFile
,
args
.
outputJSON
,
labels
=
labels
,
maximal
=
args
.
maximal
)
nearest
=
args
.
nearestNeighbour
)
This diff is collapsed.
Click to expand it.
GEODE/Visualisation/__init__.py
+
1
−
1
View file @
09712adc
from
GEODE.Visualisation.ConfusionMatrix
import
extractConfusionMatrix
,
\
maxConfusionMatrix
nearestNeighbour
from
GEODE.Visualisation.DensityProfile
import
densityProfile
,
\
drawDensityProfile
,
plotDensity
from
GEODE.Visualisation.DrawMatrix
import
drawMatrix
...
...
This diff is collapsed.
Click to expand it.
GEODE/__init__.py
+
1
−
1
View file @
09712adc
...
...
@@ -24,7 +24,7 @@ from GEODE.Metadata import article, articleKey, paragraph, paragraphKey, \
fromKey
,
relativePath
,
toKey
,
uid
from
GEODE.Store
import
corpus
,
Directory
,
JSON
,
SelfContained
,
tabular
,
toTSV
from
GEODE.Visualisation
import
densityProfile
,
drawMatrix
,
drawGraph
,
legend
,
\
maxConfusionMatrix
nearestNeighbour
from
GEODE.Visualisation.ConfusionMatrix
import
extractConfusionMatrixCLI
from
GEODE.Visualisation.DensityProfile
import
drawDensityProfileCLI
from
GEODE.Visualisation.DrawMatrix
import
drawMatrixCLI
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment