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

-- | The results of evaluating an algorithm. Returned as part of the
-- GetAccuracyMetrics response.
--
-- /See:/ 'newEvaluationResult' smart constructor.
data EvaluationResult = EvaluationResult'
  { -- | The Amazon Resource Name (ARN) of the algorithm that was evaluated.
    EvaluationResult -> Maybe Text
algorithmArn :: Prelude.Maybe Prelude.Text,
    -- | The array of test windows used for evaluating the algorithm. The
    -- @NumberOfBacktestWindows@ from the EvaluationParameters object
    -- determines the number of windows in the array.
    EvaluationResult -> Maybe [WindowSummary]
testWindows :: Prelude.Maybe [WindowSummary]
  }
  deriving (EvaluationResult -> EvaluationResult -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EvaluationResult -> EvaluationResult -> Bool
$c/= :: EvaluationResult -> EvaluationResult -> Bool
== :: EvaluationResult -> EvaluationResult -> Bool
$c== :: EvaluationResult -> EvaluationResult -> Bool
Prelude.Eq, ReadPrec [EvaluationResult]
ReadPrec EvaluationResult
Int -> ReadS EvaluationResult
ReadS [EvaluationResult]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EvaluationResult]
$creadListPrec :: ReadPrec [EvaluationResult]
readPrec :: ReadPrec EvaluationResult
$creadPrec :: ReadPrec EvaluationResult
readList :: ReadS [EvaluationResult]
$creadList :: ReadS [EvaluationResult]
readsPrec :: Int -> ReadS EvaluationResult
$creadsPrec :: Int -> ReadS EvaluationResult
Prelude.Read, Int -> EvaluationResult -> ShowS
[EvaluationResult] -> ShowS
EvaluationResult -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EvaluationResult] -> ShowS
$cshowList :: [EvaluationResult] -> ShowS
show :: EvaluationResult -> String
$cshow :: EvaluationResult -> String
showsPrec :: Int -> EvaluationResult -> ShowS
$cshowsPrec :: Int -> EvaluationResult -> ShowS
Prelude.Show, forall x. Rep EvaluationResult x -> EvaluationResult
forall x. EvaluationResult -> Rep EvaluationResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EvaluationResult x -> EvaluationResult
$cfrom :: forall x. EvaluationResult -> Rep EvaluationResult x
Prelude.Generic)

-- |
-- Create a value of 'EvaluationResult' 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:
--
-- 'algorithmArn', 'evaluationResult_algorithmArn' - The Amazon Resource Name (ARN) of the algorithm that was evaluated.
--
-- 'testWindows', 'evaluationResult_testWindows' - The array of test windows used for evaluating the algorithm. The
-- @NumberOfBacktestWindows@ from the EvaluationParameters object
-- determines the number of windows in the array.
newEvaluationResult ::
  EvaluationResult
newEvaluationResult :: EvaluationResult
newEvaluationResult =
  EvaluationResult'
    { $sel:algorithmArn:EvaluationResult' :: Maybe Text
algorithmArn = forall a. Maybe a
Prelude.Nothing,
      $sel:testWindows:EvaluationResult' :: Maybe [WindowSummary]
testWindows = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the algorithm that was evaluated.
evaluationResult_algorithmArn :: Lens.Lens' EvaluationResult (Prelude.Maybe Prelude.Text)
evaluationResult_algorithmArn :: Lens' EvaluationResult (Maybe Text)
evaluationResult_algorithmArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EvaluationResult' {Maybe Text
algorithmArn :: Maybe Text
$sel:algorithmArn:EvaluationResult' :: EvaluationResult -> Maybe Text
algorithmArn} -> Maybe Text
algorithmArn) (\s :: EvaluationResult
s@EvaluationResult' {} Maybe Text
a -> EvaluationResult
s {$sel:algorithmArn:EvaluationResult' :: Maybe Text
algorithmArn = Maybe Text
a} :: EvaluationResult)

-- | The array of test windows used for evaluating the algorithm. The
-- @NumberOfBacktestWindows@ from the EvaluationParameters object
-- determines the number of windows in the array.
evaluationResult_testWindows :: Lens.Lens' EvaluationResult (Prelude.Maybe [WindowSummary])
evaluationResult_testWindows :: Lens' EvaluationResult (Maybe [WindowSummary])
evaluationResult_testWindows = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EvaluationResult' {Maybe [WindowSummary]
testWindows :: Maybe [WindowSummary]
$sel:testWindows:EvaluationResult' :: EvaluationResult -> Maybe [WindowSummary]
testWindows} -> Maybe [WindowSummary]
testWindows) (\s :: EvaluationResult
s@EvaluationResult' {} Maybe [WindowSummary]
a -> EvaluationResult
s {$sel:testWindows:EvaluationResult' :: Maybe [WindowSummary]
testWindows = Maybe [WindowSummary]
a} :: EvaluationResult) 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

instance Data.FromJSON EvaluationResult where
  parseJSON :: Value -> Parser EvaluationResult
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EvaluationResult"
      ( \Object
x ->
          Maybe Text -> Maybe [WindowSummary] -> EvaluationResult
EvaluationResult'
            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
"AlgorithmArn")
            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
"TestWindows" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable EvaluationResult where
  hashWithSalt :: Int -> EvaluationResult -> Int
hashWithSalt Int
_salt EvaluationResult' {Maybe [WindowSummary]
Maybe Text
testWindows :: Maybe [WindowSummary]
algorithmArn :: Maybe Text
$sel:testWindows:EvaluationResult' :: EvaluationResult -> Maybe [WindowSummary]
$sel:algorithmArn:EvaluationResult' :: EvaluationResult -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
algorithmArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [WindowSummary]
testWindows

instance Prelude.NFData EvaluationResult where
  rnf :: EvaluationResult -> ()
rnf EvaluationResult' {Maybe [WindowSummary]
Maybe Text
testWindows :: Maybe [WindowSummary]
algorithmArn :: Maybe Text
$sel:testWindows:EvaluationResult' :: EvaluationResult -> Maybe [WindowSummary]
$sel:algorithmArn:EvaluationResult' :: EvaluationResult -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
algorithmArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [WindowSummary]
testWindows