{-# 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.TrainingMetrics
-- 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.TrainingMetrics where

import qualified Amazonka.Core as Core
import Amazonka.FraudDetector.Types.MetricDataPoint
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The training metric details.
--
-- /See:/ 'newTrainingMetrics' smart constructor.
data TrainingMetrics = TrainingMetrics'
  { -- | The area under the curve. This summarizes true positive rate (TPR) and
    -- false positive rate (FPR) across all possible model score thresholds. A
    -- model with no predictive power has an AUC of 0.5, whereas a perfect
    -- model has a score of 1.0.
    TrainingMetrics -> Maybe Double
auc :: Prelude.Maybe Prelude.Double,
    -- | The data points details.
    TrainingMetrics -> Maybe [MetricDataPoint]
metricDataPoints :: Prelude.Maybe [MetricDataPoint]
  }
  deriving (TrainingMetrics -> TrainingMetrics -> Bool
(TrainingMetrics -> TrainingMetrics -> Bool)
-> (TrainingMetrics -> TrainingMetrics -> Bool)
-> Eq TrainingMetrics
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TrainingMetrics -> TrainingMetrics -> Bool
$c/= :: TrainingMetrics -> TrainingMetrics -> Bool
== :: TrainingMetrics -> TrainingMetrics -> Bool
$c== :: TrainingMetrics -> TrainingMetrics -> Bool
Prelude.Eq, ReadPrec [TrainingMetrics]
ReadPrec TrainingMetrics
Int -> ReadS TrainingMetrics
ReadS [TrainingMetrics]
(Int -> ReadS TrainingMetrics)
-> ReadS [TrainingMetrics]
-> ReadPrec TrainingMetrics
-> ReadPrec [TrainingMetrics]
-> Read TrainingMetrics
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TrainingMetrics]
$creadListPrec :: ReadPrec [TrainingMetrics]
readPrec :: ReadPrec TrainingMetrics
$creadPrec :: ReadPrec TrainingMetrics
readList :: ReadS [TrainingMetrics]
$creadList :: ReadS [TrainingMetrics]
readsPrec :: Int -> ReadS TrainingMetrics
$creadsPrec :: Int -> ReadS TrainingMetrics
Prelude.Read, Int -> TrainingMetrics -> ShowS
[TrainingMetrics] -> ShowS
TrainingMetrics -> String
(Int -> TrainingMetrics -> ShowS)
-> (TrainingMetrics -> String)
-> ([TrainingMetrics] -> ShowS)
-> Show TrainingMetrics
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TrainingMetrics] -> ShowS
$cshowList :: [TrainingMetrics] -> ShowS
show :: TrainingMetrics -> String
$cshow :: TrainingMetrics -> String
showsPrec :: Int -> TrainingMetrics -> ShowS
$cshowsPrec :: Int -> TrainingMetrics -> ShowS
Prelude.Show, (forall x. TrainingMetrics -> Rep TrainingMetrics x)
-> (forall x. Rep TrainingMetrics x -> TrainingMetrics)
-> Generic TrainingMetrics
forall x. Rep TrainingMetrics x -> TrainingMetrics
forall x. TrainingMetrics -> Rep TrainingMetrics x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TrainingMetrics x -> TrainingMetrics
$cfrom :: forall x. TrainingMetrics -> Rep TrainingMetrics x
Prelude.Generic)

-- |
-- Create a value of 'TrainingMetrics' 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:
--
-- 'auc', 'trainingMetrics_auc' - The area under the curve. This summarizes true positive rate (TPR) and
-- false positive rate (FPR) across all possible model score thresholds. A
-- model with no predictive power has an AUC of 0.5, whereas a perfect
-- model has a score of 1.0.
--
-- 'metricDataPoints', 'trainingMetrics_metricDataPoints' - The data points details.
newTrainingMetrics ::
  TrainingMetrics
newTrainingMetrics :: TrainingMetrics
newTrainingMetrics =
  TrainingMetrics' :: Maybe Double -> Maybe [MetricDataPoint] -> TrainingMetrics
TrainingMetrics'
    { $sel:auc:TrainingMetrics' :: Maybe Double
auc = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:metricDataPoints:TrainingMetrics' :: Maybe [MetricDataPoint]
metricDataPoints = Maybe [MetricDataPoint]
forall a. Maybe a
Prelude.Nothing
    }

