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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMaker.Types.HyperParameterScalingType

-- | A list of continuous hyperparameters to tune.
--
-- /See:/ 'newContinuousParameterRange' smart constructor.
data ContinuousParameterRange = ContinuousParameterRange'
  { -- | The scale that hyperparameter tuning uses to search the hyperparameter
    -- range. For information about choosing a hyperparameter scale, see
    -- <https://docs.aws.amazon.com/sagemaker/latest/dg/automatic-model-tuning-define-ranges.html#scaling-type Hyperparameter Scaling>.
    -- One of the following values:
    --
    -- [Auto]
    --     Amazon SageMaker hyperparameter tuning chooses the best scale for
    --     the hyperparameter.
    --
    -- [Linear]
    --     Hyperparameter tuning searches the values in the hyperparameter
    --     range by using a linear scale.
    --
    -- [Logarithmic]
    --     Hyperparameter tuning searches the values in the hyperparameter
    --     range by using a logarithmic scale.
    --
    --     Logarithmic scaling works only for ranges that have only values
    --     greater than 0.
    --
    -- [ReverseLogarithmic]
    --     Hyperparameter tuning searches the values in the hyperparameter
    --     range by using a reverse logarithmic scale.
    --
    --     Reverse logarithmic scaling works only for ranges that are entirely
    --     within the range 0\<=x\<1.0.
    ContinuousParameterRange -> Maybe HyperParameterScalingType
scalingType :: Prelude.Maybe HyperParameterScalingType,
    -- | The name of the continuous hyperparameter to tune.
    ContinuousParameterRange -> Text
name :: Prelude.Text,
    -- | The minimum value for the hyperparameter. The tuning job uses
    -- floating-point values between this value and @MaxValue@for tuning.
    ContinuousParameterRange -> Text
minValue :: Prelude.Text,
    -- | The maximum value for the hyperparameter. The tuning job uses
    -- floating-point values between @MinValue@ value and this value for
    -- tuning.
    ContinuousParameterRange -> Text
maxValue :: Prelude.Text
  }
  deriving (ContinuousParameterRange -> ContinuousParameterRange -> Bool
(ContinuousParameterRange -> ContinuousParameterRange -> Bool)
-> (ContinuousParameterRange -> ContinuousParameterRange -> Bool)
-> Eq ContinuousParameterRange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ContinuousParameterRange -> ContinuousParameterRange -> Bool
$c/= :: ContinuousParameterRange -> ContinuousParameterRange -> Bool
== :: ContinuousParameterRange -> ContinuousParameterRange -> Bool
$c== :: ContinuousParameterRange -> ContinuousParameterRange -> Bool
Prelude.Eq, ReadPrec [ContinuousParameterRange]
ReadPrec ContinuousParameterRange
Int -> ReadS ContinuousParameterRange
ReadS [ContinuousParameterRange]
(Int -> ReadS ContinuousParameterRange)
-> ReadS [ContinuousParameterRange]
-> ReadPrec ContinuousParameterRange
-> ReadPrec [ContinuousParameterRange]
-> Read ContinuousParameterRange
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ContinuousParameterRange]
$creadListPrec :: ReadPrec [ContinuousParameterRange]
readPrec :: ReadPrec ContinuousParameterRange
$creadPrec :: ReadPrec ContinuousParameterRange
readList :: ReadS [ContinuousParameterRange]
$creadList :: ReadS [ContinuousParameterRange]
readsPrec :: Int -> ReadS ContinuousParameterRange
$creadsPrec :: Int -> ReadS ContinuousParameterRange
Prelude.Read, Int -> ContinuousParameterRange -> ShowS
[ContinuousParameterRange] -> ShowS
ContinuousParameterRange -> String
(Int -> ContinuousParameterRange -> ShowS)
-> (ContinuousParameterRange -> String)
-> ([ContinuousParameterRange] -> ShowS)
-> Show ContinuousParameterRange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ContinuousParameterRange] -> ShowS
$cshowList :: [ContinuousParameterRange] -> ShowS
show :: ContinuousParameterRange -> String
$cshow :: ContinuousParameterRange -> String
showsPrec :: Int -> ContinuousParameterRange -> ShowS
$cshowsPrec :: Int -> ContinuousParameterRange -> ShowS
Prelude.Show, (forall x.
 ContinuousParameterRange -> Rep ContinuousParameterRange x)
-> (forall x.
    Rep ContinuousParameterRange x -> ContinuousParameterRange)
-> Generic ContinuousParameterRange
forall x.
Rep ContinuousParameterRange x -> ContinuousParameterRange
forall x.
ContinuousParameterRange -> Rep ContinuousParameterRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ContinuousParameterRange x -> ContinuousParameterRange
$cfrom :: forall x.
ContinuousParameterRange -> Rep ContinuousParameterRange x
Prelude.Generic)

