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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMaker.Types.AutoMLMetricEnum
import Amazonka.SageMaker.Types.MetricSetSource

-- | Information about the metric for a candidate produced by an AutoML job.
--
-- /See:/ 'newMetricDatum' smart constructor.
data MetricDatum = MetricDatum'
  { -- | The dataset split from which the AutoML job produced the metric.
    MetricDatum -> Maybe MetricSetSource
set :: Prelude.Maybe MetricSetSource,
    -- | The name of the metric.
    MetricDatum -> Maybe AutoMLMetricEnum
metricName :: Prelude.Maybe AutoMLMetricEnum,
    -- | The value of the metric.
    MetricDatum -> Maybe Double
value :: Prelude.Maybe Prelude.Double
  }
  deriving (MetricDatum -> MetricDatum -> Bool
(MetricDatum -> MetricDatum -> Bool)
-> (MetricDatum -> MetricDatum -> Bool) -> Eq MetricDatum
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetricDatum -> MetricDatum -> Bool
$c/= :: MetricDatum -> MetricDatum -> Bool
== :: MetricDatum -> MetricDatum -> Bool
$c== :: MetricDatum -> MetricDatum -> Bool
Prelude.Eq, ReadPrec [MetricDatum]
ReadPrec MetricDatum
Int -> ReadS MetricDatum
ReadS [MetricDatum]
(Int -> ReadS MetricDatum)
-> ReadS [MetricDatum]
-> ReadPrec MetricDatum
-> ReadPrec [MetricDatum]
-> Read MetricDatum
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MetricDatum]
$creadListPrec :: ReadPrec [MetricDatum]
readPrec :: ReadPrec MetricDatum
$creadPrec :: ReadPrec MetricDatum
readList :: ReadS [MetricDatum]
$creadList :: ReadS [MetricDatum]
readsPrec :: Int -> ReadS MetricDatum
$creadsPrec :: Int -> ReadS MetricDatum
Prelude.Read, Int -> MetricDatum -> ShowS
[MetricDatum] -> ShowS
MetricDatum -> String
(Int -> MetricDatum -> ShowS)
-> (MetricDatum -> String)
-> ([MetricDatum] -> ShowS)
-> Show MetricDatum
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MetricDatum] -> ShowS
$cshowList :: [MetricDatum] -> ShowS
show :: MetricDatum -> String
$cshow :: MetricDatum -> String
showsPrec :: Int -> MetricDatum -> ShowS
$cshowsPrec :: Int -> MetricDatum -> ShowS
Prelude.Show, (forall x. MetricDatum -> Rep MetricDatum x)
-> (forall x. Rep MetricDatum x -> MetricDatum)
-> Generic MetricDatum
forall x. Rep MetricDatum x -> MetricDatum
forall x. MetricDatum -> Rep MetricDatum x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MetricDatum x -> MetricDatum
$cfrom :: forall x. MetricDatum -> Rep MetricDatum x
Prelude.Generic)

-- |
-- Create a value of 'MetricDatum' 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:
--
-- 'set', 'metricDatum_set' - The dataset split from which the AutoML job produced the metric.
--
-- 'metricName', 'metricDatum_metricName' - The name of the metric.
--
-- 'value', 'metricDatum_value' - The value of the metric.
newMetricDatum ::
  MetricDatum
newMetricDatum :: MetricDatum
newMetricDatum =
  MetricDatum' :: Maybe MetricSetSource
