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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Parameters that define how to split a dataset into training data and
-- testing data, and the number of iterations to perform. These parameters
-- are specified in the predefined algorithms but you can override them in
-- the CreatePredictor request.
--
-- /See:/ 'newEvaluationParameters' smart constructor.
data EvaluationParameters = EvaluationParameters'
  { -- | The point from the end of the dataset where you want to split the data
    -- for model training and testing (evaluation). Specify the value as the
    -- number of data points. The default is the value of the forecast horizon.
    -- @BackTestWindowOffset@ can be used to mimic a past virtual forecast
    -- start date. This value must be greater than or equal to the forecast
    -- horizon and less than half of the TARGET_TIME_SERIES dataset length.
    --
    -- @ForecastHorizon@ \<= @BackTestWindowOffset@ \< 1\/2 *
    -- TARGET_TIME_SERIES dataset length
    EvaluationParameters -> Maybe Int
backTestWindowOffset :: Prelude.Maybe Prelude.Int,
    -- | The number of times to split the input data. The default is 1. Valid
    -- values are 1 through 5.
    EvaluationParameters -> Maybe Int
numberOfBacktestWindows :: Prelude.Maybe Prelude.Int
  }
  deriving (EvaluationParameters -> EvaluationParameters -> Bool
(EvaluationParameters -> EvaluationParameters -> Bool)
-> (EvaluationParameters -> EvaluationParameters -> Bool)
-> Eq EvaluationParameters
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EvaluationParameters -> EvaluationParameters -> Bool
$c/= :: EvaluationParameters -> EvaluationParameters -> Bool
== :: EvaluationParameters -> EvaluationParameters -> Bool
$c== :: EvaluationParameters -> EvaluationParameters -> Bool
Prelude.Eq, ReadPrec [EvaluationParameters]
ReadPrec EvaluationParameters
Int -> ReadS EvaluationParameters
ReadS [EvaluationParameters]
(Int -> ReadS EvaluationParameters)
-> ReadS [EvaluationParameters]
-> ReadPrec EvaluationParameters
-> ReadPrec [EvaluationParameters]
-> Read EvaluationParameters
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EvaluationParameters]
$creadListPrec :: ReadPrec [EvaluationParameters]
readPrec :: ReadPrec EvaluationParameters
$creadPrec :: ReadPrec EvaluationParameters
readList :: ReadS [EvaluationParameters]
$creadList :: ReadS [EvaluationParameters]
readsPrec :: Int -> ReadS EvaluationParameters
$creadsPrec :: Int -> ReadS EvaluationParameters
Prelude.Read, Int -> EvaluationParameters -> ShowS
[EvaluationParameters] -> ShowS
EvaluationParameters -> String
(Int -> EvaluationParameters -> ShowS)
-> (EvaluationParameters -> String)
-> ([EvaluationParameters] -> ShowS)
-> Show EvaluationParameters
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EvaluationParameters] -> ShowS
$cshowList :: [EvaluationParameters] -> ShowS
show :: EvaluationParameters -> String
$cshow :: EvaluationParameters -> String
showsPrec :: Int -> EvaluationParameters -> ShowS
$cshowsPrec :: Int -> EvaluationParameters -> ShowS
Prelude.Show, (forall x. EvaluationParameters -> Rep EvaluationParameters x)
-> (forall x. Rep EvaluationParameters x -> EvaluationParameters)
-> Generic EvaluationParameters
forall x. Rep EvaluationParameters x -> EvaluationParameters
forall x. EvaluationParameters -> Rep EvaluationParameters x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EvaluationParameters x -> EvaluationParameters
$cfrom :: forall x. EvaluationParameters -> Rep EvaluationParameters x
Prelude.Generic)

-- |
-- Create a value of 'EvaluationParameters' 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:
--
-- 'backTestWindowOffset', 'evaluationParameters_backTestWindowOffset' - The point from the end of the dataset where you want to split the data
-- for model training and testing (evaluation). Specify the value as the
-- number of data points. The default is the value of the forecast horizon.
-- @BackTestWindowOffset@ can be used to mimic a past virtual forecast
-- start date. This value must be greater than or equal to the forecast
-- horizon and less than half of the TARGET_TIME_SERIES dataset length.
--
-- @ForecastHorizon@ \<= @BackTestWindowOffset@ \< 1\/2 *
-- TARGET_TIME_SERIES dataset length
--
-- 'numberOfBacktestWindows', 'evaluationParameters_numberOfBacktestWindows' - The number of times to split the input data. The default is 1. Valid
-- values are 1 through 5.
newEvaluationParameters ::
  EvaluationParameters
