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
e454b205
Commit
e454b205
authored
Jan 14, 2021
by
qlobbe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change beta to lambda [0...1]
parent
3e4bd243
Pipeline
#1345
failed with stage
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
26 deletions
+27
-26
AdaptativePhylo.hs
src/Gargantext/Core/Viz/AdaptativePhylo.hs
+1
-1
PhyloExport.hs
src/Gargantext/Core/Viz/Phylo/PhyloExport.hs
+1
-1
TemporalMatching.hs
src/Gargantext/Core/Viz/Phylo/TemporalMatching.hs
+25
-24
No files found.
src/Gargantext/Core/Viz/AdaptativePhylo.hs
View file @
e454b205
...
...
@@ -147,7 +147,7 @@ defaultConfig =
,
seaElevation
=
Constante
0.1
0.1
,
findAncestors
=
True
,
phyloSynchrony
=
ByProximityThreshold
0.5
10
SiblingBranches
MergeAllGroups
,
phyloQuality
=
Quality
10
0
1
,
phyloQuality
=
Quality
0
1
,
timeUnit
=
Year
3
1
5
,
clique
=
MaxClique
0
,
exportLabel
=
[
BranchLabel
MostEmergentTfIdf
2
,
GroupLabel
MostEmergentInclusive
2
]
...
...
src/Gargantext/Core/Viz/Phylo/PhyloExport.hs
View file @
e454b205
...
...
@@ -673,7 +673,7 @@ tracePhyloAncestors :: [[PhyloGroup]] -> [[PhyloGroup]]
tracePhyloAncestors
groups
=
trace
(
"-- | Found "
<>
show
(
length
$
concat
$
map
_phylo_groupAncestors
$
concat
groups
)
<>
" ancestors"
)
groups
tracePhyloInfo
::
Phylo
->
Phylo
tracePhyloInfo
phylo
=
trace
(
"
\n
"
<>
"##########################"
<>
"
\n\n
"
<>
"-- | Phylo with
β
= "
tracePhyloInfo
phylo
=
trace
(
"
\n
"
<>
"##########################"
<>
"
\n\n
"
<>
"-- | Phylo with
λ
= "
<>
show
(
_qua_granularity
$
phyloQuality
$
getConfig
phylo
)
<>
" applied to "
<>
show
(
length
$
Vector
.
toList
$
getRoots
phylo
)
<>
" foundations"
)
phylo
...
...
src/Gargantext/Core/Viz/Phylo/TemporalMatching.hs
View file @
e454b205
...
...
@@ -18,7 +18,7 @@ import Gargantext.Prelude
import
Gargantext.Core.Viz.AdaptativePhylo
import
Gargantext.Core.Viz.Phylo.PhyloTools
import
Prelude
(
floor
)
import
Prelude
(
floor
,
tan
,
pi
)
import
Control.Lens
hiding
(
Level
)
import
Control.Parallel.Strategies
(
parList
,
rdeepseq
,
using
)
import
Debug.Trace
(
trace
)
...
...
@@ -272,11 +272,11 @@ recall x bk bx = ((fromIntegral $ length $ filter (\g -> elem x $ g ^. phylo_gro
/
(
fromIntegral
$
length
$
filter
(
\
g
->
elem
x
$
g
^.
phylo_groupNgrams
)
$
concat
bx
))
fScore
::
Double
->
Int
->
[(
Date
,
Date
)]
->
[
PhyloGroup
]
->
[[
PhyloGroup
]]
->
Double
fScore
bet
a
x
periods
bk
bx
=
fScore
lambd
a
x
periods
bk
bx
=
let
rec
=
recall
x
bk
bx
acc
=
accuracy
x
periods
bk
in
((
1
+
bet
a
**
2
)
*
acc
*
rec
)
/
(((
bet
a
**
2
)
*
rec
+
acc
))
in
((
1
+
lambd
a
**
2
)
*
acc
*
rec
)
/
(((
lambd
a
**
2
)
*
rec
+
acc
))
wk
::
[
PhyloGroup
]
->
Double
...
...
@@ -284,14 +284,14 @@ wk bk = fromIntegral $ length bk
toPhyloQuality'
::
Double
->
Map
Int
Double
->
[[
PhyloGroup
]]
->
Double
toPhyloQuality'
bet
a
freq
branches
=
toPhyloQuality'
lambd
a
freq
branches
=
if
(
null
branches
)
then
0
else
sum
$
map
(
\
i
->
let
bks
=
relevantBranches
i
branches
periods
=
nub
$
map
_phylo_groupPeriod
$
filter
(
\
g
->
elem
i
$
g
^.
phylo_groupNgrams
)
$
concat
bks
in
(
freq
!
i
)
*
(
sum
$
map
(
\
bk
->
((
wk
bk
)
/
(
sum
$
map
wk
bks
))
*
(
fScore
bet
a
i
periods
bk
bks
))
bks
))
in
(
freq
!
i
)
*
(
sum
$
map
(
\
bk
->
((
wk
bk
)
/
(
sum
$
map
wk
bks
))
*
(
fScore
lambd
a
i
periods
bk
bks
))
bks
))
$
keys
freq
toRecall
::
Map
Int
Double
->
[[
PhyloGroup
]]
->
Double
...
...
@@ -330,7 +330,7 @@ toAccuracy freq branches =
-- | here we do the average of all the local f_scores
toPhyloQuality
::
Double
->
Double
->
Map
Int
Double
->
[[
PhyloGroup
]]
->
Double
toPhyloQuality
fdt
bet
a
freq
branches
=
toPhyloQuality
fdt
lambd
a
freq
branches
=
if
(
null
branches
)
then
0
else
sum
...
...
@@ -341,7 +341,8 @@ toPhyloQuality fdt beta freq branches =
periods
=
nub
$
map
_phylo_groupPeriod
$
filter
(
\
g
->
elem
x
$
g
^.
phylo_groupNgrams
)
$
concat
bx
wks
=
sum
$
map
wk
bx
-- in (px / pys) * (sum $ map (\bk -> ((wk bk) / wks) * (fScore beta x bk bx)) bx))
in
(
1
/
fdt
)
*
(
sum
$
map
(
\
bk
->
((
wk
bk
)
/
wks
)
*
(
fScore
beta
x
periods
bk
bx
))
bx
))
-- in (1 / fdt) * (sum $ map (\bk -> ((wk bk) / wks) * (fScore beta x periods bk bx)) bx))
in
(
1
/
fdt
)
*
(
sum
$
map
(
\
bk
->
((
wk
bk
)
/
wks
)
*
(
fScore
(
tan
(
lambda
*
pi
/
2
))
x
periods
bk
bx
))
bx
))
$
keys
freq
-- where
-- pys :: Double
...
...
@@ -390,7 +391,7 @@ updateThr thr branches = map (\b -> map (\g ->
-- rest = the branches we still have to break
breakBranches
::
Double
->
Proximity
->
Double
->
Map
Int
Double
->
Int
->
Double
->
Double
->
Double
->
Int
->
Map
Date
Double
->
Map
Date
Cooc
->
[
PhyloPeriodId
]
->
[([
PhyloGroup
],
Bool
)]
->
([
PhyloGroup
],
Bool
)
->
[([
PhyloGroup
],
Bool
)]
->
[([
PhyloGroup
],
Bool
)]
breakBranches
fdt
proximity
bet
a
frequency
minBranch
thr
depth
elevation
frame
docs
coocs
periods
done
ego
rest
=
breakBranches
fdt
proximity
lambd
a
frequency
minBranch
thr
depth
elevation
frame
docs
coocs
periods
done
ego
rest
=
-- 1) keep or not the new division of ego
let
done'
=
done
++
(
if
snd
ego
then
...
...
@@ -413,12 +414,12 @@ breakBranches fdt proximity beta frequency minBranch thr depth elevation frame d
-- 2) if there is no more branches in rest then return else continue
if
null
rest
then
done'
else
breakBranches
fdt
proximity
bet
a
frequency
minBranch
thr
depth
elevation
frame
docs
coocs
periods
else
breakBranches
fdt
proximity
lambd
a
frequency
minBranch
thr
depth
elevation
frame
docs
coocs
periods
done'
(
head'
"breakBranches"
rest
)
(
tail'
"breakBranches"
rest
)
where
--------------------------------------
quality
::
Double
quality
=
toPhyloQuality
fdt
bet
a
frequency
((
map
fst
done
)
++
[
fst
ego
]
++
(
map
fst
rest
))
quality
=
toPhyloQuality
fdt
lambd
a
frequency
((
map
fst
done
)
++
[
fst
ego
]
++
(
map
fst
rest
))
--------------------------------------
ego'
::
([[
PhyloGroup
]],[[
PhyloGroup
]])
ego'
=
...
...
@@ -430,29 +431,29 @@ breakBranches fdt proximity beta frequency minBranch thr depth elevation frame d
$
depthToMeta
(
elevation
-
depth
)
branches'
--------------------------------------
quality'
::
Double
quality'
=
toPhyloQuality
fdt
bet
a
frequency
quality'
=
toPhyloQuality
fdt
lambd
a
frequency
((
map
fst
done
)
++
(
fst
ego'
)
++
(
snd
ego'
)
++
(
map
fst
rest
))
seaLevelMatching
::
Double
->
Proximity
->
Double
->
Int
->
Map
Int
Double
->
Double
->
Double
->
Double
->
Double
->
Int
->
[
PhyloPeriodId
]
->
Map
Date
Double
->
Map
Date
Cooc
->
[([
PhyloGroup
],
Bool
)]
->
[([
PhyloGroup
],
Bool
)]
seaLevelMatching
fdt
proximity
bet
a
minBranch
frequency
thr
step
depth
elevation
frame
periods
docs
coocs
branches
=
seaLevelMatching
fdt
proximity
lambd
a
minBranch
frequency
thr
step
depth
elevation
frame
periods
docs
coocs
branches
=
-- if there is no branch to break or if seaLvl level > 1 then end
if
(
thr
>=
1
)
||
((
not
.
or
)
$
map
snd
branches
)
then
branches
else
-- break all the possible branches at the current seaLvl level
let
quality
=
toPhyloQuality
fdt
bet
a
frequency
(
map
fst
branches
)
let
quality
=
toPhyloQuality
fdt
lambd
a
frequency
(
map
fst
branches
)
acc
=
toAccuracy
frequency
(
map
fst
branches
)
rec
=
toRecall
frequency
(
map
fst
branches
)
branches'
=
trace
(
"↑ level = "
<>
printf
"%.3f"
thr
<>
" F(
β
) = "
<>
printf
"%.5f"
quality
branches'
=
trace
(
"↑ level = "
<>
printf
"%.3f"
thr
<>
" F(
λ
) = "
<>
printf
"%.5f"
quality
<>
" ξ = "
<>
printf
"%.5f"
acc
<>
" ρ = "
<>
printf
"%.5f"
rec
<>
" branches = "
<>
show
(
length
branches
)
<>
" ↴"
)
$
breakBranches
fdt
proximity
bet
a
frequency
minBranch
thr
depth
elevation
frame
docs
coocs
periods
$
breakBranches
fdt
proximity
lambd
a
frequency
minBranch
thr
depth
elevation
frame
docs
coocs
periods
[]
(
head'
"seaLevelMatching"
branches
)
(
tail'
"seaLevelMatching"
branches
)
frequency'
=
reduceFrequency
frequency
(
map
fst
branches'
)
in
seaLevelMatching
fdt
proximity
bet
a
minBranch
frequency'
(
thr
+
step
)
step
(
depth
-
1
)
elevation
frame
periods
docs
coocs
branches'
in
seaLevelMatching
fdt
proximity
lambd
a
minBranch
frequency'
(
thr
+
step
)
step
(
depth
-
1
)
elevation
frame
periods
docs
coocs
branches'
constanteTemporalMatching
::
Double
->
Double
->
Phylo
->
Phylo
...
...
@@ -547,7 +548,7 @@ adaptativeBreakBranches :: Double -> Proximity -> Double -> Double -> Map (Phylo
->
Double
->
Map
Int
Double
->
Int
->
Int
->
Map
Date
Double
->
Map
Date
Cooc
->
[
PhyloPeriodId
]
->
[([
PhyloGroup
],(
Bool
,[
Double
]))]
->
([
PhyloGroup
],(
Bool
,[
Double
]))
->
[([
PhyloGroup
],(
Bool
,[
Double
]))]
->
[([
PhyloGroup
],(
Bool
,[
Double
]))]
adaptativeBreakBranches
fdt
proxiConf
depth
elevation
groupsProxi
bet
a
frequency
minBranch
frame
docs
coocs
periods
done
ego
rest
=
adaptativeBreakBranches
fdt
proxiConf
depth
elevation
groupsProxi
lambd
a
frequency
minBranch
frame
docs
coocs
periods
done
ego
rest
=
-- 1) keep or not the new division of ego
let
done'
=
done
++
(
if
(
fst
.
snd
)
ego
then
(
if
((
null
(
fst
ego'
))
||
(
quality
>
quality'
))
...
...
@@ -567,7 +568,7 @@ adaptativeBreakBranches fdt proxiConf depth elevation groupsProxi beta frequenc
-- 2) if there is no more branches in rest then return else continue
if
null
rest
then
done'
else
adaptativeBreakBranches
fdt
proxiConf
depth
elevation
groupsProxi
bet
a
frequency
minBranch
frame
docs
coocs
periods
else
adaptativeBreakBranches
fdt
proxiConf
depth
elevation
groupsProxi
lambd
a
frequency
minBranch
frame
docs
coocs
periods
done'
(
head'
"breakBranches"
rest
)
(
tail'
"breakBranches"
rest
)
where
--------------------------------------
...
...
@@ -575,7 +576,7 @@ adaptativeBreakBranches fdt proxiConf depth elevation groupsProxi beta frequenc
thr
=
toThreshold
depth
$
Map
.
filter
(
\
v
->
v
>
(
last'
"breakBranches"
$
(
snd
.
snd
)
ego
))
$
reduceTupleMapByKeys
(
map
getGroupId
$
fst
ego
)
groupsProxi
--------------------------------------
quality
::
Double
quality
=
toPhyloQuality
fdt
bet
a
frequency
((
map
fst
done
)
++
[
fst
ego
]
++
(
map
fst
rest
))
quality
=
toPhyloQuality
fdt
lambd
a
frequency
((
map
fst
done
)
++
[
fst
ego
]
++
(
map
fst
rest
))
--------------------------------------
ego'
::
([[
PhyloGroup
]],[[
PhyloGroup
]])
ego'
=
...
...
@@ -587,7 +588,7 @@ adaptativeBreakBranches fdt proxiConf depth elevation groupsProxi beta frequenc
$
depthToMeta
(
elevation
-
depth
)
branches'
--------------------------------------
quality'
::
Double
quality'
=
toPhyloQuality
fdt
bet
a
frequency
quality'
=
toPhyloQuality
fdt
lambd
a
frequency
((
map
fst
done
)
++
(
fst
ego'
)
++
(
snd
ego'
)
++
(
map
fst
rest
))
...
...
@@ -595,13 +596,13 @@ adaptativeSeaLevelMatching :: Double -> Proximity -> Double -> Double -> Map (Ph
->
Double
->
Int
->
Map
Int
Double
->
Int
->
[
PhyloPeriodId
]
->
Map
Date
Double
->
Map
Date
Cooc
->
[([
PhyloGroup
],(
Bool
,[
Double
]))]
->
[([
PhyloGroup
],(
Bool
,[
Double
]))]
adaptativeSeaLevelMatching
fdt
proxiConf
depth
elevation
groupsProxi
bet
a
minBranch
frequency
frame
periods
docs
coocs
branches
=
adaptativeSeaLevelMatching
fdt
proxiConf
depth
elevation
groupsProxi
lambd
a
minBranch
frequency
frame
periods
docs
coocs
branches
=
-- if there is no branch to break or if seaLvl level >= depth then end
if
(
Map
.
null
groupsProxi
)
||
(
depth
<=
0
)
||
((
not
.
or
)
$
map
(
fst
.
snd
)
branches
)
then
branches
else
-- break all the possible branches at the current seaLvl level
let
branches'
=
adaptativeBreakBranches
fdt
proxiConf
depth
elevation
groupsProxi
bet
a
frequency
minBranch
frame
docs
coocs
periods
let
branches'
=
adaptativeBreakBranches
fdt
proxiConf
depth
elevation
groupsProxi
lambd
a
frequency
minBranch
frame
docs
coocs
periods
[]
(
head'
"seaLevelMatching"
branches
)
(
tail'
"seaLevelMatching"
branches
)
frequency'
=
reduceFrequency
frequency
(
map
fst
branches'
)
groupsProxi'
=
reduceTupleMapByKeys
(
map
(
getGroupId
)
$
concat
$
map
(
fst
)
$
filter
(
fst
.
snd
)
branches'
)
groupsProxi
...
...
@@ -610,7 +611,7 @@ adaptativeSeaLevelMatching fdt proxiConf depth elevation groupsProxi beta minBra
<>
" [✓ "
<>
show
(
length
$
filter
(
fst
.
snd
)
branches'
)
<>
"("
<>
show
(
length
$
concat
$
map
(
fst
)
$
filter
(
fst
.
snd
)
branches'
)
<>
")|✗ "
<>
show
(
length
$
filter
(
not
.
fst
.
snd
)
branches'
)
<>
"("
<>
show
(
length
$
concat
$
map
(
fst
)
$
filter
(
not
.
fst
.
snd
)
branches'
)
<>
")]"
<>
" thr = "
)
$
adaptativeSeaLevelMatching
fdt
proxiConf
(
depth
-
1
)
elevation
groupsProxi'
bet
a
minBranch
frequency'
frame
periods
docs
coocs
branches'
$
adaptativeSeaLevelMatching
fdt
proxiConf
(
depth
-
1
)
elevation
groupsProxi'
lambd
a
minBranch
frequency'
frame
periods
docs
coocs
branches'
adaptativeTemporalMatching
::
Double
->
Phylo
->
Phylo
...
...
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