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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.FraudDetector.Types.AggregatedVariablesImpactExplanation
import Amazonka.FraudDetector.Types.VariableImpactExplanation
import qualified Amazonka.Prelude as Prelude

-- | The prediction explanations that provide insight into how each event
-- variable impacted the model version\'s fraud prediction score.
--
-- /See:/ 'newPredictionExplanations' smart constructor.
data PredictionExplanations = PredictionExplanations'
  { -- | The details of the aggregated variables impact on the prediction score.
    --
    -- Account Takeover Insights (ATI) model uses event variables from the
    -- login data you provide to continuously calculate a set of variables
    -- (aggregated variables) based on historical events. For example, your ATI
    -- model might calculate the number of times an user has logged in using
    -- the same IP address. In this case, event variables used to derive the
    -- aggregated variables are @IP address@ and @user@.
    PredictionExplanations
-> Maybe [AggregatedVariablesImpactExplanation]
aggregatedVariablesImpactExplanations :: Prelude.Maybe [AggregatedVariablesImpactExplanation],
    -- | The details of the event variable\'s impact on the prediction score.
    PredictionExplanations -> Maybe [VariableImpactExplanation]
variableImpactExplanations :: Prelude.Maybe [VariableImpactExplanation]
  }
  deriving (PredictionExplanations -> PredictionExplanations -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PredictionExplanations -> PredictionExplanations -> Bool
$c/= :: PredictionExplanations -> PredictionExplanations -> Bool
== :: PredictionExplanations -> PredictionExplanations -> Bool
$c== :: PredictionExplanations -> PredictionExplanations -> Bool
Prelude.Eq, ReadPrec [PredictionExplanations]
ReadPrec PredictionExplanations
Int -> ReadS PredictionExplanations
ReadS [PredictionExplanations]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PredictionExplanations]
$creadListPrec :: ReadPrec [PredictionExplanations]
readPrec :: ReadPrec PredictionExplanations
$creadPrec :: ReadPrec PredictionExplanations
readList :: ReadS [PredictionExplanations]
$creadList :: ReadS [PredictionExplanations]
readsPrec :: Int -> ReadS PredictionExplanations
$creadsPrec :: Int -> ReadS PredictionExplanations
Prelude.Read, Int -> PredictionExplanations -> ShowS
[PredictionExplanations] -> ShowS
PredictionExplanations -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PredictionExplanations] -> ShowS
$cshowList :: [PredictionExplanations] -> ShowS
show :: PredictionExplanations -> String
$cshow :: PredictionExplanations -> String
showsPrec :: Int -> PredictionExplanations -> ShowS
$cshowsPrec :: Int -> PredictionExplanations -> ShowS
Prelude.Show, forall x. Rep PredictionExplanations x -> PredictionExplanations
forall x. PredictionExplanations -> Rep PredictionExplanations x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PredictionExplanations x -> PredictionExplanations
$cfrom :: forall x. PredictionExplanations -> Rep PredictionExplanations x
Prelude.Generic)

-- |
-- Create a value of 'PredictionExplanations' 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:
--
-- 'aggregatedVariablesImpactExplanations', 'predictionExplanations_aggregatedVariablesImpactExplanations' - The details of the aggregated variables impact on the prediction score.
--
-- Account Takeover Insights (ATI) model uses event variables from the
-- login data you provide to continuously calculate a set of variables
-- (aggregated variables) based on historical events. For example, your ATI
-- model might calculate the number of times an user has logged in using
-- the same IP address. In this case, event variables used to derive the
-- aggregated variables are @IP address@ and @user@.
--
-- 'variableImpactExplanations', 'predictionExplanations_variableImpactExplanations' - The details of the event variable\'s impact on the prediction score.
newPredictionExplanations ::
  PredictionExplanations
newPredictionExplanations :: PredictionExplanations
newPredictionExplanations =
  PredictionExplanations'
    { $sel:aggregatedVariablesImpactExplanations:PredictionExplanations' :: Maybe [AggregatedVariablesImpactExplanation]
aggregatedVariablesImpactExplanations =
        forall a. Maybe a
Prelude.Nothing,
      $sel:variableImpactExplanations:PredictionExplanations' :: Maybe [VariableImpactExplanation]
variableImpactExplanations = forall a. Maybe a
Prelude.Nothing
    }

