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

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

-- | Model performance metrics data points.
--
-- /See:/ 'newMetricDataPoint' smart constructor.
data MetricDataPoint = MetricDataPoint'
  { -- | 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 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 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
(MetricDataPoint -> MetricDataPoint -> Bool)
-> (MetricDataPoint -> MetricDataPoint -> Bool)
-> Eq MetricDataPoint
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]
(Int -> ReadS MetricDataPoint)
-> ReadS [MetricDataPoint]
-> ReadPrec MetricDataPoint
-> ReadPrec [MetricDataPoint]
-> Read 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
(Int -> MetricDataPoint -> ShowS)
-> (MetricDataPoint -> String)
-> ([MetricDataPoint] -> ShowS)
-> Show MetricDataPoint
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. MetricDataPoint -> Rep MetricDataPoint x)
-> (forall x. Rep MetricDataPoint x -> MetricDataPoint)
-> Generic MetricDataPoint
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:
--
-- 'precision', 'metricDataPoint_precision' - The percentage of fraud events correctly predicted as fraudulent as
-- compared to all events predicted as fraudulent.
--
-- 'fpr', 'metricDataPoint_fpr' - The false positive rate. This is the percentage of total legitimate
-- events that are incorrectly predicted as fraud.
--
-- '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' :: Maybe Double
-> Maybe Double -> Maybe Double -> Maybe Double -> MetricDataPoint
MetricDataPoint'
    { $sel:precision:MetricDataPoint' :: Maybe Double
precision = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:fpr:MetricDataPoint' :: Maybe Double
fpr = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:threshold:MetricDataPoint' :: Maybe Double
threshold = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:tpr:MetricDataPoint' :: Maybe Double
tpr = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Double -> f (Maybe Double))
-> MetricDataPoint -> f MetricDataPoint
metricDataPoint_precision = (MetricDataPoint -> Maybe Double)
-> (MetricDataPoint -> Maybe Double -> MetricDataPoint)
-> Lens
     MetricDataPoint MetricDataPoint (Maybe Double) (Maybe Double)
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 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 :: (Maybe Double -> f (Maybe Double))
-> MetricDataPoint -> f MetricDataPoint
metricDataPoint_fpr = (MetricDataPoint -> Maybe Double)
-> (MetricDataPoint -> Maybe Double -> MetricDataPoint)
-> Lens
     MetricDataPoint MetricDataPoint (Maybe Double) (Maybe Double)
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 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 :: (Maybe Double -> f (Maybe Double))
-> MetricDataPoint -> f MetricDataPoint
metricDataPoint_threshold = (MetricDataPoint -> Maybe Double)
-> (MetricDataPoint -> Maybe Double -> MetricDataPoint)
-> Lens
     MetricDataPoint MetricDataPoint (Maybe Double) (Maybe Double)
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 :: (Maybe Double -> f (Maybe Double))
-> MetricDataPoint -> f MetricDataPoint
metricDataPoint_tpr = (MetricDataPoint -> Maybe Double)
-> (MetricDataPoint -> Maybe Double -> MetricDataPoint)
-> Lens
     MetricDataPoint MetricDataPoint (Maybe Double) (Maybe Double)
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 Core.FromJSON MetricDataPoint where
  parseJSON :: Value -> Parser MetricDataPoint
parseJSON =
    String
-> (Object -> Parser MetricDataPoint)
-> Value
-> Parser MetricDataPoint
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MetricDataPoint"
      ( \Object
x ->
          Maybe Double
-> Maybe Double -> Maybe Double -> Maybe Double -> MetricDataPoint
MetricDataPoint'
            (Maybe Double
 -> Maybe Double -> Maybe Double -> Maybe Double -> MetricDataPoint)
-> Parser (Maybe Double)
-> Parser
     (Maybe Double -> Maybe Double -> Maybe Double -> MetricDataPoint)
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
"precision")
            Parser
  (Maybe Double -> Maybe Double -> Maybe Double -> MetricDataPoint)
-> Parser (Maybe Double)
-> Parser (Maybe Double -> Maybe Double -> MetricDataPoint)
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
"fpr")
            Parser (Maybe Double -> Maybe Double -> MetricDataPoint)
-> Parser (Maybe Double)
-> Parser (Maybe Double -> MetricDataPoint)
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
"threshold")
            Parser (Maybe Double -> MetricDataPoint)
-> Parser (Maybe Double) -> Parser MetricDataPoint
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
"tpr")
      )

instance Prelude.Hashable MetricDataPoint

instance Prelude.NFData MetricDataPoint