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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Forecast.Types.FeaturizationMethodName
import qualified Amazonka.Prelude as Prelude

-- | Provides information about the method that featurizes (transforms) a
-- dataset field. The method is part of the @FeaturizationPipeline@ of the
-- Featurization object.
--
-- The following is an example of how you specify a @FeaturizationMethod@
-- object.
--
-- @{@
--
-- @\"FeaturizationMethodName\": \"filling\",@
--
-- @\"FeaturizationMethodParameters\": {\"aggregation\": \"sum\", \"middlefill\": \"zero\", \"backfill\": \"zero\"}@
--
-- @}@
--
-- /See:/ 'newFeaturizationMethod' smart constructor.
data FeaturizationMethod = FeaturizationMethod'
  { -- | The method parameters (key-value pairs), which are a map of override
    -- parameters. Specify these parameters to override the default values.
    -- Related Time Series attributes do not accept aggregation parameters.
    --
    -- The following list shows the parameters and their valid values for the
    -- \"filling\" featurization method for a __Target Time Series__ dataset.
    -- Bold signifies the default value.
    --
    -- -   @aggregation@: __sum__, @avg@, @first@, @min@, @max@
    --
    -- -   @frontfill@: __none__
    --
    -- -   @middlefill@: __zero__, @nan@ (not a number), @value@, @median@,
    --     @mean@, @min@, @max@
    --
    -- -   @backfill@: __zero__, @nan@, @value@, @median@, @mean@, @min@, @max@
    --
    -- The following list shows the parameters and their valid values for a
    -- __Related Time Series__ featurization method (there are no defaults):
    --
    -- -   @middlefill@: @zero@, @value@, @median@, @mean@, @min@, @max@
    --
    -- -   @backfill@: @zero@, @value@, @median@, @mean@, @min@, @max@
    --
    -- -   @futurefill@: @zero@, @value@, @median@, @mean@, @min@, @max@
    --
    -- To set a filling method to a specific value, set the fill parameter to
    -- @value@ and define the value in a corresponding @_value@ parameter. For
    -- example, to set backfilling to a value of 2, include the following:
    -- @\"backfill\": \"value\"@ and @\"backfill_value\":\"2\"@.
    FeaturizationMethod -> Maybe (HashMap Text Text)
featurizationMethodParameters :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The name of the method. The \"filling\" method is the only supported
    -- method.
    FeaturizationMethod -> FeaturizationMethodName
featurizationMethodName :: FeaturizationMethodName
  }
  deriving (FeaturizationMethod -> FeaturizationMethod -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FeaturizationMethod -> FeaturizationMethod -> Bool
$c/= :: FeaturizationMethod -> FeaturizationMethod -> Bool
== :: FeaturizationMethod -> FeaturizationMethod -> Bool
$c== :: FeaturizationMethod -> FeaturizationMethod -> Bool
Prelude.Eq, ReadPrec [FeaturizationMethod]
ReadPrec FeaturizationMethod
Int -> ReadS FeaturizationMethod
ReadS [FeaturizationMethod]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FeaturizationMethod]
$creadListPrec :: ReadPrec [FeaturizationMethod]
readPrec :: ReadPrec FeaturizationMethod
$creadPrec :: ReadPrec FeaturizationMethod
readList :: ReadS [FeaturizationMethod]
$creadList :: ReadS [FeaturizationMethod]
readsPrec :: Int -> ReadS FeaturizationMethod
$creadsPrec :: Int -> ReadS FeaturizationMethod
Prelude.Read, Int -> FeaturizationMethod -> ShowS
[FeaturizationMethod] -> ShowS
FeaturizationMethod -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FeaturizationMethod] -> ShowS
$cshowList :: [FeaturizationMethod] -> ShowS
show :: FeaturizationMethod -> String
$cshow :: FeaturizationMethod -> String
showsPrec :: Int -> FeaturizationMethod -> ShowS
$cshowsPrec :: Int -> FeaturizationMethod -> ShowS
Prelude.Show, forall x. Rep FeaturizationMethod x -> FeaturizationMethod
forall x. FeaturizationMethod -> Rep FeaturizationMethod x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FeaturizationMethod x -> FeaturizationMethod
$cfrom :: forall x. FeaturizationMethod -> Rep FeaturizationMethod x
Prelude.Generic)

