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

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

-- | Provides featurization (transformation) information for a dataset field.
-- This object is part of the FeaturizationConfig object.
--
-- For example:
--
-- @{@
--
-- @\"AttributeName\": \"demand\",@
--
-- @FeaturizationPipeline [ {@
--
-- @\"FeaturizationMethodName\": \"filling\",@
--
-- @\"FeaturizationMethodParameters\": {\"aggregation\": \"avg\", \"backfill\": \"nan\"}@
--
-- @} ]@
--
-- @}@
--
-- /See:/ 'newFeaturization' smart constructor.
data Featurization = Featurization'
  { -- | An array of one @FeaturizationMethod@ object that specifies the feature
    -- transformation method.
    Featurization -> Maybe (NonEmpty FeaturizationMethod)
featurizationPipeline :: Prelude.Maybe (Prelude.NonEmpty FeaturizationMethod),
    -- | The name of the schema attribute that specifies the data field to be
    -- featurized. Amazon Forecast supports the target field of the
    -- @TARGET_TIME_SERIES@ and the @RELATED_TIME_SERIES@ datasets. For
    -- example, for the @RETAIL@ domain, the target is @demand@, and for the
    -- @CUSTOM@ domain, the target is @target_value@. For more information, see
    -- howitworks-missing-values.
    Featurization -> Text
attributeName :: Prelude.Text
  }
  deriving (Featurization -> Featurization -> Bool
(Featurization -> Featurization -> Bool)
-> (Featurization -> Featurization -> Bool) -> Eq Featurization
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Featurization -> Featurization -> Bool
$c/= :: Featurization -> Featurization -> Bool
== :: Featurization -> Featurization -> Bool
$c== :: Featurization -> Featurization -> Bool
Prelude.Eq, ReadPrec [Featurization]
ReadPrec Featurization
Int -> ReadS Featurization
ReadS [Featurization]
(Int -> ReadS Featurization)
-> ReadS [Featurization]
-> ReadPrec Featurization
-> ReadPrec [Featurization]
-> Read Featurization
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Featurization]
$creadListPrec :: ReadPrec [Featurization]
readPrec :: ReadPrec Featurization
$creadPrec :: ReadPrec Featurization
readList :: ReadS [Featurization]
$creadList :: ReadS [Featurization]
readsPrec :: Int -> ReadS Featurization
$creadsPrec :: Int -> ReadS Featurization
Prelude.Read, Int -> Featurization -> ShowS
[Featurization] -> ShowS
Featurization -> String
(Int -> Featurization -> ShowS)
-> (Featurization -> String)
-> ([Featurization] -> ShowS)
-> Show Featurization
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Featurization] -> ShowS
$cshowList :: [Featurization] -> ShowS
show :: Featurization -> String
$cshow :: Featurization -> String
showsPrec :: Int -> Featurization -> ShowS
$cshowsPrec :: Int -> Featurization -> ShowS
Prelude.Show, (forall x. Featurization -> Rep Featurization x)
-> (forall x. Rep Featurization x -> Featurization)
-> Generic Featurization
forall x. Rep Featurization x -> Featurization
forall x. Featurization -> Rep Featurization x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Featurization x -> Featurization
$cfrom :: forall x. Featurization -> Rep Featurization x
Prelude.Generic)

-- |
-- Create a value of 'Featurization' 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:
--
-- 'featurizationPipeline', 'featurization_featurizationPipeline' - An array of one @FeaturizationMethod@ object that specifies the feature
-- transformation method.
--
-- 'attributeName', 'featurization_attributeName' - The name of the schema attribute that specifies the data field to be
-- featurized. Amazon Forecast supports the target field of the
-- @TARGET_TIME_SERIES@ and the @RELATED_TIME_SERIES@ datasets. For
-- example, for the @RETAIL@ domain, the target is @demand@, and for the
-- @CUSTOM@ domain, the target is @target_value@. For more information, see
-- howitworks-missing-values.
newFeaturization ::
  -- | 'attributeName'
  Prelude.Text ->
  Featurization
newFeaturization :: Text -> Featurization
newFeaturization Text
pAttributeName_ =
  Featurization' :: Maybe (NonEmpty FeaturizationMethod) -> Text -> Featurization
Featurization'
    { $sel:featurizationPipeline:Featurization' :: Maybe (NonEmpty FeaturizationMethod)
featurizationPipeline =
        Maybe (NonEmpty FeaturizationMethod)
forall a. Maybe a
Prelude.Nothing,
      $sel:attributeName:Featurization' :: Text
attributeName = Text
pAttributeName_
    }

-- | An array of one @FeaturizationMethod@ object that specifies the feature
-- transformation method.
featurization_featurizationPipeline :: Lens.Lens' Featurization (Prelude.Maybe (Prelude.NonEmpty FeaturizationMethod))
featurization_featurizationPipeline :: (Maybe (NonEmpty FeaturizationMethod)
 -> f (Maybe (NonEmpty FeaturizationMethod)))