-- |
-- Create a value of 'ContinuousParameterRange' 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:
--
-- 'scalingType', 'continuousParameterRange_scalingType' - The scale that hyperparameter tuning uses to search the hyperparameter
-- range. For information about choosing a hyperparameter scale, see
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/automatic-model-tuning-define-ranges.html#scaling-type Hyperparameter Scaling>.
-- One of the following values:
--
-- [Auto]
--     Amazon SageMaker hyperparameter tuning chooses the best scale for
--     the hyperparameter.
--
-- [Linear]
--     Hyperparameter tuning searches the values in the hyperparameter
--     range by using a linear scale.
--
-- [Logarithmic]
--     Hyperparameter tuning searches the values in the hyperparameter
--     range by using a logarithmic scale.
--
--     Logarithmic scaling works only for ranges that have only values
--     greater than 0.
--
-- [ReverseLogarithmic]
--     Hyperparameter tuning searches the values in the hyperparameter
--     range by using a reverse logarithmic scale.
--
--     Reverse logarithmic scaling works only for ranges that are entirely
--     within the range 0\<=x\<1.0.
--
-- 'name', 'continuousParameterRange_name' - The name of the continuous hyperparameter to tune.
--
-- 'minValue', 'continuousParameterRange_minValue' - The minimum value for the hyperparameter. The tuning job uses
-- floating-point values between this value and @MaxValue@for tuning.
--
-- 'maxValue', 'continuousParameterRange_maxValue' - The maximum value for the hyperparameter. The tuning job uses
-- floating-point values between @MinValue@ value and this value for
-- tuning.
newContinuousParameterRange ::
  -- | 'name'
  Prelude.Text ->
  -- | 'minValue'
  Prelude.Text ->
  -- | 'maxValue'
  Prelude.Text ->
  ContinuousParameterRange
newContinuousParameterRange :: Text -> Text -> Text -> ContinuousParameterRange
newContinuousParameterRange
  Text
pName_
  Text
pMinValue_
  Text
pMaxValue_ =
    ContinuousParameterRange' :: Maybe HyperParameterScalingType
-> Text -> Text -> Text -> ContinuousParameterRange
ContinuousParameterRange'
      { $sel:scalingType:ContinuousParameterRange' :: Maybe HyperParameterScalingType
scalingType =
          Maybe HyperParameterScalingType
forall a. Maybe a
Prelude.Nothing,
        $sel:name:ContinuousParameterRange' :: Text
name = Text
pName_,
        $sel:minValue:ContinuousParameterRange' :: Text
minValue = Text
pMinValue_,
        $sel:maxValue:ContinuousParameterRange' :: Text
maxValue = Text
pMaxValue_
      }

-- | The scale that hyperparameter tuning uses to search the hyperparameter
-- range. For information about choosing a hyperparameter scale, see
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/automatic-model-tuning-define-ranges.html#scaling-type Hyperparameter Scaling>.
-- One of the following values:
--
-- [Auto]
--     Amazon SageMaker hyperparameter tuning chooses the best scale for
--     the hyperparameter.
--
-- [Linear]
--     Hyperparameter tuning searches the values in the hyperparameter
--     range by using a linear scale.
--
-- [Logarithmic]
--     Hyperparameter tuning searches the values in the hyperparameter
--     range by using a logarithmic scale.
--
--     Logarithmic scaling works only for ranges that have only values
--     greater than 0.
--
-- [ReverseLogarithmic]
--     Hyperparameter tuning searches the values in the hyperparameter
--     range by using a reverse logarithmic scale.
--
--     Reverse logarithmic scaling works only for ranges that are entirely
--     within the range 0\<=x\<1.0.
continuousParameterRange_scalingType :: Lens.Lens' ContinuousParameterRange (Prelude.Maybe HyperParameterScalingType)
continuousParameterRange_scalingType :: (Maybe HyperParameterScalingType
 -> f (Maybe HyperParameterScalingType))
-> ContinuousParameterRange -> f ContinuousParameterRange
continuousParameterRange_scalingType = (ContinuousParameterRange -> Maybe HyperParameterScalingType)
-> (ContinuousParameterRange
    -> Maybe HyperParameterScalingType -> ContinuousParameterRange)
-> Lens
     ContinuousParameterRange
     ContinuousParameterRange
     (Maybe HyperParameterScalingType)
     (Maybe HyperParameterScalingType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContinuousParameterRange' {Maybe HyperParameterScalingType
scalingType :: Maybe HyperParameterScalingType
$sel:scalingType:ContinuousParameterRange' :: ContinuousParameterRange -> Maybe HyperParameterScalingType
scalingType} -> Maybe HyperParameterScalingType
scalingType) (\s :: ContinuousParameterRange
s@ContinuousParameterRange' {} Maybe HyperParameterScalingType
a -> ContinuousParameterRange
s {$sel:scalingType:ContinuousParameterRange' :: Maybe HyperParameterScalingType
scalingType = Maybe HyperParameterScalingType
a} :: ContinuousParameterRange)

