{-# 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.HyperParameterSpecification
-- 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.HyperParameterSpecification 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.ParameterRange
import Amazonka.SageMaker.Types.ParameterType

-- | Defines a hyperparameter to be used by an algorithm.
--
-- /See:/ 'newHyperParameterSpecification' smart constructor.
data HyperParameterSpecification = HyperParameterSpecification'
  { -- | The default value for this hyperparameter. If a default value is
    -- specified, a hyperparameter cannot be required.
    HyperParameterSpecification -> Maybe Text
defaultValue :: Prelude.Maybe Prelude.Text,
    -- | A brief description of the hyperparameter.
    HyperParameterSpecification -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | Indicates whether this hyperparameter is required.
    HyperParameterSpecification -> Maybe Bool
isRequired :: Prelude.Maybe Prelude.Bool,
    -- | Indicates whether this hyperparameter is tunable in a hyperparameter
    -- tuning job.
    HyperParameterSpecification -> Maybe Bool
isTunable :: Prelude.Maybe Prelude.Bool,
    -- | The allowed range for this hyperparameter.
    HyperParameterSpecification -> Maybe ParameterRange
range :: Prelude.Maybe ParameterRange,
    -- | The name of this hyperparameter. The name must be unique.
    HyperParameterSpecification -> Text
name :: Prelude.Text,
    -- | The type of this hyperparameter. The valid types are @Integer@,
    -- @Continuous@, @Categorical@, and @FreeText@.
    HyperParameterSpecification -> ParameterType
type' :: ParameterType
  }
  deriving (HyperParameterSpecification -> HyperParameterSpecification -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HyperParameterSpecification -> HyperParameterSpecification -> Bool
$c/= :: HyperParameterSpecification -> HyperParameterSpecification -> Bool
== :: HyperParameterSpecification -> HyperParameterSpecification -> Bool
$c== :: HyperParameterSpecification -> HyperParameterSpecification -> Bool
Prelude.Eq, ReadPrec [HyperParameterSpecification]
ReadPrec HyperParameterSpecification
Int -> ReadS HyperParameterSpecification
ReadS [HyperParameterSpecification]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HyperParameterSpecification]
$creadListPrec :: ReadPrec [HyperParameterSpecification]
readPrec :: ReadPrec HyperParameterSpecification
$creadPrec :: ReadPrec HyperParameterSpecification
readList :: ReadS [HyperParameterSpecification]
$creadList :: ReadS [HyperParameterSpecification]
readsPrec :: Int -> ReadS HyperParameterSpecification
$creadsPrec :: Int -> ReadS HyperParameterSpecification
Prelude.Read, Int -> HyperParameterSpecification -> ShowS
[HyperParameterSpecification] -> ShowS
HyperParameterSpecification -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HyperParameterSpecification] -> ShowS
$cshowList :: [HyperParameterSpecification] -> ShowS
show :: HyperParameterSpecification -> String
$cshow :: HyperParameterSpecification -> String
showsPrec :: Int -> HyperParameterSpecification -> ShowS
$cshowsPrec :: Int -> HyperParameterSpecification -> ShowS
Prelude.Show, forall x.
Rep HyperParameterSpecification x -> HyperParameterSpecification
forall x.
HyperParameterSpecification -> Rep HyperParameterSpecification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep HyperParameterSpecification x -> HyperParameterSpecification
$cfrom :: forall x.
HyperParameterSpecification -> Rep HyperParameterSpecification x
Prelude.Generic)

