{-# 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.SageMaker.Types.ClarifyShapConfig
-- 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.SageMaker.Types.ClarifyShapConfig 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
import Amazonka.SageMaker.Types.ClarifyShapBaselineConfig
import Amazonka.SageMaker.Types.ClarifyTextConfig

-- | The configuration for SHAP analysis using SageMaker Clarify Explainer.
--
-- /See:/ 'newClarifyShapConfig' smart constructor.
data ClarifyShapConfig = ClarifyShapConfig'
  { -- | The number of samples to be used for analysis by the Kernal SHAP
    -- algorithm.
    --
    -- The number of samples determines the size of the synthetic dataset,
    -- which has an impact on latency of explainability requests. For more
    -- information, see the __Synthetic data__ of
    -- <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-online-explainability-create-endpoint.html Configure and create an endpoint>.
    ClarifyShapConfig -> Maybe Natural
numberOfSamples :: Prelude.Maybe Prelude.Natural,
    -- | The starting value used to initialize the random number generator in the
    -- explainer. Provide a value for this parameter to obtain a deterministic
    -- SHAP result.
    ClarifyShapConfig -> Maybe Int
seed :: Prelude.Maybe Prelude.Int,
    -- | A parameter that indicates if text features are treated as text and
    -- explanations are provided for individual units of text. Required for
    -- natural language processing (NLP) explainability only.
    ClarifyShapConfig -> Maybe ClarifyTextConfig
textConfig :: Prelude.Maybe ClarifyTextConfig,
    -- | A Boolean toggle to indicate if you want to use the logit function
    -- (true) or log-odds units (false) for model predictions. Defaults to
    -- false.
    ClarifyShapConfig -> Maybe Bool
useLogit :: Prelude.Maybe Prelude.Bool,
    -- | The configuration for the SHAP baseline of the Kernal SHAP algorithm.
    ClarifyShapConfig -> ClarifyShapBaselineConfig
shapBaselineConfig :: ClarifyShapBaselineConfig
  }
  deriving (ClarifyShapConfig -> ClarifyShapConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ClarifyShapConfig -> ClarifyShapConfig -> Bool
$c/= :: ClarifyShapConfig -> ClarifyShapConfig -> Bool
== :: ClarifyShapConfig -> ClarifyShapConfig -> Bool
$c== :: ClarifyShapConfig -> ClarifyShapConfig -> Bool
Prelude.Eq, ReadPrec [ClarifyShapConfig]
ReadPrec ClarifyShapConfig
Int -> ReadS ClarifyShapConfig
ReadS [ClarifyShapConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ClarifyShapConfig]
$creadListPrec :: ReadPrec [ClarifyShapConfig]
readPrec :: ReadPrec ClarifyShapConfig
$creadPrec :: ReadPrec ClarifyShapConfig
readList :: ReadS [ClarifyShapConfig]
$creadList :: ReadS [ClarifyShapConfig]
readsPrec :: Int -> ReadS ClarifyShapConfig
$creadsPrec :: Int -> ReadS ClarifyShapConfig
Prelude.Read, Int -> ClarifyShapConfig -> ShowS
[ClarifyShapConfig] -> ShowS
ClarifyShapConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ClarifyShapConfig] -> ShowS
$cshowList :: [ClarifyShapConfig] -> ShowS
show :: ClarifyShapConfig -> String
$cshow :: ClarifyShapConfig -> String
showsPrec :: Int -> ClarifyShapConfig -> ShowS
$cshowsPrec :: Int -> ClarifyShapConfig -> ShowS
Prelude.Show, forall x. Rep ClarifyShapConfig x -> ClarifyShapConfig
forall x. ClarifyShapConfig -> Rep ClarifyShapConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ClarifyShapConfig x -> ClarifyShapConfig
$cfrom :: forall x. ClarifyShapConfig -> Rep ClarifyShapConfig x
Prelude.Generic)

