{-# 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.Forecast.Types.HyperParameterTuningJobConfig
-- 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.Forecast.Types.HyperParameterTuningJobConfig where

import qualified Amazonka.Core as Core
import Amazonka.Forecast.Types.ParameterRanges
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Configuration information for a hyperparameter tuning job. You specify
-- this object in the CreatePredictor request.
--
-- A /hyperparameter/ is a parameter that governs the model training
-- process. You set hyperparameters before training starts, unlike model
-- parameters, which are determined during training. The values of the
-- hyperparameters effect which values are chosen for the model parameters.
--
-- In a /hyperparameter tuning job/, Amazon Forecast chooses the set of
-- hyperparameter values that optimize a specified metric. Forecast
-- accomplishes this by running many training jobs over a range of
-- hyperparameter values. The optimum set of values depends on the
-- algorithm, the training data, and the specified metric objective.
--
-- /See:/ 'newHyperParameterTuningJobConfig' smart constructor.
data HyperParameterTuningJobConfig = HyperParameterTuningJobConfig'
  { -- | Specifies the ranges of valid values for the hyperparameters.
    HyperParameterTuningJobConfig -> Maybe ParameterRanges
parameterRanges :: Prelude.Maybe ParameterRanges
  }
  deriving (HyperParameterTuningJobConfig
-> HyperParameterTuningJobConfig -> Bool
(HyperParameterTuningJobConfig
 -> HyperParameterTuningJobConfig -> Bool)
-> (HyperParameterTuningJobConfig
    -> HyperParameterTuningJobConfig -> Bool)
-> Eq HyperParameterTuningJobConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HyperParameterTuningJobConfig
-> HyperParameterTuningJobConfig -> Bool
$c/= :: HyperParameterTuningJobConfig
-> HyperParameterTuningJobConfig -> Bool
== :: HyperParameterTuningJobConfig
-> HyperParameterTuningJobConfig -> Bool
$c== :: HyperParameterTuningJobConfig
-> HyperParameterTuningJobConfig -> Bool
Prelude.Eq, ReadPrec [HyperParameterTuningJobConfig]
ReadPrec HyperParameterTuningJobConfig
Int -> ReadS HyperParameterTuningJobConfig
ReadS [HyperParameterTuningJobConfig]
(Int -> ReadS HyperParameterTuningJobConfig)
-> ReadS [HyperParameterTuningJobConfig]
-> ReadPrec HyperParameterTuningJobConfig
-> ReadPrec [HyperParameterTuningJobConfig]
-> Read HyperParameterTuningJobConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HyperParameterTuningJobConfig]
$creadListPrec :: ReadPrec [HyperParameterTuningJobConfig]
readPrec :: ReadPrec HyperParameterTuningJobConfig
$creadPrec :: ReadPrec HyperParameterTuningJobConfig
readList :: ReadS [HyperParameterTuningJobConfig]
$creadList :: ReadS [HyperParameterTuningJobConfig]
readsPrec :: Int -> ReadS HyperParameterTuningJobConfig
$creadsPrec :: Int -> ReadS HyperParameterTuningJobConfig
Prelude.Read, Int -> HyperParameterTuningJobConfig -> ShowS
[HyperParameterTuningJobConfig] -> ShowS
HyperParameterTuningJobConfig -> String
(Int -> HyperParameterTuningJobConfig -> ShowS)
-> (HyperParameterTuningJobConfig -> String)
-> ([HyperParameterTuningJobConfig] -> ShowS)
-> Show HyperParameterTuningJobConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HyperParameterTuningJobConfig] -> ShowS
$cshowList :: [HyperParameterTuningJobConfig] -> ShowS
show :: HyperParameterTuningJobConfig -> String
$cshow :: HyperParameterTuningJobConfig -> String
showsPrec :: Int -> HyperParameterTuningJobConfig -> ShowS
$cshowsPrec :: Int -> HyperParameterTuningJobConfig -> ShowS
Prelude.Show, (forall x.
 HyperParameterTuningJobConfig
 -> Rep HyperParameterTuningJobConfig x)
-> (forall x.
    Rep HyperParameterTuningJobConfig x
    -> HyperParameterTuningJobConfig)
-> Generic HyperParameterTuningJobConfig
forall x.
Rep HyperParameterTuningJobConfig x
-> HyperParameterTuningJobConfig
forall x.
HyperParameterTuningJobConfig
-> Rep HyperParameterTuningJobConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep HyperParameterTuningJobConfig x
-> HyperParameterTuningJobConfig
$cfrom :: forall x.
HyperParameterTuningJobConfig
-> Rep HyperParameterTuningJobConfig x
Prelude.Generic)

-- |
-- Create a value of 'HyperParameterTuningJobConfig' 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:
--
-- 'parameterRanges', 'hyperParameterTuningJobConfig_parameterRanges' - Specifies the ranges of valid values for the hyperparameters.
newHyperParameterTuningJobConfig ::
  HyperParameterTuningJobConfig
newHyperParameterTuningJobConfig :: HyperParameterTuningJobConfig
newHyperParameterTuningJobConfig =
  HyperParameterTuningJobConfig' :: Maybe ParameterRanges -> HyperParameterTuningJobConfig
HyperParameterTuningJobConfig'
    { $sel:parameterRanges:HyperParameterTuningJobConfig' :: Maybe ParameterRanges
parameterRanges =
        Maybe ParameterRanges
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the ranges of valid values for the hyperparameters.
hyperParameterTuningJobConfig_parameterRanges :: Lens.Lens' HyperParameterTuningJobConfig (Prelude.Maybe ParameterRanges)
hyperParameterTuningJobConfig_parameterRanges :: (Maybe ParameterRanges -> f (Maybe ParameterRanges))
-> HyperParameterTuningJobConfig -> f HyperParameterTuningJobConfig
hyperParameterTuningJobConfig_parameterRanges = (HyperParameterTuningJobConfig -> Maybe ParameterRanges)
-> (HyperParameterTuningJobConfig
    -> Maybe ParameterRanges -> HyperParameterTuningJobConfig)
-> Lens
     HyperParameterTuningJobConfig
     HyperParameterTuningJobConfig
     (Maybe ParameterRanges)
     (Maybe ParameterRanges)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HyperParameterTuningJobConfig' {Maybe ParameterRanges
parameterRanges :: Maybe ParameterRanges
$sel:parameterRanges:HyperParameterTuningJobConfig' :: HyperParameterTuningJobConfig -> Maybe ParameterRanges
parameterRanges} -> Maybe ParameterRanges
parameterRanges) (\s :: HyperParameterTuningJobConfig
s@HyperParameterTuningJobConfig' {} Maybe ParameterRanges
a -> HyperParameterTuningJobConfig
s {$sel:parameterRanges:HyperParameterTuningJobConfig' :: Maybe ParameterRanges
parameterRanges = Maybe ParameterRanges
a} :: HyperParameterTuningJobConfig)

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

instance
  Prelude.Hashable
    HyperParameterTuningJobConfig

instance Prelude.NFData HyperParameterTuningJobConfig

instance Core.ToJSON HyperParameterTuningJobConfig where
  toJSON :: HyperParameterTuningJobConfig -> Value
toJSON HyperParameterTuningJobConfig' {Maybe ParameterRanges
parameterRanges :: Maybe ParameterRanges
$sel:parameterRanges:HyperParameterTuningJobConfig' :: HyperParameterTuningJobConfig -> Maybe ParameterRanges
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ParameterRanges" Text -> ParameterRanges -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ParameterRanges -> Pair) -> Maybe ParameterRanges -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ParameterRanges
parameterRanges
          ]
      )