newEvaluationParameters :: EvaluationParameters
newEvaluationParameters =
  EvaluationParameters' :: Maybe Int -> Maybe Int -> EvaluationParameters
EvaluationParameters'
    { $sel:backTestWindowOffset:EvaluationParameters' :: Maybe Int
backTestWindowOffset =
        Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:numberOfBacktestWindows:EvaluationParameters' :: Maybe Int
numberOfBacktestWindows = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The point from the end of the dataset where you want to split the data
-- for model training and testing (evaluation). Specify the value as the
-- number of data points. The default is the value of the forecast horizon.
-- @BackTestWindowOffset@ can be used to mimic a past virtual forecast
-- start date. This value must be greater than or equal to the forecast
-- horizon and less than half of the TARGET_TIME_SERIES dataset length.
--
-- @ForecastHorizon@ \<= @BackTestWindowOffset@ \< 1\/2 *
-- TARGET_TIME_SERIES dataset length
evaluationParameters_backTestWindowOffset :: Lens.Lens' EvaluationParameters (Prelude.Maybe Prelude.Int)
evaluationParameters_backTestWindowOffset :: (Maybe Int -> f (Maybe Int))
-> EvaluationParameters -> f EvaluationParameters
evaluationParameters_backTestWindowOffset = (EvaluationParameters -> Maybe Int)
-> (EvaluationParameters -> Maybe Int -> EvaluationParameters)
-> Lens
     EvaluationParameters EvaluationParameters (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EvaluationParameters' {Maybe Int
backTestWindowOffset :: Maybe Int
$sel:backTestWindowOffset:EvaluationParameters' :: EvaluationParameters -> Maybe Int
backTestWindowOffset} -> Maybe Int
backTestWindowOffset) (\s :: EvaluationParameters
s@EvaluationParameters' {} Maybe Int
a -> EvaluationParameters
s {$sel:backTestWindowOffset:EvaluationParameters' :: Maybe Int
backTestWindowOffset = Maybe Int
a} :: EvaluationParameters)

-- | The number of times to split the input data. The default is 1. Valid
-- values are 1 through 5.
evaluationParameters_numberOfBacktestWindows :: Lens.Lens' EvaluationParameters (Prelude.Maybe Prelude.Int)
evaluationParameters_numberOfBacktestWindows :: (Maybe Int -> f (Maybe Int))
-> EvaluationParameters -> f EvaluationParameters
evaluationParameters_numberOfBacktestWindows = (EvaluationParameters -> Maybe Int)
-> (EvaluationParameters -> Maybe Int -> EvaluationParameters)
-> Lens
     EvaluationParameters EvaluationParameters (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EvaluationParameters' {Maybe Int
numberOfBacktestWindows :: Maybe Int
$sel:numberOfBacktestWindows:EvaluationParameters' :: EvaluationParameters -> Maybe Int
numberOfBacktestWindows} -> Maybe Int
numberOfBacktestWindows) (\s :: EvaluationParameters
s@EvaluationParameters' {} Maybe Int
a -> EvaluationParameters
s {$sel:numberOfBacktestWindows:EvaluationParameters' :: Maybe Int
numberOfBacktestWindows = Maybe Int
a} :: EvaluationParameters)

instance Core.FromJSON EvaluationParameters where
  parseJSON :: Value -> Parser EvaluationParameters
parseJSON =
    String
-> (Object -> Parser EvaluationParameters)
-> Value
-> Parser EvaluationParameters
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EvaluationParameters"
      ( \Object
x ->
          Maybe Int -> Maybe Int -> EvaluationParameters
EvaluationParameters'
            (Maybe Int -> Maybe Int -> EvaluationParameters)
-> Parser (Maybe Int) -> Parser (Maybe Int -> EvaluationParameters)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"BackTestWindowOffset")
            Parser (Maybe Int -> EvaluationParameters)
-> Parser (Maybe Int) -> Parser EvaluationParameters
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"NumberOfBacktestWindows")
      )

instance Prelude.Hashable EvaluationParameters

instance Prelude.NFData EvaluationParameters

instance Core.ToJSON EvaluationParameters where
  toJSON :: EvaluationParameters -> Value
toJSON EvaluationParameters' {Maybe Int
numberOfBacktestWindows :: Maybe Int
backTestWindowOffset :: Maybe Int
$sel:numberOfBacktestWindows:EvaluationParameters' :: EvaluationParameters -> Maybe Int
$sel:backTestWindowOffset:EvaluationParameters' :: EvaluationParameters -> Maybe Int
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"BackTestWindowOffset" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
backTestWindowOffset,
            (Text
"NumberOfBacktestWindows" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
numberOfBacktestWindows
          ]
      )