{-# 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.FraudDetector.Types.MetricDataPoint
-- 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.FraudDetector.Types.MetricDataPoint 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

-- | Model performance metrics data points.
--
-- /See:/ 'newMetricDataPoint' smart constructor.
data MetricDataPoint = MetricDataPoint'
  { -- | The false positive rate. This is the percentage of total legitimate
    -- events that are incorrectly predicted as fraud.
    MetricDataPoint -> Maybe Double
fpr :: Prelude.Maybe Prelude.Double,
    -- | The percentage of fraud events correctly predicted as fraudulent as
    -- compared to all events predicted as fraudulent.
    MetricDataPoint -> Maybe Double
precision :: Prelude.Maybe Prelude.Double,
    -- | The model threshold that specifies an acceptable fraud capture rate. For
    -- example, a threshold of 500 means any model score 500 or above is
    -- labeled as fraud.
    MetricDataPoint -> Maybe Double
threshold :: Prelude.Maybe Prelude.Double,
    -- | The true positive rate. This is the percentage of total fraud the model
    -- detects. Also known as capture rate.
    MetricDataPoint -> Maybe Double
tpr :: Prelude.Maybe Prelude.Double
  }
  deriving (MetricDataPoint -> MetricDataPoint -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetricDataPoint -> MetricDataPoint -> Bool
$c/= :: MetricDataPoint -> MetricDataPoint -> Bool
== :: MetricDataPoint -> MetricDataPoint -> Bool
$c== :: MetricDataPoint -> MetricDataPoint -> Bool
Prelude.Eq, ReadPrec [MetricDataPoint]
ReadPrec MetricDataPoint
Int -> ReadS MetricDataPoint
ReadS [MetricDataPoint]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MetricDataPoint]
$creadListPrec :: ReadPrec [MetricDataPoint]
readPrec :: ReadPrec MetricDataPoint
$creadPrec :: ReadPrec MetricDataPoint
readList :: ReadS [MetricDataPoint]
$creadList :: ReadS [MetricDataPoint]
readsPrec :: Int -> ReadS MetricDataPoint
$creadsPrec :: Int -> ReadS MetricDataPoint
Prelude.Read, Int -> MetricDataPoint -> ShowS
[MetricDataPoint] -> ShowS
MetricDataPoint -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MetricDataPoint] -> ShowS
$cshowList :: [MetricDataPoint] -> ShowS
show :: MetricDataPoint -> String
$cshow :: MetricDataPoint -> String
showsPrec :: Int -> MetricDataPoint -> ShowS
$cshowsPrec :: Int -> MetricDataPoint -> ShowS
Prelude.Show, forall x. Rep MetricDataPoint x -> MetricDataPoint
forall x. MetricDataPoint -> Rep MetricDataPoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MetricDataPoint x -> MetricDataPoint
$cfrom :: forall x. MetricDataPoint -> Rep MetricDataPoint x
Prelude.Generic)

-- |
-- Create a value of 'MetricDataPoint' 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:
--
-- 'fpr', 'metricDataPoint_fpr' - The false positive rate. This is the percentage of total legitimate
-- events that are incorrectly predicted as fraud.
--
-- 'precision', 'metricDataPoint_precision' - The percentage of fraud events correctly predicted as fraudulent as
-- compared to all events predicted as fraudulent.
--
-- 'threshold', 'metricDataPoint_threshold' - The model threshold that specifies an acceptable fraud capture rate. For
-- example, a threshold of 500 means any model score 500 or above is
-- labeled as fraud.
--
-- 'tpr', 'metricDataPoint_tpr' - The true positive rate. This is the percentage of total fraud the model
-- detects. Also known as capture rate.
newMetricDataPoint ::
  MetricDataPoint
newMetricDataPoint :: MetricDataPoint
newMetricDataPoint =
  MetricDataPoint'
    { $sel:fpr:MetricDataPoint' :: Maybe Double
fpr = forall a. Maybe a
Prelude.Nothing,
      $sel:precision:MetricDataPoint' :: Maybe Double
precision = forall a. Maybe a
Prelude.Nothing,
      $sel:threshold:MetricDataPoint' :: Maybe Double
threshold = forall a. Maybe a
Prelude.Nothing,
      $sel:tpr:MetricDataPoint' :: Maybe Double
tpr = forall a. Maybe a
Prelude.Nothing
    }