-- |
-- Create a value of 'HyperParameterSpecification' 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:
--
-- 'defaultValue', 'hyperParameterSpecification_defaultValue' - The default value for this hyperparameter. If a default value is
-- specified, a hyperparameter cannot be required.
--
-- 'description', 'hyperParameterSpecification_description' - A brief description of the hyperparameter.
--
-- 'isRequired', 'hyperParameterSpecification_isRequired' - Indicates whether this hyperparameter is required.
--
-- 'isTunable', 'hyperParameterSpecification_isTunable' - Indicates whether this hyperparameter is tunable in a hyperparameter
-- tuning job.
--
-- 'range', 'hyperParameterSpecification_range' - The allowed range for this hyperparameter.
--
-- 'name', 'hyperParameterSpecification_name' - The name of this hyperparameter. The name must be unique.
--
-- 'type'', 'hyperParameterSpecification_type' - The type of this hyperparameter. The valid types are @Integer@,
-- @Continuous@, @Categorical@, and @FreeText@.
newHyperParameterSpecification ::
  -- | 'name'
  Prelude.Text ->
  -- | 'type''
  ParameterType ->
  HyperParameterSpecification
newHyperParameterSpecification :: Text -> ParameterType -> HyperParameterSpecification
newHyperParameterSpecification Text
pName_ ParameterType
pType_ =
  HyperParameterSpecification'
    { $sel:defaultValue:HyperParameterSpecification' :: Maybe Text
defaultValue =
        forall a. Maybe a
Prelude.Nothing,
      $sel:description:HyperParameterSpecification' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:isRequired:HyperParameterSpecification' :: Maybe Bool
isRequired = forall a. Maybe a
Prelude.Nothing,
      $sel:isTunable:HyperParameterSpecification' :: Maybe Bool
isTunable = forall a. Maybe a
Prelude.Nothing,
      $sel:range:HyperParameterSpecification' :: Maybe ParameterRange
range = forall a. Maybe a
Prelude.Nothing,
      $sel:name:HyperParameterSpecification' :: Text
name = Text
pName_,
      $sel:type':HyperParameterSpecification' :: ParameterType
type' = ParameterType
pType_
    }

-- | The default value for this hyperparameter. If a default value is
-- specified, a hyperparameter cannot be required.
hyperParameterSpecification_defaultValue :: Lens.Lens' HyperParameterSpecification (Prelude.Maybe Prelude.Text)
hyperParameterSpecification_defaultValue :: Lens' HyperParameterSpecification (Maybe Text)
hyperParameterSpecification_defaultValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HyperParameterSpecification' {Maybe Text
defaultValue :: Maybe Text
$sel:defaultValue:HyperParameterSpecification' :: HyperParameterSpecification -> Maybe Text
defaultValue} -> Maybe Text
defaultValue) (\s :: HyperParameterSpecification
s@HyperParameterSpecification' {} Maybe Text
a -> HyperParameterSpecification
s {$sel:defaultValue:HyperParameterSpecification' :: Maybe Text
defaultValue = Maybe Text
a} :: HyperParameterSpecification)

-- | A brief description of the hyperparameter.
hyperParameterSpecification_description :: Lens.Lens' HyperParameterSpecification (Prelude.Maybe Prelude.Text)
hyperParameterSpecification_description :: Lens' HyperParameterSpecification (Maybe Text)
hyperParameterSpecification_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HyperParameterSpecification' {Maybe Text
description :: Maybe Text
$sel:description:HyperParameterSpecification' :: HyperParameterSpecification -> Maybe Text
description} -> Maybe Text
description) (\s :: HyperParameterSpecification
s@HyperParameterSpecification' {} Maybe Text
a -> HyperParameterSpecification
s {$sel:description:HyperParameterSpecification' :: Maybe Text
description = Maybe Text
a} :: HyperParameterSpecification)

-- | Indicates whether this hyperparameter is required.
hyperParameterSpecification_isRequired :: Lens.Lens' HyperParameterSpecification (Prelude.Maybe Prelude.Bool)
hyperParameterSpecification_isRequired :: Lens' HyperParameterSpecification (Maybe Bool)
hyperParameterSpecification_isRequired = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HyperParameterSpecification' {Maybe Bool
isRequired :: Maybe Bool
$sel:isRequired:HyperParameterSpecification' :: HyperParameterSpecification -> Maybe Bool
isRequired} -> Maybe Bool
isRequired) (\s :: HyperParameterSpecification
s@HyperParameterSpecification' {} Maybe Bool
a -> HyperParameterSpecification
s {$sel:isRequired:HyperParameterSpecification' :: Maybe Bool
isRequired = Maybe Bool
a} :: HyperParameterSpecification)

