{-# 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-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.Featurization 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.FeaturizationMethod
import qualified Amazonka.Prelude as Prelude

-- | This object belongs to the CreatePredictor operation. If you created
-- your predictor with CreateAutoPredictor, see AttributeConfig.
--
-- 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
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]
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
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. 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'
    { $sel:featurizationPipeline:Featurization' :: Maybe (NonEmpty FeaturizationMethod)
featurizationPipeline =
        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 :: Lens' Featurization (Maybe (NonEmpty FeaturizationMethod))
featurization_featurizationPipeline = 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) 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 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 :: Lens' Featurization Text
featurization_attributeName = 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 Data.FromJSON Featurization where
  parseJSON :: Value -> Parser Featurization
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Featurization"
      ( \Object
x ->
          Maybe (NonEmpty FeaturizationMethod) -> Text -> Featurization
Featurization'
            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
"FeaturizationPipeline")
            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
"AttributeName")
      )

instance Prelude.Hashable Featurization where
  hashWithSalt :: Int -> Featurization -> Int
hashWithSalt Int
_salt Featurization' {Maybe (NonEmpty FeaturizationMethod)
Text
attributeName :: Text
featurizationPipeline :: Maybe (NonEmpty FeaturizationMethod)
$sel:attributeName:Featurization' :: Featurization -> Text
$sel:featurizationPipeline:Featurization' :: Featurization -> Maybe (NonEmpty FeaturizationMethod)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty FeaturizationMethod)
featurizationPipeline
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
attributeName

instance Prelude.NFData Featurization where
  rnf :: Featurization -> ()
rnf Featurization' {Maybe (NonEmpty FeaturizationMethod)
Text
attributeName :: Text
featurizationPipeline :: Maybe (NonEmpty FeaturizationMethod)
$sel:attributeName:Featurization' :: Featurization -> Text
$sel:featurizationPipeline:Featurization' :: Featurization -> Maybe (NonEmpty FeaturizationMethod)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty FeaturizationMethod)
featurizationPipeline
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
attributeName

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"FeaturizationPipeline" 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 (NonEmpty FeaturizationMethod)
featurizationPipeline,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"AttributeName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
attributeName)
          ]
      )