-- | The details of the aggregated variables impact on the prediction score.
--
-- Account Takeover Insights (ATI) model uses event variables from the
-- login data you provide to continuously calculate a set of variables
-- (aggregated variables) based on historical events. For example, your ATI
-- model might calculate the number of times an user has logged in using
-- the same IP address. In this case, event variables used to derive the
-- aggregated variables are @IP address@ and @user@.
predictionExplanations_aggregatedVariablesImpactExplanations :: Lens.Lens' PredictionExplanations (Prelude.Maybe [AggregatedVariablesImpactExplanation])
predictionExplanations_aggregatedVariablesImpactExplanations :: Lens'
  PredictionExplanations
  (Maybe [AggregatedVariablesImpactExplanation])
predictionExplanations_aggregatedVariablesImpactExplanations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PredictionExplanations' {Maybe [AggregatedVariablesImpactExplanation]
aggregatedVariablesImpactExplanations :: Maybe [AggregatedVariablesImpactExplanation]
$sel:aggregatedVariablesImpactExplanations:PredictionExplanations' :: PredictionExplanations
-> Maybe [AggregatedVariablesImpactExplanation]
aggregatedVariablesImpactExplanations} -> Maybe [AggregatedVariablesImpactExplanation]
aggregatedVariablesImpactExplanations) (\s :: PredictionExplanations
s@PredictionExplanations' {} Maybe [AggregatedVariablesImpactExplanation]
a -> PredictionExplanations
s {$sel:aggregatedVariablesImpactExplanations:PredictionExplanations' :: Maybe [AggregatedVariablesImpactExplanation]
aggregatedVariablesImpactExplanations = Maybe [AggregatedVariablesImpactExplanation]
a} :: PredictionExplanations) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The details of the event variable\'s impact on the prediction score.
predictionExplanations_variableImpactExplanations :: Lens.Lens' PredictionExplanations (Prelude.Maybe [VariableImpactExplanation])
predictionExplanations_variableImpactExplanations :: Lens' PredictionExplanations (Maybe [VariableImpactExplanation])
predictionExplanations_variableImpactExplanations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PredictionExplanations' {Maybe [VariableImpactExplanation]
variableImpactExplanations :: Maybe [VariableImpactExplanation]
$sel:variableImpactExplanations:PredictionExplanations' :: PredictionExplanations -> Maybe [VariableImpactExplanation]
variableImpactExplanations} -> Maybe [VariableImpactExplanation]
variableImpactExplanations) (\s :: PredictionExplanations
s@PredictionExplanations' {} Maybe [VariableImpactExplanation]
a -> PredictionExplanations
s {$sel:variableImpactExplanations:PredictionExplanations' :: Maybe [VariableImpactExplanation]
variableImpactExplanations = Maybe [VariableImpactExplanation]
a} :: PredictionExplanations) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON PredictionExplanations where
  parseJSON :: Value -> Parser PredictionExplanations
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PredictionExplanations"
      ( \Object
x ->
          Maybe [AggregatedVariablesImpactExplanation]
-> Maybe [VariableImpactExplanation] -> PredictionExplanations
PredictionExplanations'
            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
"aggregatedVariablesImpactExplanations"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            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
"variableImpactExplanations"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable PredictionExplanations where
  hashWithSalt :: Int -> PredictionExplanations -> Int
hashWithSalt Int
_salt PredictionExplanations' {Maybe [AggregatedVariablesImpactExplanation]
Maybe [VariableImpactExplanation]
variableImpactExplanations :: Maybe [VariableImpactExplanation]
aggregatedVariablesImpactExplanations :: Maybe [AggregatedVariablesImpactExplanation]
$sel:variableImpactExplanations:PredictionExplanations' :: PredictionExplanations -> Maybe [VariableImpactExplanation]
$sel:aggregatedVariablesImpactExplanations:PredictionExplanations' :: PredictionExplanations
-> Maybe [AggregatedVariablesImpactExplanation]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [AggregatedVariablesImpactExplanation]
aggregatedVariablesImpactExplanations
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [VariableImpactExplanation]
variableImpactExplanations

instance Prelude.NFData PredictionExplanations where
  rnf :: PredictionExplanations -> ()
rnf PredictionExplanations' {Maybe [AggregatedVariablesImpactExplanation]
Maybe [VariableImpactExplanation]
variableImpactExplanations :: Maybe [VariableImpactExplanation]
aggregatedVariablesImpactExplanations :: Maybe [AggregatedVariablesImpactExplanation]
$sel:variableImpactExplanations:PredictionExplanations' :: PredictionExplanations -> Maybe [VariableImpactExplanation]
$sel:aggregatedVariablesImpactExplanations:PredictionExplanations' :: PredictionExplanations
-> Maybe [AggregatedVariablesImpactExplanation]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [AggregatedVariablesImpactExplanation]
aggregatedVariablesImpactExplanations
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [VariableImpactExplanation]
variableImpactExplanations