]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Core/Statistics.hs
Try the hotfix
[gargantext.git] / src / Gargantext / Core / Statistics.hs
1 {-|
2 Module : Gargantext.Core.Statistics
3 Description :
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10 -}
11
12
13 module Gargantext.Core.Statistics
14 where
15
16
17 import Data.Map.Strict (Map)
18 import Gargantext.Prelude
19 import Numeric.Statistics.PCA (pcaReduceN)
20 import Data.Array.IArray (Array, listArray, elems)
21 import qualified Data.Vector.Storable as Vec
22 import qualified Data.List as List
23 import qualified Data.Map.Strict as Map
24
25
26 data Dimension = Dimension Int
27
28 pcaReduceTo :: Ord t
29 => Dimension
30 -> Map t (Vec.Vector Double)
31 -> Map t (Vec.Vector Double)
32 pcaReduceTo (Dimension d) m = Map.fromList
33 $ zip txts
34 $ elems
35 $ pcaReduceN m'' d
36 where
37 m'' :: Array Int (Vec.Vector Double)
38 m'' = listArray (1, List.length m') m'
39
40 (txts,m') = List.unzip $ Map.toList m