-- | The name of the continuous hyperparameter to tune.
continuousParameterRange_name :: Lens.Lens' ContinuousParameterRange Prelude.Text
continuousParameterRange_name :: (Text -> f Text)
-> ContinuousParameterRange -> f ContinuousParameterRange
continuousParameterRange_name = (ContinuousParameterRange -> Text)
-> (ContinuousParameterRange -> Text -> ContinuousParameterRange)
-> Lens ContinuousParameterRange ContinuousParameterRange Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContinuousParameterRange' {Text
name :: Text
$sel:name:ContinuousParameterRange' :: ContinuousParameterRange -> Text
name} -> Text
name) (\s :: ContinuousParameterRange
s@ContinuousParameterRange' {} Text
a -> ContinuousParameterRange
s {$sel:name:ContinuousParameterRange' :: Text
name = Text
a} :: ContinuousParameterRange)

-- | The minimum value for the hyperparameter. The tuning job uses
-- floating-point values between this value and @MaxValue@for tuning.
continuousParameterRange_minValue :: Lens.Lens' ContinuousParameterRange Prelude.Text
continuousParameterRange_minValue :: (Text -> f Text)
-> ContinuousParameterRange -> f ContinuousParameterRange
continuousParameterRange_minValue = (ContinuousParameterRange -> Text)
-> (ContinuousParameterRange -> Text -> ContinuousParameterRange)
-> Lens ContinuousParameterRange ContinuousParameterRange Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContinuousParameterRange' {Text
minValue :: Text
$sel:minValue:ContinuousParameterRange' :: ContinuousParameterRange -> Text
minValue} -> Text
minValue) (\s :: ContinuousParameterRange
s@ContinuousParameterRange' {} Text
a -> ContinuousParameterRange
s {$sel:minValue:ContinuousParameterRange' :: Text
minValue = Text
a} :: ContinuousParameterRange)

-- | The maximum value for the hyperparameter. The tuning job uses
-- floating-point values between @MinValue@ value and this value for
-- tuning.
continuousParameterRange_maxValue :: Lens.Lens' ContinuousParameterRange Prelude.Text
continuousParameterRange_maxValue :: (Text -> f Text)
-> ContinuousParameterRange -> f ContinuousParameterRange
continuousParameterRange_maxValue = (ContinuousParameterRange -> Text)
-> (ContinuousParameterRange -> Text -> ContinuousParameterRange)
-> Lens ContinuousParameterRange ContinuousParameterRange Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContinuousParameterRange' {Text
maxValue :: Text
$sel:maxValue:ContinuousParameterRange' :: ContinuousParameterRange -> Text
maxValue} -> Text
maxValue) (\s :: ContinuousParameterRange
s@ContinuousParameterRange' {} Text
a -> ContinuousParameterRange
s {$sel:maxValue:ContinuousParameterRange' :: Text
maxValue = Text
a} :: ContinuousParameterRange)

instance Core.FromJSON ContinuousParameterRange where
  parseJSON :: Value -> Parser ContinuousParameterRange
parseJSON =
    String
-> (Object -> Parser ContinuousParameterRange)
-> Value
-> Parser ContinuousParameterRange
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ContinuousParameterRange"
      ( \Object
x ->
          Maybe HyperParameterScalingType
-> Text -> Text -> Text -> ContinuousParameterRange
ContinuousParameterRange'
            (Maybe HyperParameterScalingType
 -> Text -> Text -> Text -> ContinuousParameterRange)
-> Parser (Maybe HyperParameterScalingType)
-> Parser (Text -> Text -> Text -> ContinuousParameterRange)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe HyperParameterScalingType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ScalingType")
            Parser (Text -> Text -> Text -> ContinuousParameterRange)
-> Parser Text -> Parser (Text -> Text -> ContinuousParameterRange)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Name")
            Parser (Text -> Text -> ContinuousParameterRange)
-> Parser Text -> Parser (Text -> ContinuousParameterRange)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"MinValue")
            Parser (Text -> ContinuousParameterRange)
-> Parser Text -> Parser ContinuousParameterRange
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"MaxValue")
      )

instance Prelude.Hashable ContinuousParameterRange

instance Prelude.NFData ContinuousParameterRange

instance Core.ToJSON ContinuousParameterRange where
  toJSON :: ContinuousParameterRange -> Value
toJSON ContinuousParameterRange' {Maybe HyperParameterScalingType
Text
maxValue :: Text
minValue :: Text
name :: Text
scalingType :: Maybe HyperParameterScalingType
$sel:maxValue:ContinuousParameterRange' :: ContinuousParameterRange -> Text
$sel:minValue:ContinuousParameterRange' :: ContinuousParameterRange -> Text
$sel:name:ContinuousParameterRange' :: ContinuousParameterRange -> Text
$sel:scalingType:ContinuousParameterRange' :: ContinuousParameterRange -> Maybe HyperParameterScalingType
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ScalingType" Text -> HyperParameterScalingType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HyperParameterScalingType -> Pair)
-> Maybe HyperParameterScalingType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe HyperParameterScalingType
scalingType,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"MinValue" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
minValue),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"MaxValue" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
maxValue)
          ]
      )