-- |
-- Create a value of 'ClarifyShapConfig' 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:
--
-- 'numberOfSamples', 'clarifyShapConfig_numberOfSamples' - The number of samples to be used for analysis by the Kernal SHAP
-- algorithm.
--
-- The number of samples determines the size of the synthetic dataset,
-- which has an impact on latency of explainability requests. For more
-- information, see the __Synthetic data__ of
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-online-explainability-create-endpoint.html Configure and create an endpoint>.
--
-- 'seed', 'clarifyShapConfig_seed' - The starting value used to initialize the random number generator in the
-- explainer. Provide a value for this parameter to obtain a deterministic
-- SHAP result.
--
-- 'textConfig', 'clarifyShapConfig_textConfig' - A parameter that indicates if text features are treated as text and
-- explanations are provided for individual units of text. Required for
-- natural language processing (NLP) explainability only.
--
-- 'useLogit', 'clarifyShapConfig_useLogit' - A Boolean toggle to indicate if you want to use the logit function
-- (true) or log-odds units (false) for model predictions. Defaults to
-- false.
--
-- 'shapBaselineConfig', 'clarifyShapConfig_shapBaselineConfig' - The configuration for the SHAP baseline of the Kernal SHAP algorithm.
newClarifyShapConfig ::
  -- | 'shapBaselineConfig'
  ClarifyShapBaselineConfig ->
  ClarifyShapConfig
newClarifyShapConfig :: ClarifyShapBaselineConfig -> ClarifyShapConfig
newClarifyShapConfig ClarifyShapBaselineConfig
pShapBaselineConfig_ =
  ClarifyShapConfig'
    { $sel:numberOfSamples:ClarifyShapConfig' :: Maybe Natural
numberOfSamples =
        forall a. Maybe a
Prelude.Nothing,
      $sel:seed:ClarifyShapConfig' :: Maybe Int
seed = forall a. Maybe a
Prelude.Nothing,
      $sel:textConfig:ClarifyShapConfig' :: Maybe ClarifyTextConfig
textConfig = forall a. Maybe a
Prelude.Nothing,
      $sel:useLogit:ClarifyShapConfig' :: Maybe Bool
useLogit = forall a. Maybe a
Prelude.Nothing,
      $sel:shapBaselineConfig:ClarifyShapConfig' :: ClarifyShapBaselineConfig
shapBaselineConfig = ClarifyShapBaselineConfig
pShapBaselineConfig_
    }

-- | The number of samples to be used for analysis by the Kernal SHAP
-- algorithm.
--
-- The number of samples determines the size of the synthetic dataset,
-- which has an impact on latency of explainability requests. For more
-- information, see the __Synthetic data__ of
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-online-explainability-create-endpoint.html Configure and create an endpoint>.
clarifyShapConfig_numberOfSamples :: Lens.Lens' ClarifyShapConfig (Prelude.Maybe Prelude.Natural)
clarifyShapConfig_numberOfSamples :: Lens' ClarifyShapConfig (Maybe Natural)
clarifyShapConfig_numberOfSamples = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClarifyShapConfig' {Maybe Natural
numberOfSamples :: Maybe Natural
$sel:numberOfSamples:ClarifyShapConfig' :: ClarifyShapConfig -> Maybe Natural
numberOfSamples} -> Maybe Natural
numberOfSamples) (\s :: ClarifyShapConfig
s@ClarifyShapConfig' {} Maybe Natural
a -> ClarifyShapConfig
s {$sel:numberOfSamples:ClarifyShapConfig' :: Maybe Natural
numberOfSamples = Maybe Natural
a} :: ClarifyShapConfig)

-- | The starting value used to initialize the random number generator in the
-- explainer. Provide a value for this parameter to obtain a deterministic
-- SHAP result.
clarifyShapConfig_seed :: Lens.Lens' ClarifyShapConfig (Prelude.Maybe Prelude.Int)
clarifyShapConfig_seed :: Lens' ClarifyShapConfig (Maybe Int)
clarifyShapConfig_seed = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClarifyShapConfig' {Maybe Int
seed :: Maybe Int
$sel:seed:ClarifyShapConfig' :: ClarifyShapConfig -> Maybe Int
seed} -> Maybe Int
seed) (\s :: ClarifyShapConfig
s@ClarifyShapConfig' {} Maybe Int
a -> ClarifyShapConfig
s {$sel:seed:ClarifyShapConfig' :: Maybe Int
seed = Maybe Int
a} :: ClarifyShapConfig)