-- | Indicates whether this hyperparameter is tunable in a hyperparameter
-- tuning job.
hyperParameterSpecification_isTunable :: Lens.Lens' HyperParameterSpecification (Prelude.Maybe Prelude.Bool)
hyperParameterSpecification_isTunable :: Lens' HyperParameterSpecification (Maybe Bool)
hyperParameterSpecification_isTunable = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HyperParameterSpecification' {Maybe Bool
isTunable :: Maybe Bool
$sel:isTunable:HyperParameterSpecification' :: HyperParameterSpecification -> Maybe Bool
isTunable} -> Maybe Bool
isTunable) (\s :: HyperParameterSpecification
s@HyperParameterSpecification' {} Maybe Bool
a -> HyperParameterSpecification
s {$sel:isTunable:HyperParameterSpecification' :: Maybe Bool
isTunable = Maybe Bool
a} :: HyperParameterSpecification)

-- | The allowed range for this hyperparameter.
hyperParameterSpecification_range :: Lens.Lens' HyperParameterSpecification (Prelude.Maybe ParameterRange)
hyperParameterSpecification_range :: Lens' HyperParameterSpecification (Maybe ParameterRange)
hyperParameterSpecification_range = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HyperParameterSpecification' {Maybe ParameterRange
range :: Maybe ParameterRange
$sel:range:HyperParameterSpecification' :: HyperParameterSpecification -> Maybe ParameterRange
range} -> Maybe ParameterRange
range) (\s :: HyperParameterSpecification
s@HyperParameterSpecification' {} Maybe ParameterRange
a -> HyperParameterSpecification
s {$sel:range:HyperParameterSpecification' :: Maybe ParameterRange
range = Maybe ParameterRange
a} :: HyperParameterSpecification)

-- | The name of this hyperparameter. The name must be unique.
hyperParameterSpecification_name :: Lens.Lens' HyperParameterSpecification Prelude.Text
hyperParameterSpecification_name :: Lens' HyperParameterSpecification Text
hyperParameterSpecification_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HyperParameterSpecification' {Text
name :: Text
$sel:name:HyperParameterSpecification' :: HyperParameterSpecification -> Text
name} -> Text
name) (\s :: HyperParameterSpecification
s@HyperParameterSpecification' {} Text
a -> HyperParameterSpecification
s {$sel:name:HyperParameterSpecification' :: Text
name = Text
a} :: HyperParameterSpecification)

-- | The type of this hyperparameter. The valid types are @Integer@,
-- @Continuous@, @Categorical@, and @FreeText@.
hyperParameterSpecification_type :: Lens.Lens' HyperParameterSpecification ParameterType
hyperParameterSpecification_type :: Lens' HyperParameterSpecification ParameterType
hyperParameterSpecification_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HyperParameterSpecification' {ParameterType
type' :: ParameterType
$sel:type':HyperParameterSpecification' :: HyperParameterSpecification -> ParameterType
type'} -> ParameterType
type') (\s :: HyperParameterSpecification
s@HyperParameterSpecification' {} ParameterType
a -> HyperParameterSpecification
s {$sel:type':HyperParameterSpecification' :: ParameterType
type' = ParameterType
a} :: HyperParameterSpecification)

instance Data.FromJSON HyperParameterSpecification where
  parseJSON :: Value -> Parser HyperParameterSpecification
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"HyperParameterSpecification"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Bool
-> Maybe Bool
-> Maybe ParameterRange
-> Text
-> ParameterType
-> HyperParameterSpecification
HyperParameterSpecification'
            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
"DefaultValue")
            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
"Description")
            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
"IsRequired")
            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
"IsTunable")
            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
"Range")
            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
"Name")
            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
