{-# 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.WindowSummary
-- 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.WindowSummary 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.EvaluationType
import Amazonka.Forecast.Types.Metrics
import qualified Amazonka.Prelude as Prelude

-- | The metrics for a time range within the evaluation portion of a dataset.
-- This object is part of the EvaluationResult object.
--
-- The @TestWindowStart@ and @TestWindowEnd@ parameters are determined by
-- the @BackTestWindowOffset@ parameter of the EvaluationParameters object.
--
-- /See:/ 'newWindowSummary' smart constructor.
data WindowSummary = WindowSummary'
  { -- | The type of evaluation.
    --
    -- -   @SUMMARY@ - The average metrics across all windows.
    --
    -- -   @COMPUTED@ - The metrics for the specified window.
    WindowSummary -> Maybe EvaluationType
evaluationType :: Prelude.Maybe EvaluationType,
    -- | The number of data points within the window.
    WindowSummary -> Maybe Int
itemCount :: Prelude.Maybe Prelude.Int,
    -- | Provides metrics used to evaluate the performance of a predictor.
    WindowSummary -> Maybe Metrics
metrics :: Prelude.Maybe Metrics,
    -- | The timestamp that defines the end of the window.
    WindowSummary -> Maybe POSIX
testWindowEnd :: Prelude.Maybe Data.POSIX,
    -- | The timestamp that defines the start of the window.
    WindowSummary -> Maybe POSIX
testWindowStart :: Prelude.Maybe Data.POSIX
  }
  deriving (WindowSummary -> WindowSummary -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WindowSummary -> WindowSummary -> Bool
$c/= :: WindowSummary -> WindowSummary -> Bool
== :: WindowSummary -> WindowSummary -> Bool
$c== :: WindowSummary -> WindowSummary -> Bool
Prelude.Eq, ReadPrec [WindowSummary]
ReadPrec WindowSummary
Int -> ReadS WindowSummary
ReadS [WindowSummary]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WindowSummary]
$creadListPrec :: ReadPrec [WindowSummary]
readPrec :: ReadPrec WindowSummary
$creadPrec :: ReadPrec WindowSummary
readList :: ReadS [WindowSummary]
$creadList :: ReadS [WindowSummary]
readsPrec :: Int -> ReadS WindowSummary
$creadsPrec :: Int -> ReadS WindowSummary
Prelude.Read, Int -> WindowSummary -> ShowS
[WindowSummary] -> ShowS
WindowSummary -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WindowSummary] -> ShowS
$cshowList :: [WindowSummary] -> ShowS
show :: WindowSummary -> String
$cshow :: WindowSummary -> String
showsPrec :: Int -> WindowSummary -> ShowS
$cshowsPrec :: Int -> WindowSummary -> ShowS
Prelude.Show, forall x. Rep WindowSummary x -> WindowSummary
forall x. WindowSummary -> Rep WindowSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WindowSummary x -> WindowSummary
$cfrom :: forall x. WindowSummary -> Rep WindowSummary x
Prelude.Generic)

-- |
-- Create a value of 'WindowSummary' 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:
--
-- 'evaluationType', 'windowSummary_evaluationType' - The type of evaluation.
--
-- -   @SUMMARY@ - The average metrics across all windows.
--
-- -   @COMPUTED@ - The metrics for the specified window.
--
-- 'itemCount', 'windowSummary_itemCount' - The number of data points within the window.
--
-- 'metrics', 'windowSummary_metrics' - Provides metrics used to evaluate the performance of a predictor.
--
-- 'testWindowEnd', 'windowSummary_testWindowEnd' - The timestamp that defines the end of the window.
--
-- 'testWindowStart', 'windowSummary_testWindowStart' - The timestamp that defines the start of the window.
newWindowSummary ::
  WindowSummary
newWindowSummary :: WindowSummary
newWindowSummary =
  WindowSummary'
    { $sel:evaluationType:WindowSummary' :: Maybe EvaluationType
evaluationType = forall a. Maybe a
Prelude.Nothing,
      $sel:itemCount:WindowSummary' :: Maybe Int
itemCount = forall a. Maybe a
Prelude.Nothing,
      $sel:metrics:WindowSummary' :: Maybe Metrics
metrics = forall a. Maybe a
Prelude.Nothing,
      $sel:testWindowEnd:WindowSummary' :: Maybe POSIX
testWindowEnd = forall a. Maybe a
Prelude.Nothing,
      $sel:testWindowStart:WindowSummary' :: Maybe POSIX
testWindowStart = forall a. Maybe a
Prelude.Nothing
    }

-- | The type of evaluation.
--
-- -   @SUMMARY@ - The average metrics across all windows.
--
-- -   @COMPUTED@ - The metrics for the specified window.
windowSummary_evaluationType :: Lens.Lens' WindowSummary (Prelude.Maybe EvaluationType)
windowSummary_evaluationType :: Lens' WindowSummary (Maybe EvaluationType)
windowSummary_evaluationType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WindowSummary' {Maybe EvaluationType
evaluationType :: Maybe EvaluationType
$sel:evaluationType:WindowSummary' :: WindowSummary -> Maybe EvaluationType
evaluationType} -> Maybe EvaluationType
evaluationType) (\s :: WindowSummary
s@WindowSummary' {} Maybe EvaluationType
a -> WindowSummary
s {$sel:evaluationType:WindowSummary' :: Maybe EvaluationType
evaluationType = Maybe EvaluationType
a} :: WindowSummary)

