{-# 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.ModelMetrics
-- 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.SageMaker.Types.ModelMetrics where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMaker.Types.Bias
import Amazonka.SageMaker.Types.Explainability
import Amazonka.SageMaker.Types.ModelDataQuality
import Amazonka.SageMaker.Types.ModelQuality

-- | Contains metrics captured from a model.
--
-- /See:/ 'newModelMetrics' smart constructor.
data ModelMetrics = ModelMetrics'
  { -- | Metrics that measure bais in a model.
    ModelMetrics -> Maybe Bias
bias :: Prelude.Maybe Bias,
    -- | Metrics that measure the quality of the input data for a model.
    ModelMetrics -> Maybe ModelDataQuality
modelDataQuality :: Prelude.Maybe ModelDataQuality,
    -- | Metrics that measure the quality of a model.
    ModelMetrics -> Maybe ModelQuality
modelQuality :: Prelude.Maybe ModelQuality,
    -- | Metrics that help explain a model.
    ModelMetrics -> Maybe Explainability
explainability :: Prelude.Maybe Explainability
  }
  deriving (ModelMetrics -> ModelMetrics -> Bool
(ModelMetrics -> ModelMetrics -> Bool)
-> (ModelMetrics -> ModelMetrics -> Bool) -> Eq ModelMetrics
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModelMetrics -> ModelMetrics -> Bool
$c/= :: ModelMetrics -> ModelMetrics -> Bool
== :: ModelMetrics -> ModelMetrics -> Bool
$c== :: ModelMetrics -> ModelMetrics -> Bool
Prelude.Eq, ReadPrec [ModelMetrics]
ReadPrec ModelMetrics
Int -> ReadS ModelMetrics
ReadS [ModelMetrics]
(Int -> ReadS ModelMetrics)
-> ReadS [ModelMetrics]
-> ReadPrec ModelMetrics
-> ReadPrec [ModelMetrics]
-> Read ModelMetrics
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ModelMetrics]
$creadListPrec :: ReadPrec [ModelMetrics]
readPrec :: ReadPrec ModelMetrics
$creadPrec :: ReadPrec ModelMetrics
readList :: ReadS [ModelMetrics]
$creadList :: ReadS [ModelMetrics]
readsPrec :: Int -> ReadS ModelMetrics
$creadsPrec :: Int -> ReadS ModelMetrics
Prelude.Read, Int -> ModelMetrics -> ShowS
[ModelMetrics] -> ShowS
ModelMetrics -> String
(Int -> ModelMetrics -> ShowS)
-> (ModelMetrics -> String)
-> ([ModelMetrics] -> ShowS)
-> Show ModelMetrics
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModelMetrics] -> ShowS
$cshowList :: [ModelMetrics] -> ShowS
show :: ModelMetrics -> String
$cshow :: ModelMetrics -> String
showsPrec :: Int -> ModelMetrics -> ShowS
$cshowsPrec :: Int -> ModelMetrics -> ShowS
Prelude.Show, (forall x. ModelMetrics -> Rep ModelMetrics x)
-> (forall x. Rep ModelMetrics x -> ModelMetrics)
-> Generic ModelMetrics
forall x. Rep ModelMetrics x -> ModelMetrics
forall x. ModelMetrics -> Rep ModelMetrics x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModelMetrics x -> ModelMetrics
$cfrom :: forall x. ModelMetrics -> Rep ModelMetrics x
Prelude.Generic)

-- |
-- Create a value of 'ModelMetrics' 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:
--
-- 'bias', 'modelMetrics_bias' - Metrics that measure bais in a model.
--
-- 'modelDataQuality', 'modelMetrics_modelDataQuality' - Metrics that measure the quality of the input data for a model.
--
-- 'modelQuality', 'modelMetrics_modelQuality' - Metrics that measure the quality of a model.
--
-- 'explainability', 'modelMetrics_explainability' - Metrics that help explain a model.
newModelMetrics ::
  ModelMetrics
newModelMetrics :: ModelMetrics
newModelMetrics =
  ModelMetrics' :: Maybe Bias
