{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Comprehend.Types.EntityTypesEvaluationMetrics where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 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,
    -- | 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 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
  }
  deriving (EntityTypesEvaluationMetrics
-> EntityTypesEvaluationMetrics -> Bool
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]
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
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.
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:
--
-- '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.
--
-- '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.
--
-- '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.
newEntityTypesEvaluationMetrics ::
  EntityTypesEvaluationMetrics
newEntityTypesEvaluationMetrics :: EntityTypesEvaluationMetrics
newEntityTypesEvaluationMetrics =
  EntityTypesEvaluationMetrics'
    { $sel:f1Score:EntityTypesEvaluationMetrics' :: Maybe Double
f1Score =
        forall a. Maybe a
Prelude.Nothing,
      $sel:precision:EntityTypesEvaluationMetrics' :: Maybe Double
precision = forall a. Maybe a
Prelude.Nothing,
      $sel:recall:EntityTypesEvaluationMetrics' :: Maybe Double
recall = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' EntityTypesEvaluationMetrics (Maybe Double)
entityTypesEvaluationMetrics_f1Score = 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)

-- | 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 :: Lens' EntityTypesEvaluationMetrics (Maybe Double)
entityTypesEvaluationMetrics_precision = 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 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 :: Lens' EntityTypesEvaluationMetrics (Maybe Double)
entityTypesEvaluationMetrics_recall = 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)

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

instance
  Prelude.Hashable
    EntityTypesEvaluationMetrics
  where
  hashWithSalt :: Int -> EntityTypesEvaluationMetrics -> Int
hashWithSalt Int
_salt EntityTypesEvaluationMetrics' {Maybe Double
recall :: Maybe Double
precision :: Maybe Double
f1Score :: Maybe Double
$sel:recall:EntityTypesEvaluationMetrics' :: EntityTypesEvaluationMetrics -> Maybe Double
$sel:precision:EntityTypesEvaluationMetrics' :: EntityTypesEvaluationMetrics -> Maybe Double
$sel:f1Score:EntityTypesEvaluationMetrics' :: EntityTypesEvaluationMetrics -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
f1Score
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
precision
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
recall

instance Prelude.NFData EntityTypesEvaluationMetrics where
  rnf :: EntityTypesEvaluationMetrics -> ()
rnf EntityTypesEvaluationMetrics' {Maybe Double
recall :: Maybe Double
precision :: Maybe Double
f1Score :: Maybe Double
$sel:recall:EntityTypesEvaluationMetrics' :: EntityTypesEvaluationMetrics -> Maybe Double
$sel:precision:EntityTypesEvaluationMetrics' :: EntityTypesEvaluationMetrics -> Maybe Double
$sel:f1Score:EntityTypesEvaluationMetrics' :: EntityTypesEvaluationMetrics -> Maybe Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
f1Score
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
precision
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
recall