-- | A parameter that indicates if text features are treated as text and
-- explanations are provided for individual units of text. Required for
-- natural language processing (NLP) explainability only.
clarifyShapConfig_textConfig :: Lens.Lens' ClarifyShapConfig (Prelude.Maybe ClarifyTextConfig)
clarifyShapConfig_textConfig :: Lens' ClarifyShapConfig (Maybe ClarifyTextConfig)
clarifyShapConfig_textConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClarifyShapConfig' {Maybe ClarifyTextConfig
textConfig :: Maybe ClarifyTextConfig
$sel:textConfig:ClarifyShapConfig' :: ClarifyShapConfig -> Maybe ClarifyTextConfig
textConfig} -> Maybe ClarifyTextConfig
textConfig) (\s :: ClarifyShapConfig
s@ClarifyShapConfig' {} Maybe ClarifyTextConfig
a -> ClarifyShapConfig
s {$sel:textConfig:ClarifyShapConfig' :: Maybe ClarifyTextConfig
textConfig = Maybe ClarifyTextConfig
a} :: ClarifyShapConfig)

-- | A Boolean toggle to indicate if you want to use the logit function
-- (true) or log-odds units (false) for model predictions. Defaults to
-- false.
clarifyShapConfig_useLogit :: Lens.Lens' ClarifyShapConfig (Prelude.Maybe Prelude.Bool)
clarifyShapConfig_useLogit :: Lens' ClarifyShapConfig (Maybe Bool)
clarifyShapConfig_useLogit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClarifyShapConfig' {Maybe Bool
useLogit :: Maybe Bool
$sel:useLogit:ClarifyShapConfig' :: ClarifyShapConfig -> Maybe Bool
useLogit} -> Maybe Bool
useLogit) (\s :: ClarifyShapConfig
s@ClarifyShapConfig' {} Maybe Bool
a -> ClarifyShapConfig
s {$sel:useLogit:ClarifyShapConfig' :: Maybe Bool
useLogit = Maybe Bool
a} :: ClarifyShapConfig)

-- | The configuration for the SHAP baseline of the Kernal SHAP algorithm.
clarifyShapConfig_shapBaselineConfig :: Lens.Lens' ClarifyShapConfig ClarifyShapBaselineConfig
clarifyShapConfig_shapBaselineConfig :: Lens' ClarifyShapConfig ClarifyShapBaselineConfig
clarifyShapConfig_shapBaselineConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClarifyShapConfig' {ClarifyShapBaselineConfig
shapBaselineConfig :: ClarifyShapBaselineConfig
$sel:shapBaselineConfig:ClarifyShapConfig' :: ClarifyShapConfig -> ClarifyShapBaselineConfig
shapBaselineConfig} -> ClarifyShapBaselineConfig
shapBaselineConfig) (\s :: ClarifyShapConfig
s@ClarifyShapConfig' {} ClarifyShapBaselineConfig
a -> ClarifyShapConfig
s {$sel:shapBaselineConfig:ClarifyShapConfig' :: ClarifyShapBaselineConfig
shapBaselineConfig = ClarifyShapBaselineConfig
a} :: ClarifyShapConfig)

instance Data.FromJSON ClarifyShapConfig where
  parseJSON :: Value -> Parser ClarifyShapConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ClarifyShapConfig"
      ( \Object
x ->
          Maybe Natural
-> Maybe Int
-> Maybe ClarifyTextConfig
-> Maybe Bool
-> ClarifyShapBaselineConfig
-> ClarifyShapConfig
ClarifyShapConfig'
            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
"NumberOfSamples")
            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