-- |
-- Create a value of 'FeaturizationMethod' 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:
--
-- 'featurizationMethodParameters', 'featurizationMethod_featurizationMethodParameters' - The method parameters (key-value pairs), which are a map of override
-- parameters. Specify these parameters to override the default values.
-- Related Time Series attributes do not accept aggregation parameters.
--
-- The following list shows the parameters and their valid values for the
-- \"filling\" featurization method for a __Target Time Series__ dataset.
-- Bold signifies the default value.
--
-- -   @aggregation@: __sum__, @avg@, @first@, @min@, @max@
--
-- -   @frontfill@: __none__
--
-- -   @middlefill@: __zero__, @nan@ (not a number), @value@, @median@,
--     @mean@, @min@, @max@
--
-- -   @backfill@: __zero__, @nan@, @value@, @median@, @mean@, @min@, @max@
--
-- The following list shows the parameters and their valid values for a
-- __Related Time Series__ featurization method (there are no defaults):
--
-- -   @middlefill@: @zero@, @value@, @median@, @mean@, @min@, @max@
--
-- -   @backfill@: @zero@, @value@, @median@, @mean@, @min@, @max@
--
-- -   @futurefill@: @zero@, @value@, @median@, @mean@, @min@, @max@
--
-- To set a filling method to a specific value, set the fill parameter to
-- @value@ and define the value in a corresponding @_value@ parameter. For
-- example, to set backfilling to a value of 2, include the following:
-- @\"backfill\": \"value\"@ and @\"backfill_value\":\"2\"@.
--
-- 'featurizationMethodName', 'featurizationMethod_featurizationMethodName' - The name of the method. The \"filling\" method is the only supported
-- method.
newFeaturizationMethod ::
  -- | 'featurizationMethodName'
  FeaturizationMethodName ->
  FeaturizationMethod
newFeaturizationMethod :: FeaturizationMethodName -> FeaturizationMethod
newFeaturizationMethod FeaturizationMethodName
pFeaturizationMethodName_ =
  FeaturizationMethod'
    { $sel:featurizationMethodParameters:FeaturizationMethod' :: Maybe (HashMap Text Text)
featurizationMethodParameters =
        forall a. Maybe a
Prelude.Nothing,
      $sel:featurizationMethodName:FeaturizationMethod' :: FeaturizationMethodName
featurizationMethodName = FeaturizationMethodName
pFeaturizationMethodName_
    }

-- | The method parameters (key-value pairs), which are a map of override
-- parameters. Specify these parameters to override the default values.
-- Related Time Series attributes do not accept aggregation parameters.
--
-- The following list shows the parameters and their valid values for the
-- \"filling\" featurization method for a __Target Time Series__ dataset.
-- Bold signifies the default value.
--
-- -   @aggregation@: __sum__, @avg@, @first@, @min@, @max@
--
-- -   @frontfill@: __none__
--
-- -   @middlefill@: __zero__, @nan@ (not a number), @value@, @median@,
--     @mean@, @min@, @max@
--
-- -   @backfill@: __zero__, @nan@, @value@, @median@, @mean@, @min@, @max@
--
-- The following list shows the parameters and their valid values for a
-- __Related Time Series__ featurization method (there are no defaults):
--
-- -   @middlefill@: @zero@, @value@, @median@, @mean@, @min@, @max@
--
-- -   @backfill@: @zero@, @value@, @median@, @mean@, @min@, @max@
--
-- -   @futurefill@: @zero@, @value@, @median@, @mean@, @min@, @max@
--
-- To set a filling method to a specific value, set the fill parameter to
-- @value@ and define the value in a corresponding @_value@ parameter. For
-- example, to set backfilling to a value of 2, include the following:
-- @\"backfill\": \"value\"@ and @\"backfill_value\":\"2\"@.
featurizationMethod_featurizationMethodParameters :: Lens.Lens' FeaturizationMethod (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
featurizationMethod_featurizationMethodParameters :: Lens' FeaturizationMethod (Maybe (HashMap Text Text))
featurizationMethod_featurizationMethodParameters = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FeaturizationMethod' {Maybe (HashMap Text Text)
featurizationMethodParameters :: Maybe (HashMap Text Text)
$sel:featurizationMethodParameters:FeaturizationMethod' :: FeaturizationMethod -> Maybe (HashMap Text Text)
featurizationMethodParameters} -> Maybe (HashMap Text Text)
featurizationMethodParameters) (\s :: FeaturizationMethod
s@FeaturizationMethod' {} Maybe (HashMap Text Text)
a -> FeaturizationMethod
s {$sel:featurizationMethodParameters:FeaturizationMethod' :: Maybe (HashMap Text Text)
featurizationMethodParameters = Maybe (HashMap Text Text)
a} :: FeaturizationMethod) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the method. The \"filling\" method is the only supported
-- method.
featurizationMethod_featurizationMethodName :: Lens.Lens' FeaturizationMethod FeaturizationMethodName
featurizationMethod_featurizationMethodName :: Lens' FeaturizationMethod FeaturizationMethodName
featurizationMethod_featurizationMethodName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FeaturizationMethod' {FeaturizationMethodName
featurizationMethodName :: FeaturizationMethodName
$sel:featurizationMethodName:FeaturizationMethod' :: FeaturizationMethod -> FeaturizationMethodName
featurizationMethodName} -> FeaturizationMethodName
featurizationMethodName) (\s :: FeaturizationMethod
s@FeaturizationMethod' {} FeaturizationMethodName
a -> FeaturizationMethod
s {$sel:featurizationMethodName:FeaturizationMethod' :: FeaturizationMethodName
featurizationMethodName = FeaturizationMethodName
a} :: FeaturizationMethod)

