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

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

-- | The weighted loss value for a quantile. This object is part of the
-- Metrics object.
--
-- /See:/ 'newWeightedQuantileLoss' smart constructor.
data WeightedQuantileLoss = WeightedQuantileLoss'
  { -- | The difference between the predicted value and the actual value over the
    -- quantile, weighted (normalized) by dividing by the sum over all
    -- quantiles.
    WeightedQuantileLoss -> Maybe Double
lossValue :: Prelude.Maybe Prelude.Double,
    -- | The quantile. Quantiles divide a probability distribution into regions
    -- of equal probability. For example, if the distribution was divided into
    -- 5 regions of equal probability, the quantiles would be 0.2, 0.4, 0.6,
    -- and 0.8.
    WeightedQuantileLoss -> Maybe Double
quantile :: Prelude.Maybe Prelude.Double
  }
  deriving (WeightedQuantileLoss -> WeightedQuantileLoss -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WeightedQuantileLoss -> WeightedQuantileLoss -> Bool
$c/= :: WeightedQuantileLoss -> WeightedQuantileLoss -> Bool
== :: WeightedQuantileLoss -> WeightedQuantileLoss -> Bool
$c== :: WeightedQuantileLoss -> WeightedQuantileLoss -> Bool
Prelude.Eq, ReadPrec [WeightedQuantileLoss]
ReadPrec WeightedQuantileLoss
Int -> ReadS WeightedQuantileLoss
ReadS [WeightedQuantileLoss]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WeightedQuantileLoss]
$creadListPrec :: ReadPrec [WeightedQuantileLoss]
readPrec :: ReadPrec WeightedQuantileLoss
$creadPrec :: ReadPrec WeightedQuantileLoss
readList :: ReadS [WeightedQuantileLoss]
$creadList :: ReadS [WeightedQuantileLoss]
readsPrec :: Int -> ReadS WeightedQuantileLoss
$creadsPrec :: Int -> ReadS WeightedQuantileLoss
Prelude.Read, Int -> WeightedQuantileLoss -> ShowS
[WeightedQuantileLoss] -> ShowS
WeightedQuantileLoss -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WeightedQuantileLoss] -> ShowS
$cshowList :: [WeightedQuantileLoss] -> ShowS
show :: WeightedQuantileLoss -> String
$cshow :: WeightedQuantileLoss -> String
showsPrec :: Int -> WeightedQuantileLoss -> ShowS
$cshowsPrec :: Int -> WeightedQuantileLoss -> ShowS
Prelude.Show, forall x. Rep WeightedQuantileLoss x -> WeightedQuantileLoss
forall x. WeightedQuantileLoss -> Rep WeightedQuantileLoss x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WeightedQuantileLoss x -> WeightedQuantileLoss
$cfrom :: forall x. WeightedQuantileLoss -> Rep WeightedQuantileLoss x
Prelude.Generic)

-- |
-- Create a value of 'WeightedQuantileLoss' 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:
--
-- 'lossValue', 'weightedQuantileLoss_lossValue' - The difference between the predicted value and the actual value over the
-- quantile, weighted (normalized) by dividing by the sum over all
-- quantiles.
--
-- 'quantile', 'weightedQuantileLoss_quantile' - The quantile. Quantiles divide a probability distribution into regions
-- of equal probability. For example, if the distribution was divided into
-- 5 regions of equal probability, the quantiles would be 0.2, 0.4, 0.6,
-- and 0.8.
newWeightedQuantileLoss ::
  WeightedQuantileLoss
newWeightedQuantileLoss :: WeightedQuantileLoss
newWeightedQuantileLoss =
  WeightedQuantileLoss'
    { $sel:lossValue:WeightedQuantileLoss' :: Maybe Double
lossValue = forall a. Maybe a
Prelude.Nothing,
      $sel:quantile:WeightedQuantileLoss' :: Maybe Double
quantile = forall a. Maybe a
Prelude.Nothing
    }

-- | The difference between the predicted value and the actual value over the
-- quantile, weighted (normalized) by dividing by the sum over all
-- quantiles.
weightedQuantileLoss_lossValue :: Lens.Lens' WeightedQuantileLoss (Prelude.Maybe Prelude.Double)
weightedQuantileLoss_lossValue :: Lens' WeightedQuantileLoss (Maybe Double)
weightedQuantileLoss_lossValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WeightedQuantileLoss' {Maybe Double
lossValue :: Maybe Double
$sel:lossValue:WeightedQuantileLoss' :: WeightedQuantileLoss -> Maybe Double
lossValue} -> Maybe Double
lossValue) (\s :: WeightedQuantileLoss
s@WeightedQuantileLoss' {} Maybe Double
a -> WeightedQuantileLoss
s {$sel:lossValue:WeightedQuantileLoss' :: Maybe Double
lossValue = Maybe Double
a} :: WeightedQuantileLoss)

-- | The quantile. Quantiles divide a probability distribution into regions
-- of equal probability. For example, if the distribution was divided into
-- 5 regions of equal probability, the quantiles would be 0.2, 0.4, 0.6,
-- and 0.8.
weightedQuantileLoss_quantile :: Lens.Lens' WeightedQuantileLoss (Prelude.Maybe Prelude.Double)
weightedQuantileLoss_quantile :: Lens' WeightedQuantileLoss (Maybe Double)
weightedQuantileLoss_quantile = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WeightedQuantileLoss' {Maybe Double
quantile :: Maybe Double
$sel:quantile:WeightedQuantileLoss' :: WeightedQuantileLoss -> Maybe Double
quantile} -> Maybe Double
quantile) (\s :: WeightedQuantileLoss
s@WeightedQuantileLoss' {} Maybe Double
a -> WeightedQuantileLoss
s {$sel:quantile:WeightedQuantileLoss' :: Maybe Double
quantile = Maybe Double
a} :: WeightedQuantileLoss)

instance Data.FromJSON WeightedQuantileLoss where
  parseJSON :: Value -> Parser WeightedQuantileLoss
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"WeightedQuantileLoss"
      ( \Object
x ->
          Maybe Double -> Maybe Double -> WeightedQuantileLoss
WeightedQuantileLoss'
            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
"LossValue")
            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
"Quantile")
      )

instance Prelude.Hashable WeightedQuantileLoss where
  hashWithSalt :: Int -> WeightedQuantileLoss -> Int
hashWithSalt Int
_salt WeightedQuantileLoss' {Maybe Double
quantile :: Maybe Double
lossValue :: Maybe Double
$sel:quantile:WeightedQuantileLoss' :: WeightedQuantileLoss -> Maybe Double
$sel:lossValue:WeightedQuantileLoss' :: WeightedQuantileLoss -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
lossValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
quantile

instance Prelude.NFData WeightedQuantileLoss where
  rnf :: WeightedQuantileLoss -> ()
rnf WeightedQuantileLoss' {Maybe Double
quantile :: Maybe Double
lossValue :: Maybe Double
$sel:quantile:WeightedQuantileLoss' :: WeightedQuantileLoss -> Maybe Double
$sel:lossValue:WeightedQuantileLoss' :: WeightedQuantileLoss -> Maybe Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
lossValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
quantile