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
158
Issues
158
List
Board
Labels
Milestones
Merge Requests
11
Merge Requests
11
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
1c65bec6
Commit
1c65bec6
authored
Nov 05, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] Distributional, work with David
parent
f455b5b4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
67 deletions
+33
-67
Distributional.hs
...ntext/Core/Methods/Distances/Accelerate/Distributional.hs
+15
-39
Utils.hs
src/Gargantext/Core/Methods/Matrix/Accelerate/Utils.hs
+14
-25
API.hs
src/Gargantext/Core/Viz/Graph/API.hs
+4
-3
No files found.
src/Gargantext/Core/Methods/Distances/Accelerate/Distributional.hs
View file @
1c65bec6
...
...
@@ -49,56 +49,32 @@ import Data.Array.Accelerate
import
Data.Array.Accelerate.Interpreter
(
run
)
import
Gargantext.Core.Methods.Matrix.Accelerate.Utils
import
qualified
Gargantext.Prelude
as
P
-- import Data.Array.Accelerate.LinearAlgebra (identity) TODO
-----------------------------------------------------------------------
-- * Distributional Distance
distributional''
::
(
P
.
Num
(
Exp
a
)
,
P
.
Fractional
(
Exp
a
)
,
P
.
Ord
(
Exp
a
)
,
Ord
a
)
=>
Matrix
a
->
Matrix
a
distributional''
m'
=
run
mi_d_mi
distributional
::
Matrix
Int
->
Matrix
Double
distributional
m'
=
run
z
where
m
=
use
m'
m
=
map
fromIntegral
$
use
m'
n
=
dim
m'
d_m
=
(
.*
)
(
matrixIdentity
n
)
m
o_d_m
=
(
#*#
)
(
matrixOne
n
)
d_m
d_m_o
=
(
#*#
)
d_m
(
matrixOne
n
)
mi
=
(
.*
)
((
./
)
m
o_d_m
)
((
./
)
m
d_m_o
)
d_mi
=
(
.*
)
(
matrixIdentity
n
)
mi
mi_d_mi
=
(
.-
)
mi
d_mi
-- WIP (specs describe iteration on vectors, using full matrix version here)
d_mi_d_mi
=
(
.*
)
(
matrixIdentity
n
)
mi_d_mi
min_mi_mj
=
zipWith
min
d_mi_d_mi
d_mj_d_mj
where
-- not sure about transpose here
-- maybe backpermute j to i cells ?
d_mj_d_mj
=
transpose
d_mi_d_mi
sum_min_mi_mj
=
matSumCol
n
min_mi_mj
sum_mi
=
matSumCol
n
d_mi_d_mi
result
=
zipWith
(
/
)
sum_min_mi_mj
sum_mi
d_m_o
=
transpose
o_d_m
mi
=
(
.*
)
((
./
)
m
o_d_m
)
((
./
)
m
d_m_o
)
d_mi
=
(
.*
)
(
matrixIdentity
n
)
mi
w
=
(
.-
)
mi
d_mi
z
=
(
#*#
)
w
(
matrixOne
n
)
z'
=
transpose
z
min_z_z'
=
zipWith
min
z
z'
result
=
(
./
)
min_z_z'
z
...
...
@@ -124,8 +100,8 @@ distributional'' m' = run mi_d_mi
-- \[N_{m} = \sum_{i,i \neq i}^{m} \sum_{j, j \neq j}^{m} S_{ij}\]
--
distributional
::
Matrix
Int
->
Matrix
Double
distributional
m
=
-- run {- $ matMiniMax -}
distributional
''
::
Matrix
Int
->
Matrix
Double
distributional
''
m
=
-- run {- $ matMiniMax -}
run
$
diagNull
n
$
rIJ
n
$
filterWith
0
100
...
...
src/Gargantext/Core/Methods/Matrix/Accelerate/Utils.hs
View file @
1c65bec6
...
...
@@ -33,8 +33,6 @@ module Gargantext.Core.Methods.Matrix.Accelerate.Utils
import
qualified
Data.Foldable
as
P
(
foldl1
)
import
Debug.Trace
(
trace
)
import
Data.Array.Accelerate
import
Data.Array.Accelerate.Array.Sugar
(
Elt
(
..
),
Shape
(
..
),
Slice
(
..
),
(
:.
))
import
Data.Array.Accelerate.Smart
(
Exp
(
..
))
import
Data.Array.Accelerate.Interpreter
(
run
)
import
qualified
Gargantext.Prelude
as
P
import
Data.Array.Accelerate.LinearAlgebra
hiding
(
Matrix
,
transpose
,
Vector
)
...
...
@@ -43,13 +41,13 @@ import Data.Array.Accelerate.LinearAlgebra hiding (Matrix, transpose, Vector)
-- | Main operators
-- Matrix Multiplication
(
#*#
)
::
(
Shape
ix
,
Slice
ix
,
Elt
a
,
P
.
Num
(
Exp
a
)
)
=>
Acc
(
Array
((
ix
:.
Int
)
:.
Int
)
a
)
->
Acc
(
Array
((
ix
:.
Int
)
:.
Int
)
a
)
->
Acc
(
Array
((
ix
:.
Int
)
:.
Int
)
a
)
,
Slice
ix
,
Elt
a
,
P
.
Num
(
Exp
a
)
)
=>
Acc
(
Array
((
ix
:.
Int
)
:.
Int
)
a
)
->
Acc
(
Array
((
ix
:.
Int
)
:.
Int
)
a
)
->
Acc
(
Array
((
ix
:.
Int
)
:.
Int
)
a
)
(
#*#
)
=
multiplyMatrixMatrix
...
...
@@ -64,15 +62,6 @@ import Data.Array.Accelerate.LinearAlgebra hiding (Matrix, transpose, Vector)
->
Acc
(
Array
((
ix
:.
Int
)
:.
Int
)
a
)
(
.*
)
=
zipWith
(
*
)
(
.**
)
::
(
Shape
ix
,
Slice
ix
,
Elt
a
,
P
.
Num
(
Exp
a
)
)
=>
Acc
(
Array
((
ix
:.
Int
)
:.
Int
)
a
)
->
Acc
(
Array
((
ix
:.
Int
)
:.
Int
)
a
)
(
.**
)
m
=
(
.*
)
m
m
(
./
)
::
(
Shape
ix
,
Slice
ix
...
...
@@ -406,14 +395,14 @@ theMatrixInt n = matrix n (dataMatrix n)
,
1
,
2
]
|
(
P
.==
)
x
3
=
[
1
,
1
,
2
,
1
,
2
,
3
,
2
,
3
,
4
|
(
P
.==
)
x
3
=
[
7
,
4
,
0
,
4
,
5
,
3
,
0
,
3
,
4
]
|
(
P
.==
)
x
4
=
[
1
,
1
,
2
,
3
,
1
,
2
,
3
,
4
,
2
,
3
,
4
,
5
,
3
,
4
,
5
,
6
|
(
P
.==
)
x
4
=
[
4
,
4
,
0
,
0
,
4
,
4
,
0
,
0
,
0
,
0
,
3
,
3
,
0
,
0
,
3
,
3
]
|
P
.
otherwise
=
P
.
undefined
...
...
src/Gargantext/Core/Viz/Graph/API.hs
View file @
1c65bec6
...
...
@@ -93,7 +93,8 @@ getGraph _uId nId = do
-- TODO Distance in Graph params
case
graph
of
Nothing
->
do
graph'
<-
computeGraph
cId
Conditional
NgramsTerms
repo
graph'
<-
computeGraph
cId
Distributional
NgramsTerms
repo
-- graph' <- computeGraph cId Conditional NgramsTerms repo
mt
<-
defaultGraphMetadata
cId
"Title"
repo
let
graph''
=
set
graph_metadata
(
Just
mt
)
graph'
let
hg
=
HyperdataGraphAPI
graph''
camera
...
...
@@ -206,7 +207,7 @@ graphRecompute u n logStatus = do
,
_scst_remaining
=
Just
1
,
_scst_events
=
Just
[]
}
_g
<-
trace
(
show
u
)
$
recomputeGraph
u
n
Conditional
_g
<-
trace
(
show
u
)
$
recomputeGraph
u
n
Distributional
--
Conditional
pure
JobLog
{
_scst_succeeded
=
Just
1
,
_scst_failed
=
Just
0
,
_scst_remaining
=
Just
0
...
...
@@ -241,7 +242,7 @@ graphVersions nId = do
,
gv_repo
=
v
}
recomputeVersions
::
UserId
->
NodeId
->
GargNoServer
Graph
recomputeVersions
uId
nId
=
recomputeGraph
uId
nId
Conditional
recomputeVersions
uId
nId
=
recomputeGraph
uId
nId
Distributional
--
Conditional
------------------------------------------------------------
graphClone
::
UserId
...
...
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