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
150
Issues
150
List
Board
Labels
Milestones
Merge Requests
5
Merge Requests
5
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
8255d8e6
Commit
8255d8e6
authored
Jun 09, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[STAT] map list creation adding kmeans to splitBy inclusion score.
parent
bfe7d274
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
7 deletions
+9
-7
package.yaml
package.yaml
+1
-0
Metrics.hs
src/Gargantext/Text/Metrics.hs
+6
-7
stack.yaml
stack.yaml
+2
-0
No files found.
package.yaml
View file @
8255d8e6
...
...
@@ -68,6 +68,7 @@ library:
-
hlcm
-
ini
-
jose-jwt
-
kmeans-vector
-
lens
-
logging-effect
-
matrix
...
...
src/Gargantext/Text/Metrics.hs
View file @
8255d8e6
...
...
@@ -24,15 +24,17 @@ module Gargantext.Text.Metrics
import
Data.Text
(
Text
,
pack
)
import
Data.Map
(
Map
)
import
qualified
Data.List
as
L
import
qualified
Data.Map
as
M
import
qualified
Data.Set
as
S
import
qualified
Data.Text
as
T
import
qualified
Data.Vector
as
V
import
qualified
Data.Vector.Unboxed
as
VU
import
Data.Tuple.Extra
(
both
)
--import GHC.Real (Ratio)
--import qualified Data.Text.Metrics as DTM
import
Data.Array.Accelerate
(
toList
)
import
Math.KMeans
(
kmeans
,
euclidSq
,
elements
)
import
Gargantext.Prelude
...
...
@@ -64,14 +66,11 @@ type BinSize = Double
takeSome
::
Ord
t
=>
ListSize
->
BinSize
->
[
Scored
t
]
->
[
Scored
t
]
takeSome
l
s
scores
=
L
.
take
l
$
takeSample
n
m
$
takeKmeans
l'
$
L
.
reverse
$
L
.
sortOn
_scored_incExc
scores
$
takeKmeans
2
scores
where
-- TODO : KMEAN split into 2 main clusters
-- (advice: use accelerate-example kmeans version
-- and maybe benchmark it to be sure)
takeKmeans
=
L
.
take
l'
=
4000
-- (TODO: benchmark with accelerate-example kmeans version)
takeKmeans
x
xs
=
elements
$
V
.
head
$
kmeans
(
\
i
->
VU
.
fromList
([(
_scored_incExc
i
::
Double
)]))
euclidSq
x
xs
n
=
round
((
fromIntegral
l
)
/
s
)
m
=
round
$
(
fromIntegral
$
length
scores
)
/
(
s
)
takeSample
n
m
xs
=
L
.
concat
$
map
(
L
.
take
n
)
...
...
stack.yaml
View file @
8255d8e6
...
...
@@ -23,6 +23,8 @@ extra-deps:
-
fullstop-0.1.4
-
haskell-src-exts-1.18.2
-
http-types-0.12.1
-
kmeans-vector-0.3.2
-
probable-0.1.3
-
protolude-0.2
-
servant-0.13
-
servant-auth-0.3.0.1
...
...
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