"Seed")
            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
"TextConfig")
            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
"UseLogit")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ShapBaselineConfig")
      )

instance Prelude.Hashable ClarifyShapConfig where
  hashWithSalt :: Int -> ClarifyShapConfig -> Int
hashWithSalt Int
_salt ClarifyShapConfig' {Maybe Bool
Maybe Int
Maybe Natural
Maybe ClarifyTextConfig
ClarifyShapBaselineConfig
shapBaselineConfig :: ClarifyShapBaselineConfig
useLogit :: Maybe Bool
textConfig :: Maybe ClarifyTextConfig
seed :: Maybe Int
numberOfSamples :: Maybe Natural
$sel:shapBaselineConfig:ClarifyShapConfig' :: ClarifyShapConfig -> ClarifyShapBaselineConfig
$sel:useLogit:ClarifyShapConfig' :: ClarifyShapConfig -> Maybe Bool
$sel:textConfig:ClarifyShapConfig' :: ClarifyShapConfig -> Maybe ClarifyTextConfig
$sel:seed:ClarifyShapConfig' :: ClarifyShapConfig -> Maybe Int
$sel:numberOfSamples:ClarifyShapConfig' :: ClarifyShapConfig -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
numberOfSamples
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
seed
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ClarifyTextConfig
textConfig
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
useLogit
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ClarifyShapBaselineConfig
shapBaselineConfig

instance Prelude.NFData ClarifyShapConfig where
  rnf :: ClarifyShapConfig -> ()
rnf ClarifyShapConfig' {Maybe Bool
Maybe Int
Maybe Natural
Maybe ClarifyTextConfig
ClarifyShapBaselineConfig
shapBaselineConfig :: ClarifyShapBaselineConfig
useLogit :: Maybe Bool
textConfig :: Maybe ClarifyTextConfig
seed :: Maybe Int
numberOfSamples :: Maybe Natural
$sel:shapBaselineConfig:ClarifyShapConfig' :: ClarifyShapConfig -> ClarifyShapBaselineConfig
$sel:useLogit:ClarifyShapConfig' :: ClarifyShapConfig -> Maybe Bool
$sel:textConfig:ClarifyShapConfig' :: ClarifyShapConfig -> Maybe ClarifyTextConfig
$sel:seed:ClarifyShapConfig' :: ClarifyShapConfig -> Maybe Int
$sel:numberOfSamples:ClarifyShapConfig' :: ClarifyShapConfig -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
numberOfSamples
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
seed
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ClarifyTextConfig
textConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
useLogit
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ClarifyShapBaselineConfig
shapBaselineConfig

instance Data.ToJSON ClarifyShapConfig where
  toJSON :: ClarifyShapConfig -> Value
toJSON ClarifyShapConfig' {Maybe Bool
Maybe Int
Maybe Natural
Maybe ClarifyTextConfig
ClarifyShapBaselineConfig
shapBaselineConfig :: ClarifyShapBaselineConfig
useLogit :: Maybe Bool
textConfig :: Maybe ClarifyTextConfig
seed :: Maybe Int
numberOfSamples :: Maybe Natural
$sel:shapBaselineConfig:ClarifyShapConfig' :: ClarifyShapConfig -> ClarifyShapBaselineConfig
$sel:useLogit:ClarifyShapConfig' :: ClarifyShapConfig -> Maybe Bool
$sel:textConfig:ClarifyShapConfig' :: ClarifyShapConfig -> Maybe ClarifyTextConfig
$sel:seed:ClarifyShapConfig' :: ClarifyShapConfig -> Maybe Int
$sel:numberOfSamples:ClarifyShapConfig' :: ClarifyShapConfig -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"NumberOfSamples" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
numberOfSamples,
            (Key
"Seed" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
seed,
            (Key
"TextConfig" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ClarifyTextConfig
textConfig,
            (Key
"UseLogit" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
useLogit,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ShapBaselineConfig" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ClarifyShapBaselineConfig
shapBaselineConfig)
          ]
      )