Commit 51df3b7d authored by Alexandre Delanoë's avatar Alexandre Delanoë

[OPTIM] Distri Similarity

parent 107b2fc6
...@@ -5,7 +5,7 @@ cabal-version: 1.12 ...@@ -5,7 +5,7 @@ cabal-version: 1.12
-- see: https://github.com/sol/hpack -- see: https://github.com/sol/hpack
name: gargantext name: gargantext
version: 0.0.6.9.8.1 version: 0.0.6.9.8.1
synopsis: Search, map, share synopsis: Search, map, share
description: Please see README.md description: Please see README.md
category: Data category: Data
......
...@@ -20,7 +20,7 @@ import Data.Swagger ...@@ -20,7 +20,7 @@ import Data.Swagger
import Data.Text (Text) import Data.Text (Text)
import GHC.Generics (Generic) import GHC.Generics (Generic)
import Gargantext.Core.Methods.Similarities.Accelerate.Conditional (measureConditional) import Gargantext.Core.Methods.Similarities.Accelerate.Conditional (measureConditional)
import Gargantext.Core.Methods.Similarities.Accelerate.Distributional (logDistributional) import Gargantext.Core.Methods.Similarities.Accelerate.Distributional (logDistributional2)
-- import Gargantext.Core.Text.Metrics.Count (coocOn) -- import Gargantext.Core.Text.Metrics.Count (coocOn)
-- import Gargantext.Core.Viz.Graph.Index -- import Gargantext.Core.Viz.Graph.Index
import Gargantext.Prelude (Ord, Eq, Int, Double, Show, map) import Gargantext.Prelude (Ord, Eq, Int, Double, Show, map)
...@@ -36,7 +36,7 @@ data Similarity = Conditional | Distributional ...@@ -36,7 +36,7 @@ data Similarity = Conditional | Distributional
measure :: Similarity -> Matrix Int -> Matrix Double measure :: Similarity -> Matrix Int -> Matrix Double
measure Conditional x = measureConditional x measure Conditional x = measureConditional x
measure Distributional x = logDistributional x measure Distributional x = logDistributional2 x
------------------------------------------------------------------------ ------------------------------------------------------------------------
withMetric :: GraphMetric -> Similarity withMetric :: GraphMetric -> Similarity
......
...@@ -92,5 +92,3 @@ conditional' m = ( run $ ie $ map fromIntegral $ use m ...@@ -92,5 +92,3 @@ conditional' m = ( run $ ie $ map fromIntegral $ use m
n :: Exp Double n :: Exp Double
n = P.fromIntegral r n = P.fromIntegral r
...@@ -137,8 +137,8 @@ import qualified Prelude ...@@ -137,8 +137,8 @@ import qualified Prelude
-- 8.333333333333333e-2, 4.6875e-2, 1.0, 0.25, -- 8.333333333333333e-2, 4.6875e-2, 1.0, 0.25,
-- 0.3333333333333333, 5.7692307692307696e-2, 1.0, 1.0] -- 0.3333333333333333, 5.7692307692307696e-2, 1.0, 1.0]
-- --
distributional :: Matrix Int -> Acc (Matrix Double) distributional :: Matrix Int -> Matrix Double
distributional m' = result distributional m' = run $ result
where where
m = map A.fromIntegral $ use m' m = map A.fromIntegral $ use m'
n = dim m' n = dim m'
...@@ -170,7 +170,7 @@ distributional m' = result ...@@ -170,7 +170,7 @@ distributional m' = result
logDistributional2 :: Matrix Int -> Matrix Double logDistributional2 :: Matrix Int -> Matrix Double
logDistributional2 m = trace ("logDistributional, dim=" `mappend` show n) . run logDistributional2 m = trace ("logDistributional, dim=" `mappend` show n) . run
$ diagNull n -- $ diagNull n
$ matMaxMini $ matMaxMini
$ logDistributional' n m $ logDistributional' n m
where where
...@@ -263,7 +263,7 @@ logDistributional' n m' = trace ("logDistributional'") result ...@@ -263,7 +263,7 @@ logDistributional' n m' = trace ("logDistributional'") result
-- --
logDistributional :: Matrix Int -> Matrix Double logDistributional :: Matrix Int -> Matrix Double
logDistributional m' = run $ diagNull n result logDistributional m' = run result
where where
m = map fromIntegral $ use m' m = map fromIntegral $ use m'
n = dim m' n = dim m'
...@@ -362,9 +362,12 @@ rIJ n m = matMaxMini $ divide a b ...@@ -362,9 +362,12 @@ rIJ n m = matMaxMini $ divide a b
-- * For Tests (to be removed) -- * For Tests (to be removed)
-- | Test perfermance with this matrix -- | Test perfermance with this matrix
-- TODO : add this in a benchmark folder -- TODO : add this in a benchmark folder
distriTest :: Int -> Matrix Double {-
distriTest n = logDistributional (theMatrixInt n) distriTest :: Int -> Bool
distriTest n = logDistributional m == distributional m
where
m = theMatrixInt n
-}
-- * sparse utils -- * sparse utils
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment