{-# 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.EntityTypesEvaluationMetrics
-- 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.EntityTypesEvaluationMetrics 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 for a
-- specific entity type.
--
-- /See:/ 'newEntityTypesEvaluationMetrics' smart constructor.
data EntityTypesEvaluationMetrics = EntityTypesEvaluationMetrics'
  { -- | A measure of how complete the recognizer results are for a specific
    -- entity type in the test data. High recall means that the recognizer
    -- returned most of the relevant results.
    EntityTypesEvaluationMetrics -> Maybe Double
recall :: Prelude.Maybe Prelude.Double,
    -- | A measure of the usefulness of the recognizer results for a specific
    -- entity type in the test data. High precision means that the recognizer
    -- returned substantially more relevant results than irrelevant ones.
    EntityTypesEvaluationMetrics -> Maybe Double
precision :: Prelude.Maybe Prelude.Double,
    -- | A measure of how accurate the recognizer results are for a specific
    -- entity type in 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.
    EntityTypesEvaluationMetrics -> Maybe Double
f1Score :: Prelude.Maybe Prelude.Double
  }
  deriving (EntityTypesEvaluationMetrics
-> EntityTypesEvaluationMetrics -> Bool
(EntityTypesEvaluationMetrics
 -> EntityTypesEvaluationMetrics -> Bool)
-> (EntityTypesEvaluationMetrics
    -> EntityTypesEvaluationMetrics -> Bool)
-> Eq EntityTypesEvaluationMetrics
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EntityTypesEvaluationMetrics
-> EntityTypesEvaluationMetrics -> Bool
$c/= :: EntityTypesEvaluationMetrics
-> EntityTypesEvaluationMetrics -> Bool
== :: EntityTypesEvaluationMetrics
-> EntityTypesEvaluationMetrics -> Bool
$c== :: EntityTypesEvaluationMetrics
-> EntityTypesEvaluationMetrics -> Bool
Prelude.Eq, ReadPrec [EntityTypesEvaluationMetrics]
ReadPrec EntityTypesEvaluationMetrics
Int -> ReadS EntityTypesEvaluationMetrics
ReadS [EntityTypesEvaluationMetrics]
(Int -> ReadS EntityTypesEvaluationMetrics)
-> ReadS [EntityTypesEvaluationMetrics]
-> ReadPrec EntityTypesEvaluationMetrics
-> ReadPrec [EntityTypesEvaluationMetrics]
-> Read EntityTypesEvaluationMetrics
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EntityTypesEvaluationMetrics]
$creadListPrec :: ReadPrec [EntityTypesEvaluationMetrics]
readPrec :: ReadPrec EntityTypesEvaluationMetrics
$creadPrec :: ReadPrec EntityTypesEvaluationMetrics
readList :: ReadS [EntityTypesEvaluationMetrics]
$creadList :: ReadS [EntityTypesEvaluationMetrics]
readsPrec :: Int -> ReadS EntityTypesEvaluationMetrics
$creadsPrec :: Int -> ReadS EntityTypesEvaluationMetrics
Prelude.Read, Int -> EntityTypesEvaluationMetrics -> ShowS
[EntityTypesEvaluationMetrics] -> ShowS
EntityTypesEvaluationMetrics -> String
(Int -> EntityTypesEvaluationMetrics -> ShowS)
-> (EntityTypesEvaluationMetrics -> String)
-> ([EntityTypesEvaluationMetrics] -> ShowS)
-> Show EntityTypesEvaluationMetrics
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EntityTypesEvaluationMetrics] -> ShowS
$cshowList :: [EntityTypesEvaluationMetrics] -> ShowS
show :: EntityTypesEvaluationMetrics -> String
$cshow :: EntityTypesEvaluationMetrics -> String
showsPrec :: Int -> EntityTypesEvaluationMetrics -> ShowS
$cshowsPrec :: Int -> EntityTypesEvaluationMetrics -> ShowS
Prelude.Show, (forall x.
 EntityTypesEvaluationMetrics -> Rep EntityTypesEvaluationMetrics x)
-> (forall x.
    Rep EntityTypesEvaluationMetrics x -> EntityTypesEvaluationMetrics)
-> Generic EntityTypesEvaluationMetrics
forall x.
Rep EntityTypesEvaluationMetrics x -> EntityTypesEvaluationMetrics
forall x.
EntityTypesEvaluationMetrics -> Rep EntityTypesEvaluationMetrics x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep EntityTypesEvaluationMetrics x -> EntityTypesEvaluationMetrics
$cfrom :: forall x.
EntityTypesEvaluationMetrics -> Rep EntityTypesEvaluationMetrics x
Prelude.Generic)

-- |
-- Create a value of 'EntityTypesEvaluationMetrics' 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', 'entityTypesEvaluationMetrics_recall' - A measure of how complete the recognizer results are for a specific
-- entity type in the test data. High recall means that the recognizer
-- returned most of the relevant results.
--
-- 'precision', 'entityTypesEvaluationMetrics_precision' - A measure of the usefulness of the recognizer results for a specific
-- entity type in the test data. High precision means that the recognizer
-- returned substantially more relevant results than irrelevant ones.
--
-- 'f1Score', 'entityTypesEvaluationMetrics_f1Score' - A measure of how accurate the recognizer results are for a specific
-- entity type in 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.
newEntityTypesEvaluationMetrics ::
  EntityTypesEvaluationMetrics
newEntityTypesEvaluationMetrics :: EntityTypesEvaluationMetrics
newEntityTypesEvaluationMetrics =
  EntityTypesEvaluationMetrics' :: Maybe Double
-> Maybe Double -> Maybe Double -> EntityTypesEvaluationMetrics
EntityTypesEvaluationMetrics'
    { $sel:recall:EntityTypesEvaluationMetrics' :: Maybe Double
recall =
        Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:precision:EntityTypesEvaluationMetrics' :: Maybe Double
precision = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:f1Score:EntityTypesEvaluationMetrics' :: Maybe Double
f1Score = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

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

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

-- | A measure of how accurate the recognizer results are for a specific
-- entity type in 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.
entityTypesEvaluationMetrics_f1Score :: Lens.Lens' EntityTypesEvaluationMetrics (Prelude.Maybe Prelude.Double)
entityTypesEvaluationMetrics_f1Score :: (Maybe Double -> f (Maybe Double))
-> EntityTypesEvaluationMetrics -> f EntityTypesEvaluationMetrics
entityTypesEvaluationMetrics_f1Score = (EntityTypesEvaluationMetrics -> Maybe Double)
-> (EntityTypesEvaluationMetrics
    -> Maybe Double -> EntityTypesEvaluationMetrics)
-> Lens
     EntityTypesEvaluationMetrics
     EntityTypesEvaluationMetrics
     (Maybe Double)
     (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntityTypesEvaluationMetrics' {Maybe Double
f1Score :: Maybe Double
$sel:f1Score:EntityTypesEvaluationMetrics' :: EntityTypesEvaluationMetrics -> Maybe Double
f1Score} -> Maybe Double
f1Score) (\s :: EntityTypesEvaluationMetrics
s@EntityTypesEvaluationMetrics' {} Maybe Double
a -> EntityTypesEvaluationMetrics
s {$sel:f1Score:EntityTypesEvaluationMetrics' :: Maybe Double
f1Score = Maybe Double
a} :: EntityTypesEvaluationMetrics)

instance Core.FromJSON EntityTypesEvaluationMetrics where
  parseJSON :: Value -> Parser EntityTypesEvaluationMetrics
parseJSON =
    String
-> (Object -> Parser EntityTypesEvaluationMetrics)
-> Value
-> Parser EntityTypesEvaluationMetrics
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EntityTypesEvaluationMetrics"
      ( \Object
x ->
          Maybe Double
-> Maybe Double -> Maybe Double -> EntityTypesEvaluationMetrics
EntityTypesEvaluationMetrics'
            (Maybe Double
 -> Maybe Double -> Maybe Double -> EntityTypesEvaluationMetrics)
-> Parser (Maybe Double)
-> Parser
     (Maybe Double -> Maybe Double -> EntityTypesEvaluationMetrics)
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 -> EntityTypesEvaluationMetrics)
-> Parser (Maybe Double)
-> Parser (Maybe Double -> EntityTypesEvaluationMetrics)
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 -> EntityTypesEvaluationMetrics)
-> Parser (Maybe Double) -> Parser EntityTypesEvaluationMetrics
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
    EntityTypesEvaluationMetrics

instance Prelude.NFData EntityTypesEvaluationMetrics