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

import qualified Amazonka.Core as Core
import Amazonka.Forecast.Types.FeaturizationMethodName
import qualified Amazonka.Lens as Lens
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
(FeaturizationMethod -> FeaturizationMethod -> Bool)
-> (FeaturizationMethod -> FeaturizationMethod -> Bool)
-> Eq FeaturizationMethod
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]
(Int -> ReadS FeaturizationMethod)
-> ReadS [FeaturizationMethod]
-> ReadPrec FeaturizationMethod
-> ReadPrec [FeaturizationMethod]
-> Read 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
(Int -> FeaturizationMethod -> ShowS)
-> (FeaturizationMethod -> String)
-> ([FeaturizationMethod] -> ShowS)
-> Show FeaturizationMethod
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. FeaturizationMethod -> Rep FeaturizationMethod x)
-> (forall x. Rep FeaturizationMethod x -> FeaturizationMethod)
-> Generic FeaturizationMethod
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' :: Maybe (HashMap Text Text)
-> FeaturizationMethodName -> FeaturizationMethod
FeaturizationMethod'
    { $sel:featurizationMethodParameters:FeaturizationMethod' :: Maybe (HashMap Text Text)
featurizationMethodParameters =
        Maybe (HashMap Text Text)
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 :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> FeaturizationMethod -> f FeaturizationMethod
featurizationMethod_featurizationMethodParameters = (FeaturizationMethod -> Maybe (HashMap Text Text))
-> (FeaturizationMethod
    -> Maybe (HashMap Text Text) -> FeaturizationMethod)
-> Lens
     FeaturizationMethod
     FeaturizationMethod
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> FeaturizationMethod -> f FeaturizationMethod)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> FeaturizationMethod
-> f FeaturizationMethod
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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 AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
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 :: (FeaturizationMethodName -> f FeaturizationMethodName)
-> FeaturizationMethod -> f FeaturizationMethod
featurizationMethod_featurizationMethodName = (FeaturizationMethod -> FeaturizationMethodName)
-> (FeaturizationMethod
    -> FeaturizationMethodName -> FeaturizationMethod)
-> Lens
     FeaturizationMethod
     FeaturizationMethod
     FeaturizationMethodName
     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 Core.FromJSON FeaturizationMethod where
  parseJSON :: Value -> Parser FeaturizationMethod
parseJSON =
    String
-> (Object -> Parser FeaturizationMethod)
-> Value
-> Parser FeaturizationMethod
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FeaturizationMethod"
      ( \Object
x ->
          Maybe (HashMap Text Text)
-> FeaturizationMethodName -> FeaturizationMethod
FeaturizationMethod'
            (Maybe (HashMap Text Text)
 -> FeaturizationMethodName -> FeaturizationMethod)
-> Parser (Maybe (HashMap Text Text))
-> Parser (FeaturizationMethodName -> FeaturizationMethod)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FeaturizationMethodParameters"
                            Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (FeaturizationMethodName -> FeaturizationMethod)
-> Parser FeaturizationMethodName -> Parser FeaturizationMethod
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser FeaturizationMethodName
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"FeaturizationMethodName")
      )

instance Prelude.Hashable FeaturizationMethod

instance Prelude.NFData FeaturizationMethod

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"FeaturizationMethodParameters" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
featurizationMethodParameters,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"FeaturizationMethodName"
                  Text -> FeaturizationMethodName -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= FeaturizationMethodName
featurizationMethodName
              )
          ]
      )