-- | The number of data points within the window.
windowSummary_itemCount :: Lens.Lens' WindowSummary (Prelude.Maybe Prelude.Int)
windowSummary_itemCount :: Lens' WindowSummary (Maybe Int)
windowSummary_itemCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WindowSummary' {Maybe Int
itemCount :: Maybe Int
$sel:itemCount:WindowSummary' :: WindowSummary -> Maybe Int
itemCount} -> Maybe Int
itemCount) (\s :: WindowSummary
s@WindowSummary' {} Maybe Int
a -> WindowSummary
s {$sel:itemCount:WindowSummary' :: Maybe Int
itemCount = Maybe Int
a} :: WindowSummary)

-- | Provides metrics used to evaluate the performance of a predictor.
windowSummary_metrics :: Lens.Lens' WindowSummary (Prelude.Maybe Metrics)
windowSummary_metrics :: Lens' WindowSummary (Maybe Metrics)
windowSummary_metrics = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WindowSummary' {Maybe Metrics
metrics :: Maybe Metrics
$sel:metrics:WindowSummary' :: WindowSummary -> Maybe Metrics
metrics} -> Maybe Metrics
metrics) (\s :: WindowSummary
s@WindowSummary' {} Maybe Metrics
a -> WindowSummary
s {$sel:metrics:WindowSummary' :: Maybe Metrics
metrics = Maybe Metrics
a} :: WindowSummary)

-- | The timestamp that defines the end of the window.
windowSummary_testWindowEnd :: Lens.Lens' WindowSummary (Prelude.Maybe Prelude.UTCTime)
windowSummary_testWindowEnd :: Lens' WindowSummary (Maybe UTCTime)
windowSummary_testWindowEnd = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WindowSummary' {Maybe POSIX
testWindowEnd :: Maybe POSIX
$sel:testWindowEnd:WindowSummary' :: WindowSummary -> Maybe POSIX
testWindowEnd} -> Maybe POSIX
testWindowEnd) (\s :: WindowSummary
s@WindowSummary' {} Maybe POSIX
a -> WindowSummary
s {$sel:testWindowEnd:WindowSummary' :: Maybe POSIX
testWindowEnd = Maybe POSIX
a} :: WindowSummary) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The timestamp that defines the start of the window.
windowSummary_testWindowStart :: Lens.Lens' WindowSummary (Prelude.Maybe Prelude.UTCTime)
windowSummary_testWindowStart :: Lens' WindowSummary (Maybe UTCTime)
windowSummary_testWindowStart = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WindowSummary' {Maybe POSIX
testWindowStart :: Maybe POSIX
$sel:testWindowStart:WindowSummary' :: WindowSummary -> Maybe POSIX
testWindowStart} -> Maybe POSIX
testWindowStart) (\s :: WindowSummary
s@WindowSummary' {} Maybe POSIX
a -> WindowSummary
s {$sel:testWindowStart:WindowSummary' :: Maybe POSIX
testWindowStart = Maybe POSIX
a} :: WindowSummary) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

instance Data.FromJSON WindowSummary where
  parseJSON :: Value -> Parser WindowSummary
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"WindowSummary"
      ( \Object
x ->
          Maybe EvaluationType
-> Maybe Int
-> Maybe Metrics
-> Maybe POSIX
-> Maybe POSIX
-> WindowSummary
WindowSummary'
            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
"EvaluationType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ItemCount")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Metrics")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"TestWindowEnd")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"TestWindowStart")
      )

instance Prelude.Hashable WindowSummary where
  hashWithSalt :: Int -> WindowSummary -> Int
hashWithSalt Int
_salt WindowSummary' {Maybe Int
Maybe POSIX
Maybe EvaluationType
Maybe Metrics
testWindowStart :: Maybe POSIX
testWindowEnd :: Maybe POSIX
metrics :: Maybe Metrics
itemCount :: Maybe Int
evaluationType :: Maybe EvaluationType
$sel:testWindowStart:WindowSummary' :: WindowSummary -> Maybe POSIX
$sel:testWindowEnd:WindowSummary' :: WindowSummary -> Maybe POSIX
$sel:metrics:WindowSummary' :: WindowSummary -> Maybe Metrics
$sel:itemCount:WindowSummary' :: WindowSummary -> Maybe Int
$sel:evaluationType:WindowSummary' :: WindowSummary -> Maybe EvaluationType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EvaluationType
evaluationType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
itemCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Metrics
metrics
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
testWindowEnd
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
testWindowStart

instance Prelude.NFData WindowSummary where
  rnf :: WindowSummary -> ()
rnf WindowSummary' {Maybe Int
Maybe POSIX
Maybe EvaluationType
Maybe Metrics
testWindowStart :: Maybe POSIX
testWindowEnd :: Maybe POSIX
metrics :: Maybe Metrics
itemCount :: Maybe Int
evaluationType :: Maybe EvaluationType
$sel:testWindowStart:WindowSummary' :: WindowSummary -> Maybe POSIX
$sel:testWindowEnd:WindowSummary' :: WindowSummary -> Maybe POSIX
$sel:metrics:WindowSummary' :: WindowSummary -> Maybe Metrics
$sel:itemCount:WindowSummary' :: WindowSummary -> Maybe Int
$sel:evaluationType:WindowSummary' :: WindowSummary -> Maybe EvaluationType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe EvaluationType
evaluationType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
itemCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Metrics
metrics
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
testWindowEnd
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
testWindowStart