-> Maybe AutoMLMetricEnum -> Maybe Double -> MetricDatum
MetricDatum'
    { $sel:set:MetricDatum' :: Maybe MetricSetSource
set = Maybe MetricSetSource
forall a. Maybe a
Prelude.Nothing,
      $sel:metricName:MetricDatum' :: Maybe AutoMLMetricEnum
metricName = Maybe AutoMLMetricEnum
forall a. Maybe a
Prelude.Nothing,
      $sel:value:MetricDatum' :: Maybe Double
value = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | The dataset split from which the AutoML job produced the metric.
metricDatum_set :: Lens.Lens' MetricDatum (Prelude.Maybe MetricSetSource)
metricDatum_set :: (Maybe MetricSetSource -> f (Maybe MetricSetSource))
-> MetricDatum -> f MetricDatum
metricDatum_set = (MetricDatum -> Maybe MetricSetSource)
-> (MetricDatum -> Maybe MetricSetSource -> MetricDatum)
-> Lens
     MetricDatum
     MetricDatum
     (Maybe MetricSetSource)
     (Maybe MetricSetSource)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDatum' {Maybe MetricSetSource
set :: Maybe MetricSetSource
$sel:set:MetricDatum' :: MetricDatum -> Maybe MetricSetSource
set} -> Maybe MetricSetSource
set) (\s :: MetricDatum
s@MetricDatum' {} Maybe MetricSetSource
a -> MetricDatum
s {$sel:set:MetricDatum' :: Maybe MetricSetSource
set = Maybe MetricSetSource
a} :: MetricDatum)

-- | The name of the metric.
metricDatum_metricName :: Lens.Lens' MetricDatum (Prelude.Maybe AutoMLMetricEnum)
metricDatum_metricName :: (Maybe AutoMLMetricEnum -> f (Maybe AutoMLMetricEnum))
-> MetricDatum -> f MetricDatum
metricDatum_metricName = (MetricDatum -> Maybe AutoMLMetricEnum)
-> (MetricDatum -> Maybe AutoMLMetricEnum -> MetricDatum)
-> Lens
     MetricDatum
     MetricDatum
     (Maybe AutoMLMetricEnum)
     (Maybe AutoMLMetricEnum)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDatum' {Maybe AutoMLMetricEnum
metricName :: Maybe AutoMLMetricEnum
$sel:metricName:MetricDatum' :: MetricDatum -> Maybe AutoMLMetricEnum
metricName} -> Maybe AutoMLMetricEnum
metricName) (\s :: MetricDatum
s@MetricDatum' {} Maybe AutoMLMetricEnum
a -> MetricDatum
s {$sel:metricName:MetricDatum' :: Maybe AutoMLMetricEnum
metricName = Maybe AutoMLMetricEnum
a} :: MetricDatum)

-- | The value of the metric.
metricDatum_value :: Lens.Lens' MetricDatum (Prelude.Maybe Prelude.Double)
metricDatum_value :: (Maybe Double -> f (Maybe Double)) -> MetricDatum -> f MetricDatum
metricDatum_value = (MetricDatum -> Maybe Double)
-> (MetricDatum -> Maybe Double -> MetricDatum)
-> Lens MetricDatum MetricDatum (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDatum' {Maybe Double
value :: Maybe Double
$sel:value:MetricDatum' :: MetricDatum -> Maybe Double
value} -> Maybe Double
value) (\s :: MetricDatum
s@MetricDatum' {} Maybe Double
a -> MetricDatum
s {$sel:value:MetricDatum' :: Maybe Double
value = Maybe Double
a} :: MetricDatum)

instance Core.FromJSON MetricDatum where
  parseJSON :: Value -> Parser MetricDatum
parseJSON =
    String
-> (Object -> Parser MetricDatum) -> Value -> Parser MetricDatum
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MetricDatum"
      ( \Object
x ->
          Maybe MetricSetSource
-> Maybe AutoMLMetricEnum -> Maybe Double -> MetricDatum
MetricDatum'
            (Maybe MetricSetSource
 -> Maybe AutoMLMetricEnum -> Maybe Double -> MetricDatum)
-> Parser (Maybe MetricSetSource)
-> Parser (Maybe AutoMLMetricEnum -> Maybe Double -> MetricDatum)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe MetricSetSource)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Set")
            Parser (Maybe AutoMLMetricEnum -> Maybe Double -> MetricDatum)
-> Parser (Maybe AutoMLMetricEnum)
-> Parser (Maybe Double -> MetricDatum)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AutoMLMetricEnum)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MetricName")
            Parser (Maybe Double -> MetricDatum)
-> Parser (Maybe Double) -> Parser MetricDatum
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
"Value")
      )

instance Prelude.Hashable MetricDatum

instance Prelude.NFData MetricDatum