-> Maybe ModelDataQuality
-> Maybe ModelQuality
-> Maybe Explainability
-> ModelMetrics
ModelMetrics'
    { $sel:bias:ModelMetrics' :: Maybe Bias
bias = Maybe Bias
forall a. Maybe a
Prelude.Nothing,
      $sel:modelDataQuality:ModelMetrics' :: Maybe ModelDataQuality
modelDataQuality = Maybe ModelDataQuality
forall a. Maybe a
Prelude.Nothing,
      $sel:modelQuality:ModelMetrics' :: Maybe ModelQuality
modelQuality = Maybe ModelQuality
forall a. Maybe a
Prelude.Nothing,
      $sel:explainability:ModelMetrics' :: Maybe Explainability
explainability = Maybe Explainability
forall a. Maybe a
Prelude.Nothing
    }

-- | Metrics that measure bais in a model.
modelMetrics_bias :: Lens.Lens' ModelMetrics (Prelude.Maybe Bias)
modelMetrics_bias :: (Maybe Bias -> f (Maybe Bias)) -> ModelMetrics -> f ModelMetrics
modelMetrics_bias = (ModelMetrics -> Maybe Bias)
-> (ModelMetrics -> Maybe Bias -> ModelMetrics)
-> Lens ModelMetrics ModelMetrics (Maybe Bias) (Maybe Bias)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModelMetrics' {Maybe Bias
bias :: Maybe Bias
$sel:bias:ModelMetrics' :: ModelMetrics -> Maybe Bias
bias} -> Maybe Bias
bias) (\s :: ModelMetrics
s@ModelMetrics' {} Maybe Bias
a -> ModelMetrics
s {$sel:bias:ModelMetrics' :: Maybe Bias
bias = Maybe Bias
a} :: ModelMetrics)

-- | Metrics that measure the quality of the input data for a model.
modelMetrics_modelDataQuality :: Lens.Lens' ModelMetrics (Prelude.Maybe ModelDataQuality)
modelMetrics_modelDataQuality :: (Maybe ModelDataQuality -> f (Maybe ModelDataQuality))
-> ModelMetrics -> f ModelMetrics
modelMetrics_modelDataQuality = (ModelMetrics -> Maybe ModelDataQuality)
-> (ModelMetrics -> Maybe ModelDataQuality -> ModelMetrics)
-> Lens
     ModelMetrics
     ModelMetrics
     (Maybe ModelDataQuality)
     (Maybe ModelDataQuality)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModelMetrics' {Maybe ModelDataQuality
modelDataQuality :: Maybe ModelDataQuality
$sel:modelDataQuality:ModelMetrics' :: ModelMetrics -> Maybe ModelDataQuality
modelDataQuality} -> Maybe ModelDataQuality
modelDataQuality) (\s :: ModelMetrics
s@ModelMetrics' {} Maybe ModelDataQuality
a -> ModelMetrics
s {$sel:modelDataQuality:ModelMetrics' :: Maybe ModelDataQuality
modelDataQuality = Maybe ModelDataQuality
a} :: ModelMetrics)

-- | Metrics that measure the quality of a model.
modelMetrics_modelQuality :: Lens.Lens' ModelMetrics (Prelude.Maybe ModelQuality)
modelMetrics_modelQuality :: (Maybe ModelQuality -> f (Maybe ModelQuality))
-> ModelMetrics -> f ModelMetrics
modelMetrics_modelQuality = (ModelMetrics -> Maybe ModelQuality)
-> (ModelMetrics -> Maybe ModelQuality -> ModelMetrics)
-> Lens
     ModelMetrics ModelMetrics (Maybe ModelQuality) (Maybe ModelQuality)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModelMetrics' {Maybe ModelQuality
modelQuality :: Maybe ModelQuality
$sel:modelQuality:ModelMetrics' :: ModelMetrics -> Maybe ModelQuality
modelQuality} -> Maybe ModelQuality
modelQuality) (\s :: ModelMetrics
s@ModelMetrics' {} Maybe ModelQuality
a -> ModelMetrics
s {$sel:modelQuality:ModelMetrics' :: Maybe ModelQuality
modelQuality = Maybe ModelQuality
a} :: ModelMetrics)