"Type")
      )

instance Prelude.Hashable HyperParameterSpecification where
  hashWithSalt :: Int -> HyperParameterSpecification -> Int
hashWithSalt Int
_salt HyperParameterSpecification' {Maybe Bool
Maybe Text
Maybe ParameterRange
Text
ParameterType
type' :: ParameterType
name :: Text
range :: Maybe ParameterRange
isTunable :: Maybe Bool
isRequired :: Maybe Bool
description :: Maybe Text
defaultValue :: Maybe Text
$sel:type':HyperParameterSpecification' :: HyperParameterSpecification -> ParameterType
$sel:name:HyperParameterSpecification' :: HyperParameterSpecification -> Text
$sel:range:HyperParameterSpecification' :: HyperParameterSpecification -> Maybe ParameterRange
$sel:isTunable:HyperParameterSpecification' :: HyperParameterSpecification -> Maybe Bool
$sel:isRequired:HyperParameterSpecification' :: HyperParameterSpecification -> Maybe Bool
$sel:description:HyperParameterSpecification' :: HyperParameterSpecification -> Maybe Text
$sel:defaultValue:HyperParameterSpecification' :: HyperParameterSpecification -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
defaultValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
isRequired
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
isTunable
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ParameterRange
range
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ParameterType
type'

instance Prelude.NFData HyperParameterSpecification where
  rnf :: HyperParameterSpecification -> ()
rnf HyperParameterSpecification' {Maybe Bool
Maybe Text
Maybe ParameterRange
Text
ParameterType
type' :: ParameterType
name :: Text
range :: Maybe ParameterRange
isTunable :: Maybe Bool
isRequired :: Maybe Bool
description :: Maybe Text
defaultValue :: Maybe Text
$sel:type':HyperParameterSpecification' :: HyperParameterSpecification -> ParameterType
$sel:name:HyperParameterSpecification' :: HyperParameterSpecification -> Text
$sel:range:HyperParameterSpecification' :: HyperParameterSpecification -> Maybe ParameterRange
$sel:isTunable:HyperParameterSpecification' :: HyperParameterSpecification -> Maybe Bool
$sel:isRequired:HyperParameterSpecification' :: HyperParameterSpecification -> Maybe Bool
$sel:description:HyperParameterSpecification' :: HyperParameterSpecification -> Maybe Text
$sel:defaultValue:HyperParameterSpecification' :: HyperParameterSpecification -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
defaultValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
isRequired
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
isTunable
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ParameterRange
range
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ParameterType
type'

instance Data.ToJSON HyperParameterSpecification where
  toJSON :: HyperParameterSpecification -> Value
toJSON HyperParameterSpecification' {Maybe Bool
Maybe Text
Maybe ParameterRange
Text
ParameterType
type' :: ParameterType
name :: Text
range :: Maybe ParameterRange
isTunable :: Maybe Bool
isRequired :: Maybe Bool
description :: Maybe Text
defaultValue :: Maybe Text
$sel:type':HyperParameterSpecification' :: HyperParameterSpecification -> ParameterType
$sel:name:HyperParameterSpecification' :: HyperParameterSpecification -> Text
$sel:range:HyperParameterSpecification' :: HyperParameterSpecification -> Maybe ParameterRange
$sel:isTunable:HyperParameterSpecification' :: HyperParameterSpecification -> Maybe Bool
$sel:isRequired:HyperParameterSpecification' :: HyperParameterSpecification -> Maybe Bool
$sel:description:HyperParameterSpecification' :: HyperParameterSpecification -> Maybe Text
$sel:defaultValue:HyperParameterSpecification' :: HyperParameterSpecification -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DefaultValue" 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 Text
defaultValue,
            (Key
"Description" 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 Text
description,
            (Key
"IsRequired" 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
isRequired,
            (Key
"IsTunable" 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
isTunable,
            (Key
"Range" 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 ParameterRange
range,
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"Type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ParameterType
type')
          ]
      )