-> Featurization -> f Featurization
featurization_featurizationPipeline = (Featurization -> Maybe (NonEmpty FeaturizationMethod))
-> (Featurization
    -> Maybe (NonEmpty FeaturizationMethod) -> Featurization)
-> Lens
     Featurization
     Featurization
     (Maybe (NonEmpty FeaturizationMethod))
     (Maybe (NonEmpty FeaturizationMethod))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Featurization' {Maybe (NonEmpty FeaturizationMethod)
featurizationPipeline :: Maybe (NonEmpty FeaturizationMethod)
$sel:featurizationPipeline:Featurization' :: Featurization -> Maybe (NonEmpty FeaturizationMethod)
featurizationPipeline} -> Maybe (NonEmpty FeaturizationMethod)
featurizationPipeline) (\s :: Featurization
s@Featurization' {} Maybe (NonEmpty FeaturizationMethod)
a -> Featurization
s {$sel:featurizationPipeline:Featurization' :: Maybe (NonEmpty FeaturizationMethod)
featurizationPipeline = Maybe (NonEmpty FeaturizationMethod)
a} :: Featurization) ((Maybe (NonEmpty FeaturizationMethod)
  -> f (Maybe (NonEmpty FeaturizationMethod)))
 -> Featurization -> f Featurization)
-> ((Maybe (NonEmpty FeaturizationMethod)
     -> f (Maybe (NonEmpty FeaturizationMethod)))
    -> Maybe (NonEmpty FeaturizationMethod)
    -> f (Maybe (NonEmpty FeaturizationMethod)))
-> (Maybe (NonEmpty FeaturizationMethod)
    -> f (Maybe (NonEmpty FeaturizationMethod)))
-> Featurization
-> f Featurization
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty FeaturizationMethod)
  (NonEmpty FeaturizationMethod)
  (NonEmpty FeaturizationMethod)
  (NonEmpty FeaturizationMethod)
-> Iso
     (Maybe (NonEmpty FeaturizationMethod))
     (Maybe (NonEmpty FeaturizationMethod))
     (Maybe (NonEmpty FeaturizationMethod))
     (Maybe (NonEmpty FeaturizationMethod))
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
  (NonEmpty FeaturizationMethod)
  (NonEmpty FeaturizationMethod)
  (NonEmpty FeaturizationMethod)
  (NonEmpty FeaturizationMethod)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the schema attribute that specifies the data field to be
-- featurized. Amazon Forecast supports the target field of the
-- @TARGET_TIME_SERIES@ and the @RELATED_TIME_SERIES@ datasets. For
-- example, for the @RETAIL@ domain, the target is @demand@, and for the
-- @CUSTOM@ domain, the target is @target_value@. For more information, see
-- howitworks-missing-values.
featurization_attributeName :: Lens.Lens' Featurization Prelude.Text
featurization_attributeName :: (Text -> f Text) -> Featurization -> f Featurization
featurization_attributeName = (Featurization -> Text)
-> (Featurization -> Text -> Featurization)
-> Lens Featurization Featurization Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Featurization' {Text
attributeName :: Text
$sel:attributeName:Featurization' :: Featurization -> Text
attributeName} -> Text
attributeName) (\s :: Featurization
s@Featurization' {} Text
a -> Featurization
s {$sel:attributeName:Featurization' :: Text
attributeName = Text
a} :: Featurization)

instance Core.FromJSON Featurization where
  parseJSON :: Value -> Parser Featurization
parseJSON =
    String
-> (Object -> Parser Featurization)
-> Value
-> Parser Featurization
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Featurization"
      ( \Object
x ->
          Maybe (NonEmpty FeaturizationMethod) -> Text -> Featurization
Featurization'
            (Maybe (NonEmpty FeaturizationMethod) -> Text -> Featurization)
-> Parser (Maybe (NonEmpty FeaturizationMethod))
-> Parser (Text -> Featurization)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (NonEmpty FeaturizationMethod))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FeaturizationPipeline")
            Parser (Text -> Featurization)
-> Parser Text -> Parser Featurization
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
"AttributeName")
      )

instance Prelude.Hashable Featurization

instance Prelude.NFData Featurization

instance Core.ToJSON Featurization where
  toJSON :: Featurization -> Value
toJSON Featurization' {Maybe (NonEmpty FeaturizationMethod)
Text
attributeName :: Text
featurizationPipeline :: Maybe (NonEmpty FeaturizationMethod)
$sel:attributeName:Featurization' :: Featurization -> Text
$sel:featurizationPipeline:Featurization' :: Featurization -> Maybe (NonEmpty FeaturizationMethod)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"FeaturizationPipeline" Text -> NonEmpty FeaturizationMethod -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NonEmpty FeaturizationMethod -> Pair)
-> Maybe (NonEmpty FeaturizationMethod) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty FeaturizationMethod)
featurizationPipeline,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"AttributeName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
attributeName)
          ]
      )