]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Core/Statistics.hs
[FEAT] search in Trash
[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 {-# LANGUAGE NoImplicitPrelude #-}
13
14 module Gargantext.Core.Statistics
15 where
16
17
18 import Data.Map (Map)
19 import Gargantext.Prelude
20 import Numeric.Statistics.PCA (pcaReduceN)
21 import Data.Array.IArray (Array, listArray, elems)
22 import qualified Data.Vector.Storable as Vec
23 import qualified Data.List as List
24 import qualified Data.Map as Map
25
26
27 data Dimension = Dimension Int
28
29 pcaReduceTo :: Ord t
30 => Dimension
31 -> Map t (Vec.Vector Double)
32 -> Map t (Vec.Vector Double)
33 pcaReduceTo (Dimension d) m = Map.fromList
34 $ zip txts
35 $ elems
36 $ pcaReduceN m'' d
37 where
38 m'' :: Array Int (Vec.Vector Double)
39 m'' = listArray (1, List.length m') m'
40
41 (txts,m') = List.unzip $ Map.toList m
42
43