-- | Metrics that help explain a model.
modelMetrics_explainability :: Lens.Lens' ModelMetrics (Prelude.Maybe Explainability)
modelMetrics_explainability :: (Maybe Explainability -> f (Maybe Explainability))
-> ModelMetrics -> f ModelMetrics
modelMetrics_explainability = (ModelMetrics -> Maybe Explainability)
-> (ModelMetrics -> Maybe Explainability -> ModelMetrics)
-> Lens
     ModelMetrics
     ModelMetrics
     (Maybe Explainability)
     (Maybe Explainability)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModelMetrics' {Maybe Explainability
explainability :: Maybe Explainability
$sel:explainability:ModelMetrics' :: ModelMetrics -> Maybe Explainability
explainability} -> Maybe Explainability
explainability) (\s :: ModelMetrics
s@ModelMetrics' {} Maybe Explainability
a -> ModelMetrics
s {$sel:explainability:ModelMetrics' :: Maybe Explainability
explainability = Maybe Explainability
a} :: ModelMetrics)

instance Core.FromJSON ModelMetrics where
  parseJSON :: Value -> Parser ModelMetrics
parseJSON =
    String
-> (Object -> Parser ModelMetrics) -> Value -> Parser ModelMetrics
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ModelMetrics"
      ( \Object
x ->
          Maybe Bias
-> Maybe ModelDataQuality
-> Maybe ModelQuality
-> Maybe Explainability
-> ModelMetrics
ModelMetrics'
            (Maybe Bias
 -> Maybe ModelDataQuality
 -> Maybe ModelQuality
 -> Maybe Explainability
 -> ModelMetrics)
-> Parser (Maybe Bias)
-> Parser
     (Maybe ModelDataQuality
      -> Maybe ModelQuality -> Maybe Explainability -> ModelMetrics)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bias)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Bias")
            Parser
  (Maybe ModelDataQuality
   -> Maybe ModelQuality -> Maybe Explainability -> ModelMetrics)
-> Parser (Maybe ModelDataQuality)
-> Parser
     (Maybe ModelQuality -> Maybe Explainability -> ModelMetrics)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ModelDataQuality)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ModelDataQuality")
            Parser (Maybe ModelQuality -> Maybe Explainability -> ModelMetrics)
-> Parser (Maybe ModelQuality)
-> Parser (Maybe Explainability -> ModelMetrics)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ModelQuality)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ModelQuality")
            Parser (Maybe Explainability -> ModelMetrics)
-> Parser (Maybe Explainability) -> Parser ModelMetrics
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Explainability)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Explainability")
      )

instance Prelude.Hashable ModelMetrics

instance Prelude.NFData ModelMetrics

instance Core.ToJSON ModelMetrics where
  toJSON :: ModelMetrics -> Value
toJSON ModelMetrics' {Maybe Explainability
Maybe Bias
Maybe ModelDataQuality
Maybe ModelQuality
explainability :: Maybe Explainability
modelQuality :: Maybe ModelQuality
modelDataQuality :: Maybe ModelDataQuality
bias :: Maybe Bias
$sel:explainability:ModelMetrics' :: ModelMetrics -> Maybe Explainability
$sel:modelQuality:ModelMetrics' :: ModelMetrics -> Maybe ModelQuality
$sel:modelDataQuality:ModelMetrics' :: ModelMetrics -> Maybe ModelDataQuality
$sel:bias:ModelMetrics' :: ModelMetrics -> Maybe Bias
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Bias" Text -> Bias -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bias -> Pair) -> Maybe Bias -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bias
bias,
            (Text
"ModelDataQuality" Text -> ModelDataQuality -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ModelDataQuality -> Pair) -> Maybe ModelDataQuality -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ModelDataQuality
modelDataQuality,
            (Text
"ModelQuality" Text -> ModelQuality -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ModelQuality -> Pair) -> Maybe ModelQuality -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ModelQuality
modelQuality,
            (Text
"Explainability" Text -> Explainability -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Explainability -> Pair) -> Maybe Explainability -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Explainability
explainability
          ]
      )