-- | The area under the curve. This summarizes true positive rate (TPR) and
-- false positive rate (FPR) across all possible model score thresholds. A
-- model with no predictive power has an AUC of 0.5, whereas a perfect
-- model has a score of 1.0.
trainingMetrics_auc :: Lens.Lens' TrainingMetrics (Prelude.Maybe Prelude.Double)
trainingMetrics_auc :: (Maybe Double -> f (Maybe Double))
-> TrainingMetrics -> f TrainingMetrics
trainingMetrics_auc = (TrainingMetrics -> Maybe Double)
-> (TrainingMetrics -> Maybe Double -> TrainingMetrics)
-> Lens
     TrainingMetrics TrainingMetrics (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrainingMetrics' {Maybe Double
auc :: Maybe Double
$sel:auc:TrainingMetrics' :: TrainingMetrics -> Maybe Double
auc} -> Maybe Double
auc) (\s :: TrainingMetrics
s@TrainingMetrics' {} Maybe Double
a -> TrainingMetrics
s {$sel:auc:TrainingMetrics' :: Maybe Double
auc = Maybe Double
a} :: TrainingMetrics)

-- | The data points details.
trainingMetrics_metricDataPoints :: Lens.Lens' TrainingMetrics (Prelude.Maybe [MetricDataPoint])
trainingMetrics_metricDataPoints :: (Maybe [MetricDataPoint] -> f (Maybe [MetricDataPoint]))
-> TrainingMetrics -> f TrainingMetrics
trainingMetrics_metricDataPoints = (TrainingMetrics -> Maybe [MetricDataPoint])
-> (TrainingMetrics -> Maybe [MetricDataPoint] -> TrainingMetrics)
-> Lens
     TrainingMetrics
     TrainingMetrics
     (Maybe [MetricDataPoint])
     (Maybe [MetricDataPoint])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrainingMetrics' {Maybe [MetricDataPoint]
metricDataPoints :: Maybe [MetricDataPoint]
$sel:metricDataPoints:TrainingMetrics' :: TrainingMetrics -> Maybe [MetricDataPoint]
metricDataPoints} -> Maybe [MetricDataPoint]
metricDataPoints) (\s :: TrainingMetrics
s@TrainingMetrics' {} Maybe [MetricDataPoint]
a -> TrainingMetrics
s {$sel:metricDataPoints:TrainingMetrics' :: Maybe [MetricDataPoint]
metricDataPoints = Maybe [MetricDataPoint]
a} :: TrainingMetrics) ((Maybe [MetricDataPoint] -> f (Maybe [MetricDataPoint]))
 -> TrainingMetrics -> f TrainingMetrics)
-> ((Maybe [MetricDataPoint] -> f (Maybe [MetricDataPoint]))
    -> Maybe [MetricDataPoint] -> f (Maybe [MetricDataPoint]))
-> (Maybe [MetricDataPoint] -> f (Maybe [MetricDataPoint]))
-> TrainingMetrics
-> f TrainingMetrics
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [MetricDataPoint]
  [MetricDataPoint]
  [MetricDataPoint]
  [MetricDataPoint]
-> Iso
     (Maybe [MetricDataPoint])
     (Maybe [MetricDataPoint])
     (Maybe [MetricDataPoint])
     (Maybe [MetricDataPoint])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [MetricDataPoint]
  [MetricDataPoint]
  [MetricDataPoint]
  [MetricDataPoint]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON TrainingMetrics where
  parseJSON :: Value -> Parser TrainingMetrics
parseJSON =
    String
-> (Object -> Parser TrainingMetrics)
-> Value
-> Parser TrainingMetrics
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TrainingMetrics"
      ( \Object
x ->
          Maybe Double -> Maybe [MetricDataPoint] -> TrainingMetrics
TrainingMetrics'
            (Maybe Double -> Maybe [MetricDataPoint] -> TrainingMetrics)
-> Parser (Maybe Double)
-> Parser (Maybe [MetricDataPoint] -> TrainingMetrics)
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
"auc")
            Parser (Maybe [MetricDataPoint] -> TrainingMetrics)
-> Parser (Maybe [MetricDataPoint]) -> Parser TrainingMetrics
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [MetricDataPoint]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"metricDataPoints"
                            Parser (Maybe (Maybe [MetricDataPoint]))
-> Maybe [MetricDataPoint] -> Parser (Maybe [MetricDataPoint])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [MetricDataPoint]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable TrainingMetrics

instance Prelude.NFData TrainingMetrics