Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EDdA Classification
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
Projet GEODE
EDdA Classification
Commits
5edc22a5
Commit
5edc22a5
authored
3 years ago
by
Alice Brenon
Browse files
Options
Downloads
Patches
Plain Diff
Add notebook to visualize the graph of domain adjacencies according to their confusion matrices
parent
8da28111
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
guix.scm
+9
-5
9 additions, 5 deletions
guix.scm
notebooks/Domains Graphs.ipynb
+122
-0
122 additions, 0 deletions
notebooks/Domains Graphs.ipynb
with
131 additions
and
5 deletions
guix.scm
+
9
−
5
View file @
5edc22a5
...
...
@@ -2,6 +2,7 @@
((
gnu
packages
python-xyz
)
#
:select
(
python-matplotlib
python-nltk
python-seaborn
))
((
gnu
packages
graphviz
)
#
:select
(
graphviz
python-graphviz
))
(
guix
gexp
)
(
guix
git-download
)
((
guix
licenses
)
#
:select
(
lgpl3+
))
...
...
@@ -19,14 +20,17 @@
#
:select?
(
git-predicate
%source-dir
)))
(
build-system
python-build-system
)
(
propagated-inputs
(
list
python-matplotlib
(
list
graphviz
python-graphviz
python-matplotlib
python-nltk
python-pandas
python-seaborn
))
python-seaborn
))
(
home-page
"https://gitlab.liris.cnrs.fr/geode/pyedda"
)
(
synopsis
"A set of tools to explore the EDdA"
)
(
description
"PyEDdA provides a python library to expose the data from the Encyclopédie
by Diderot & d'Alembert, as well as several subpackages for the various
approach tested in the course of project GÉODE."
)
"PyEDdA provides a python library to expose the data from the Encyclopédie
by Diderot & d'Alembert, as well as several subpackages for the various
approach tested in the course of project GÉODE."
)
(
license
lgpl3+
)))
This diff is collapsed.
Click to expand it.
notebooks/Domains Graphs.ipynb
0 → 100644
+
122
−
0
View file @
5edc22a5
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "fc7a6e69",
"metadata": {},
"outputs": [],
"source": [
"from EDdA import data\n",
"from EDdA.store import preparePath\n",
"from EDdA.classification import confusionMatrix, metrics, toPNG, topNGrams\n",
"from IPython.display import Image\n",
"import graphviz\n",
"import os"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "f49c39b5",
"metadata": {},
"outputs": [],
"source": [
"source = data.load('training_set')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "3a37bfa1",
"metadata": {},
"outputs": [],
"source": [
"def nearestAdjacency(matrix):\n",
" m = []\n",
" dimension = len(matrix)\n",
" for i in range(0, dimension):\n",
" link = max([matrix[i][j] for j in range(0, dimension) if j != i])\n",
" if link == 0:\n",
" m.append([])\n",
" else:\n",
" m.append([j for j in range(0, dimension) if j != i and matrix[i][j] == link])\n",
" return m"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "b9c92861",
"metadata": {},
"outputs": [],
"source": [
"def listToMatrix(adjacencyList):\n",
" m = []\n",
" dimension = len(adjacencyList)\n",
" for i in range(0, dimension):\n",
" m.append(dimension * [0])\n",
" for j in adjacencyList[i]:\n",
" m[i][j] = 1\n",
" return m"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "69d494ab",
"metadata": {},
"outputs": [],
"source": [
"def showGraph(n, ranks, metricsName):\n",
" adjacencyList = nearestAdjacency(confusionMatrix(topNGrams(source, n, ranks), metrics[metricsName]))\n",
" g = graphviz.Digraph()\n",
" g.graph_attr['rankdir'] = 'LR'\n",
" dimension = len(adjacencyList)\n",
" for i in range(0, dimension):\n",
" g.node(data.domains[i])\n",
" for i in range(0, dimension):\n",
" for j in adjacencyList[i]:\n",
" g.edge(data.domains[i], data.domains[j])\n",
" return Image(filename=g.render(\n",
" preparePath(f'../graph/{source.hash}/{n}grams_top{ranks}_{metricsName}.gv'),\n",
" format='png')\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "3d0f3709",
"metadata": {},
"outputs": [],
"source": [
"for n in range(1, 4):\n",
" for ranks in [10, 50, 100]:\n",
" for name in metrics:\n",
" showGraph(n, ranks, name)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "/gnu/store/2rpsj69fzmcnafz4rml0blrynfayxqzr-python-wrapper-3.9.9/bin/python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.9"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
%% Cell type:code id:fc7a6e69 tags:
```
/gnu/store/2rpsj69fzmcnafz4rml0blrynfayxqzr-python-wrapper-3.9.9/bin/python
from EDdA import data
from EDdA.store import preparePath
from EDdA.classification import confusionMatrix, metrics, toPNG, topNGrams
from IPython.display import Image
import graphviz
import os
```
%% Cell type:code id:f49c39b5 tags:
```
/gnu/store/2rpsj69fzmcnafz4rml0blrynfayxqzr-python-wrapper-3.9.9/bin/python
source = data.load('training_set')
```
%% Cell type:code id:3a37bfa1 tags:
```
/gnu/store/2rpsj69fzmcnafz4rml0blrynfayxqzr-python-wrapper-3.9.9/bin/python
def nearestAdjacency(matrix):
m = []
dimension = len(matrix)
for i in range(0, dimension):
link = max([matrix[i][j] for j in range(0, dimension) if j != i])
if link == 0:
m.append([])
else:
m.append([j for j in range(0, dimension) if j != i and matrix[i][j] == link])
return m
```
%% Cell type:code id:b9c92861 tags:
```
/gnu/store/2rpsj69fzmcnafz4rml0blrynfayxqzr-python-wrapper-3.9.9/bin/python
def listToMatrix(adjacencyList):
m = []
dimension = len(adjacencyList)
for i in range(0, dimension):
m.append(dimension * [0])
for j in adjacencyList[i]:
m[i][j] = 1
return m
```
%% Cell type:code id:69d494ab tags:
```
/gnu/store/2rpsj69fzmcnafz4rml0blrynfayxqzr-python-wrapper-3.9.9/bin/python
def showGraph(n, ranks, metricsName):
adjacencyList = nearestAdjacency(confusionMatrix(topNGrams(source, n, ranks), metrics[metricsName]))
g = graphviz.Digraph()
g.graph_attr['rankdir'] = 'LR'
dimension = len(adjacencyList)
for i in range(0, dimension):
g.node(data.domains[i])
for i in range(0, dimension):
for j in adjacencyList[i]:
g.edge(data.domains[i], data.domains[j])
return Image(filename=g.render(
preparePath(f'../graph/{source.hash}/{n}grams_top{ranks}_{metricsName}.gv'),
format='png')
)
```
%% Cell type:code id:3d0f3709 tags:
```
/gnu/store/2rpsj69fzmcnafz4rml0blrynfayxqzr-python-wrapper-3.9.9/bin/python
for n in range(1, 4):
for ranks in [10, 50, 100]:
for name in metrics:
showGraph(n, ranks, name)
```
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