-- | The false positive rate. This is the percentage of total legitimate
-- events that are incorrectly predicted as fraud.
metricDataPoint_fpr :: Lens.Lens' MetricDataPoint (Prelude.Maybe Prelude.Double)
metricDataPoint_fpr :: Lens' MetricDataPoint (Maybe Double)
metricDataPoint_fpr = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDataPoint' {Maybe Double
fpr :: Maybe Double
$sel:fpr:MetricDataPoint' :: MetricDataPoint -> Maybe Double
fpr} -> Maybe Double
fpr) (\s :: MetricDataPoint
s@MetricDataPoint' {} Maybe Double
a -> MetricDataPoint
s {$sel:fpr:MetricDataPoint' :: Maybe Double
fpr = Maybe Double
a} :: MetricDataPoint)

-- | The percentage of fraud events correctly predicted as fraudulent as
-- compared to all events predicted as fraudulent.
metricDataPoint_precision :: Lens.Lens' MetricDataPoint (Prelude.Maybe Prelude.Double)
metricDataPoint_precision :: Lens' MetricDataPoint (Maybe Double)
metricDataPoint_precision = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDataPoint' {Maybe Double
precision :: Maybe Double
$sel:precision:MetricDataPoint' :: MetricDataPoint -> Maybe Double
precision} -> Maybe Double
precision) (\s :: MetricDataPoint
s@MetricDataPoint' {} Maybe Double
a -> MetricDataPoint
s {$sel:precision:MetricDataPoint' :: Maybe Double
precision = Maybe Double
a} :: MetricDataPoint)

-- | The model threshold that specifies an acceptable fraud capture rate. For
-- example, a threshold of 500 means any model score 500 or above is
-- labeled as fraud.
metricDataPoint_threshold :: Lens.Lens' MetricDataPoint (Prelude.Maybe Prelude.Double)
metricDataPoint_threshold :: Lens' MetricDataPoint (Maybe Double)
metricDataPoint_threshold = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDataPoint' {Maybe Double
threshold :: Maybe Double
$sel:threshold:MetricDataPoint' :: MetricDataPoint -> Maybe Double
threshold} -> Maybe Double
threshold) (\s :: MetricDataPoint
s@MetricDataPoint' {} Maybe Double
a -> MetricDataPoint
s {$sel:threshold:MetricDataPoint' :: Maybe Double
threshold = Maybe Double
a} :: MetricDataPoint)

-- | The true positive rate. This is the percentage of total fraud the model
-- detects. Also known as capture rate.
metricDataPoint_tpr :: Lens.Lens' MetricDataPoint (Prelude.Maybe Prelude.Double)
metricDataPoint_tpr :: Lens' MetricDataPoint (Maybe Double)
metricDataPoint_tpr = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDataPoint' {Maybe Double
tpr :: Maybe Double
$sel:tpr:MetricDataPoint' :: MetricDataPoint -> Maybe Double
tpr} -> Maybe Double
tpr) (\s :: MetricDataPoint
s@MetricDataPoint' {} Maybe Double
a -> MetricDataPoint
s {$sel:tpr:MetricDataPoint' :: Maybe Double
tpr = Maybe Double
a} :: MetricDataPoint)

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

instance Prelude.Hashable MetricDataPoint where
  hashWithSalt :: Int -> MetricDataPoint -> Int
hashWithSalt Int
_salt MetricDataPoint' {Maybe Double
tpr :: Maybe Double
threshold :: Maybe Double
precision :: Maybe Double
fpr :: Maybe Double
$sel:tpr:MetricDataPoint' :: MetricDataPoint -> Maybe Double
$sel:threshold:MetricDataPoint' :: MetricDataPoint -> Maybe Double
$sel:precision:MetricDataPoint' :: MetricDataPoint -> Maybe Double
$sel:fpr:MetricDataPoint' :: MetricDataPoint -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
fpr
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
precision
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
threshold
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
tpr

instance Prelude.NFData MetricDataPoint where
  rnf :: MetricDataPoint -> ()
rnf MetricDataPoint' {Maybe Double
tpr :: Maybe Double
threshold :: Maybe Double
precision :: Maybe Double
fpr :: Maybe Double
$sel:tpr:MetricDataPoint' :: MetricDataPoint -> Maybe Double
$sel:threshold:MetricDataPoint' :: MetricDataPoint -> Maybe Double
$sel:precision:MetricDataPoint' :: MetricDataPoint -> Maybe Double
$sel:fpr:MetricDataPoint' :: MetricDataPoint -> Maybe Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
fpr
      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
threshold
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
tpr