{-# OPTIONS_GHC -fno-warn-orphans #-}
+{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
where
import Control.Monad.Reader (MonadReader)
-import Control.Monad.IO.Class (MonadIO, liftIO)
-import Gargantext.API.Settings
+-- TODO remvoe this deps
+import Gargantext.API.Admin.Settings
import Data.Map (Map)
import Data.Maybe (maybe)
import Gargantext.Core.Types.Main (ListType(..), listTypeId, fromListTypeId)
import qualified Data.IntMap as IntMap
import qualified Data.List as List
import qualified Data.Map as Map
-import qualified Data.SVM as SVM
+import qualified Data.SVM as SVM
import qualified Data.Vector as Vec
------------------------------------------------------------------------
type Score = Double
type Param = Double
-grid :: (MonadReader env m, MonadIO m, HasSettings env)
+grid :: (MonadReader env m, MonadBase IO m, HasSettings env)
=> Param -> Param -> Train -> [Tests] -> m (Maybe Model)
grid _ _ _ [] = panic "Gargantext.Text.List.Learn.grid : empty test data"
grid s e tr te = do
let
- grid' :: (MonadReader env m, MonadIO m, HasSettings env)
+ grid' :: (MonadReader env m, MonadBase IO m, HasSettings env)
=> Double -> Double
-> Train
-> [Tests]
-> m (Score, Model)
grid' x y tr' te' = do
- model'' <- liftIO $ trainList x y tr'
+ model'' <- liftBase $ trainList x y tr'
let
model' = ModelSVM model'' (Just x) (Just y)
$ map (\(k,vs) -> zip (repeat k) vs)
$ Map.toList t
- res' <- liftIO $ predictList m toGuess
+ res' <- liftBase $ predictList m toGuess
pure $ score'' $ score' $ List.zip res res'
score <- mapM (getScore model') te'