instance Data.FromJSON FeaturizationMethod where
  parseJSON :: Value -> Parser FeaturizationMethod
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FeaturizationMethod"
      ( \Object
x ->
          Maybe (HashMap Text Text)
-> FeaturizationMethodName -> FeaturizationMethod
FeaturizationMethod'
            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
"FeaturizationMethodParameters"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            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
"FeaturizationMethodName")
      )

instance Prelude.Hashable FeaturizationMethod where
  hashWithSalt :: Int -> FeaturizationMethod -> Int
hashWithSalt Int
_salt FeaturizationMethod' {Maybe (HashMap Text Text)
FeaturizationMethodName
featurizationMethodName :: FeaturizationMethodName
featurizationMethodParameters :: Maybe (HashMap Text Text)
$sel:featurizationMethodName:FeaturizationMethod' :: FeaturizationMethod -> FeaturizationMethodName
$sel:featurizationMethodParameters:FeaturizationMethod' :: FeaturizationMethod -> Maybe (HashMap Text Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
featurizationMethodParameters
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` FeaturizationMethodName
featurizationMethodName

instance Prelude.NFData FeaturizationMethod where
  rnf :: FeaturizationMethod -> ()
rnf FeaturizationMethod' {Maybe (HashMap Text Text)
FeaturizationMethodName
featurizationMethodName :: FeaturizationMethodName
featurizationMethodParameters :: Maybe (HashMap Text Text)
$sel:featurizationMethodName:FeaturizationMethod' :: FeaturizationMethod -> FeaturizationMethodName
$sel:featurizationMethodParameters:FeaturizationMethod' :: FeaturizationMethod -> Maybe (HashMap Text Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
featurizationMethodParameters
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf FeaturizationMethodName
featurizationMethodName

instance Data.ToJSON FeaturizationMethod where
  toJSON :: FeaturizationMethod -> Value
toJSON FeaturizationMethod' {Maybe (HashMap Text Text)
FeaturizationMethodName
featurizationMethodName :: FeaturizationMethodName
featurizationMethodParameters :: Maybe (HashMap Text Text)
$sel:featurizationMethodName:FeaturizationMethod' :: FeaturizationMethod -> FeaturizationMethodName
$sel:featurizationMethodParameters:FeaturizationMethod' :: FeaturizationMethod -> Maybe (HashMap Text Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"FeaturizationMethodParameters" 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 (HashMap Text Text)
featurizationMethodParameters,
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"FeaturizationMethodName"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= FeaturizationMethodName
featurizationMethodName
              )
          ]
      )