Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
147
Issues
147
List
Board
Labels
Milestones
Merge Requests
9
Merge Requests
9
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
2efbab70
Commit
2efbab70
authored
Jun 07, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
need fix
parent
7ec4291b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
5 deletions
+25
-5
Matrice.hs
src/Gargantext/Viz/Graph/Distances/Matrice.hs
+25
-5
No files found.
src/Gargantext/Viz/Graph/Distances/Matrice.hs
View file @
2efbab70
...
...
@@ -68,8 +68,6 @@ rank :: (Matrix a) -> Int
rank
m
=
arrayRank
$
arrayShape
m
-----------------------------------------------------------------------
-- | Conditional Distance
-- | Dimension of a square Matrix
-- How to force use with SquareMatrix ?
type
Dim
=
Int
...
...
@@ -89,12 +87,34 @@ mkSum r mat = replicate (constant (Z :. (r :: Int) :. All)) $ sum mat
-- divByDiag
divByDiag
::
Dim
->
Acc
(
Matrix
Double
)
->
Acc
(
Matrix
Double
)
divByDiag
d
mat
=
zipWith
(
/
)
mat
(
replicate
(
constant
(
Z
:.
(
d
::
Int
)
:.
All
))
$
diag
mat
)
where
diag
::
Elt
e
=>
Acc
(
Matrix
e
)
->
Acc
(
Vector
e
)
diag
m
=
backpermute
(
indexTail
(
shape
m
))
(
lift1
(
\
(
Z
:.
x
)
->
(
Z
:.
x
:.
(
x
::
Exp
Int
))))
m
diag
::
Elt
e
=>
Acc
(
Matrix
e
)
->
Acc
(
Vector
e
)
diag
m
=
backpermute
(
indexTail
(
shape
m
))
(
lift1
(
\
(
Z
:.
x
)
->
(
Z
:.
x
:.
(
x
::
Exp
Int
))))
m
-- | Conditional Distance
{-
Metric Specificity and genericity: select terms
N termes
Ni : occ de i
Nij : cooc i et j
P(i|j)=Nij/Nj Probability to get i given j
Gen(i) : 1/(N-1)*Sum(j!=i, P(i|j)) : Genericity of i
Spec(i) : 1/(N-1)*Sum( j!=i, P(j|i)) : Specificity of j
Inclusion (i) = Gen(i)+Spec(i)
Genericity score = Gen(i)- Spec(i)
----
Compute genericity/specificity:
P(j|i) = N(ij) / N(ii)
P(i|j) = N(ij) / N(jj)
...
...
@@ -121,7 +141,7 @@ p_ij m = zipWith (/) m (n_jj m)
n_jj
::
Elt
e
=>
Acc
(
SymetricMatrix
e
)
->
Acc
(
Matrix
e
)
n_jj
m
=
backpermute
(
shape
m
)
(
lift1
(
\
(
Z
:.
(
i
::
Exp
Int
)
:.
(
j
::
Exp
Int
))
->
(
Z
:.
j
:.
j
)
->
ifThenElse
(
i
<
j
)
(
Z
:.
j
:.
j
)
(
Z
:.
i
:.
i
)
)
)
m
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment