{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Comprehend.Types.EntityRecognizerEvaluationMetrics
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Comprehend.Types.EntityRecognizerEvaluationMetrics where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Detailed information about the accuracy of an entity recognizer.
--
-- /See:/ 'newEntityRecognizerEvaluationMetrics' smart constructor.
data EntityRecognizerEvaluationMetrics = EntityRecognizerEvaluationMetrics'
  { -- | A measure of how complete the recognizer results are for the test data.
    -- High recall means that the recognizer returned most of the relevant
    -- results.
    EntityRecognizerEvaluationMetrics -> Maybe Double
recall :: Prelude.Maybe Prelude.Double,
    -- | A measure of the usefulness of the recognizer results in the test data.
    -- High precision means that the recognizer returned substantially more
    -- relevant results than irrelevant ones.
    EntityRecognizerEvaluationMetrics -> Maybe Double
precision :: Prelude.Maybe Prelude.Double,
    -- | A measure of how accurate the recognizer results are for the test data.
    -- It is derived from the @Precision@ and @Recall@ values. The @F1Score@ is
    -- the harmonic average of the two scores. The highest score is 1, and the
    -- worst score is 0.
    EntityRecognizerEvaluationMetrics -> Maybe Double
f1Score :: Prelude.Maybe Prelude.Double
  }
  deriving (EntityRecognizerEvaluationMetrics
-> EntityRecognizerEvaluationMetrics -> Bool
(EntityRecognizerEvaluationMetrics
 -> EntityRecognizerEvaluationMetrics -> Bool)
-> (EntityRecognizerEvaluationMetrics
    -> EntityRecognizerEvaluationMetrics -> Bool)
-> Eq EntityRecognizerEvaluationMetrics
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EntityRecognizerEvaluationMetrics
-> EntityRecognizerEvaluationMetrics -> Bool
$c/= :: EntityRecognizerEvaluationMetrics
-> EntityRecognizerEvaluationMetrics -> Bool
== :: EntityRecognizerEvaluationMetrics
-> EntityRecognizerEvaluationMetrics -> Bool
$c== :: EntityRecognizerEvaluationMetrics
-> EntityRecognizerEvaluationMetrics -> Bool
Prelude.Eq, ReadPrec [EntityRecognizerEvaluationMetrics]
ReadPrec EntityRecognizerEvaluationMetrics
Int -> ReadS EntityRecognizerEvaluationMetrics
ReadS [EntityRecognizerEvaluationMetrics]
(Int -> ReadS EntityRecognizerEvaluationMetrics)
-> ReadS [EntityRecognizerEvaluationMetrics]
-> ReadPrec EntityRecognizerEvaluationMetrics
-> ReadPrec [EntityRecognizerEvaluationMetrics]
-> Read EntityRecognizerEvaluationMetrics
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EntityRecognizerEvaluationMetrics]
$creadListPrec :: ReadPrec [EntityRecognizerEvaluationMetrics]
readPrec :: ReadPrec EntityRecognizerEvaluationMetrics
$creadPrec :: ReadPrec EntityRecognizerEvaluationMetrics
readList :: ReadS [EntityRecognizerEvaluationMetrics]
$creadList :: ReadS [EntityRecognizerEvaluationMetrics]
readsPrec :: Int -> ReadS EntityRecognizerEvaluationMetrics
$creadsPrec :: Int -> ReadS EntityRecognizerEvaluationMetrics
Prelude.Read, Int -> EntityRecognizerEvaluationMetrics -> ShowS
[EntityRecognizerEvaluationMetrics] -> ShowS
EntityRecognizerEvaluationMetrics -> String
(Int -> EntityRecognizerEvaluationMetrics -> ShowS)
-> (EntityRecognizerEvaluationMetrics -> String)
-> ([EntityRecognizerEvaluationMetrics] -> ShowS)
-> Show EntityRecognizerEvaluationMetrics
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EntityRecognizerEvaluationMetrics] -> ShowS
$cshowList :: [EntityRecognizerEvaluationMetrics] -> ShowS
show :: EntityRecognizerEvaluationMetrics -> String
$cshow :: EntityRecognizerEvaluationMetrics -> String
showsPrec :: Int -> EntityRecognizerEvaluationMetrics -> ShowS
$cshowsPrec :: Int -> EntityRecognizerEvaluationMetrics -> ShowS
Prelude.Show, (forall x.
 EntityRecognizerEvaluationMetrics
 -> Rep EntityRecognizerEvaluationMetrics x)
-> (forall x.
    Rep EntityRecognizerEvaluationMetrics x
    -> EntityRecognizerEvaluationMetrics)
-> Generic EntityRecognizerEvaluationMetrics
forall x.
Rep EntityRecognizerEvaluationMetrics x
-> EntityRecognizerEvaluationMetrics
forall x.
EntityRecognizerEvaluationMetrics
-> Rep EntityRecognizerEvaluationMetrics x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep EntityRecognizerEvaluationMetrics x
-> EntityRecognizerEvaluationMetrics
$cfrom :: forall x.
EntityRecognizerEvaluationMetrics
-> Rep EntityRecognizerEvaluationMetrics x
Prelude.Generic)

-- |
-- Create a value of 'EntityRecognizerEvaluationMetrics' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'recall', 'entityRecognizerEvaluationMetrics_recall' - A measure of how complete the recognizer results are for the test data.
-- High recall means that the recognizer returned most of the relevant
-- results.
--
-- 'precision', 'entityRecognizerEvaluationMetrics_precision' - A measure of the usefulness of the recognizer results in the test data.
-- High precision means that the recognizer returned substantially more
-- relevant results than irrelevant ones.
--
-- 'f1Score', 'entityRecognizerEvaluationMetrics_f1Score' - A measure of how accurate the recognizer results are for the test data.
-- It is derived from the @Precision@ and @Recall@ values. The @F1Score@ is
-- the harmonic average of the two scores. The highest score is 1, and the
-- worst score is 0.
newEntityRecognizerEvaluationMetrics ::
  EntityRecognizerEvaluationMetrics
newEntityRecognizerEvaluationMetrics :: EntityRecognizerEvaluationMetrics
newEntityRecognizerEvaluationMetrics =
  EntityRecognizerEvaluationMetrics' :: Maybe Double
-> Maybe Double
-> Maybe Double
-> EntityRecognizerEvaluationMetrics
EntityRecognizerEvaluationMetrics'
    { $sel:recall:EntityRecognizerEvaluationMetrics' :: Maybe Double
recall =
        Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:precision:EntityRecognizerEvaluationMetrics' :: Maybe Double
precision = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:f1Score:EntityRecognizerEvaluationMetrics' :: Maybe Double
f1Score = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | A measure of how complete the recognizer results are for the test data.
-- High recall means that the recognizer returned most of the relevant
-- results.
entityRecognizerEvaluationMetrics_recall :: Lens.Lens' EntityRecognizerEvaluationMetrics (Prelude.Maybe Prelude.Double)
entityRecognizerEvaluationMetrics_recall :: (Maybe Double -> f (Maybe Double))
-> EntityRecognizerEvaluationMetrics
-> f EntityRecognizerEvaluationMetrics
entityRecognizerEvaluationMetrics_recall = (EntityRecognizerEvaluationMetrics -> Maybe Double)
-> (EntityRecognizerEvaluationMetrics
    -> Maybe Double -> EntityRecognizerEvaluationMetrics)
-> Lens
     EntityRecognizerEvaluationMetrics
     EntityRecognizerEvaluationMetrics
     (Maybe Double)
     (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntityRecognizerEvaluationMetrics' {Maybe Double
recall :: Maybe Double
$sel:recall:EntityRecognizerEvaluationMetrics' :: EntityRecognizerEvaluationMetrics -> Maybe Double
recall} -> Maybe Double
recall) (\s :: EntityRecognizerEvaluationMetrics
s@EntityRecognizerEvaluationMetrics' {} Maybe Double
a -> EntityRecognizerEvaluationMetrics
s {$sel:recall:EntityRecognizerEvaluationMetrics' :: Maybe Double
recall = Maybe Double
a} :: EntityRecognizerEvaluationMetrics)

-- | A measure of the usefulness of the recognizer results in the test data.
-- High precision means that the recognizer returned substantially more
-- relevant results than irrelevant ones.
entityRecognizerEvaluationMetrics_precision :: Lens.Lens' EntityRecognizerEvaluationMetrics (Prelude.Maybe Prelude.Double)
entityRecognizerEvaluationMetrics_precision :: (Maybe Double -> f (Maybe Double))
-> EntityRecognizerEvaluationMetrics
-> f EntityRecognizerEvaluationMetrics
entityRecognizerEvaluationMetrics_precision = (EntityRecognizerEvaluationMetrics -> Maybe Double)
-> (EntityRecognizerEvaluationMetrics
    -> Maybe Double -> EntityRecognizerEvaluationMetrics)
-> Lens
     EntityRecognizerEvaluationMetrics
     EntityRecognizerEvaluationMetrics
     (Maybe Double)
     (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntityRecognizerEvaluationMetrics' {Maybe Double
precision :: Maybe Double
$sel:precision:EntityRecognizerEvaluationMetrics' :: EntityRecognizerEvaluationMetrics -> Maybe Double
precision} -> Maybe Double
precision) (\s :: EntityRecognizerEvaluationMetrics
s@EntityRecognizerEvaluationMetrics' {} Maybe Double
a -> EntityRecognizerEvaluationMetrics
s {$sel:precision:EntityRecognizerEvaluationMetrics' :: Maybe Double
precision = Maybe Double
a} :: EntityRecognizerEvaluationMetrics)

-- | A measure of how accurate the recognizer results are for the test data.
-- It is derived from the @Precision@ and @Recall@ values. The @F1Score@ is
-- the harmonic average of the two scores. The highest score is 1, and the
-- worst score is 0.
entityRecognizerEvaluationMetrics_f1Score :: Lens.Lens' EntityRecognizerEvaluationMetrics (Prelude.Maybe Prelude.Double)
entityRecognizerEvaluationMetrics_f1Score :: (Maybe Double -> f (Maybe Double))
-> EntityRecognizerEvaluationMetrics
-> f EntityRecognizerEvaluationMetrics
entityRecognizerEvaluationMetrics_f1Score = (EntityRecognizerEvaluationMetrics -> Maybe Double)
-> (EntityRecognizerEvaluationMetrics
    -> Maybe Double -> EntityRecognizerEvaluationMetrics)
-> Lens
     EntityRecognizerEvaluationMetrics
     EntityRecognizerEvaluationMetrics
     (Maybe Double)
     (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntityRecognizerEvaluationMetrics' {Maybe Double
f1Score :: Maybe Double
$sel:f1Score:EntityRecognizerEvaluationMetrics' :: EntityRecognizerEvaluationMetrics -> Maybe Double
f1Score} -> Maybe Double
f1Score) (\s :: EntityRecognizerEvaluationMetrics
s@EntityRecognizerEvaluationMetrics' {} Maybe Double
a -> EntityRecognizerEvaluationMetrics
s {$sel:f1Score:EntityRecognizerEvaluationMetrics' :: Maybe Double
f1Score = Maybe Double
a} :: EntityRecognizerEvaluationMetrics)

instance
  Core.FromJSON
    EntityRecognizerEvaluationMetrics
  where
  parseJSON :: Value -> Parser EntityRecognizerEvaluationMetrics
parseJSON =
    String
-> (Object -> Parser EntityRecognizerEvaluationMetrics)
-> Value
-> Parser EntityRecognizerEvaluationMetrics
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EntityRecognizerEvaluationMetrics"
      ( \Object
x ->
          Maybe Double
-> Maybe Double
-> Maybe Double
-> EntityRecognizerEvaluationMetrics
EntityRecognizerEvaluationMetrics'
            (Maybe Double
 -> Maybe Double
 -> Maybe Double
 -> EntityRecognizerEvaluationMetrics)
-> Parser (Maybe Double)
-> Parser
     (Maybe Double -> Maybe Double -> EntityRecognizerEvaluationMetrics)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Recall")
            Parser
  (Maybe Double -> Maybe Double -> EntityRecognizerEvaluationMetrics)
-> Parser (Maybe Double)
-> Parser (Maybe Double -> EntityRecognizerEvaluationMetrics)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Precision")
            Parser (Maybe Double -> EntityRecognizerEvaluationMetrics)
-> Parser (Maybe Double)
-> Parser EntityRecognizerEvaluationMetrics
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"F1Score")
      )

instance
  Prelude.Hashable
    EntityRecognizerEvaluationMetrics

instance
  Prelude.NFData
    EntityRecognizerEvaluationMetrics