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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 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,
    -- | 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
  }
  deriving (WeightedQuantileLoss -> WeightedQuantileLoss -> Bool
(WeightedQuantileLoss -> WeightedQuantileLoss -> Bool)
-> (WeightedQuantileLoss -> WeightedQuantileLoss -> Bool)
-> Eq WeightedQuantileLoss
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]
(Int -> ReadS WeightedQuantileLoss)
-> ReadS [WeightedQuantileLoss]
-> ReadPrec WeightedQuantileLoss
-> ReadPrec [WeightedQuantileLoss]
-> Read 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
(Int -> WeightedQuantileLoss -> ShowS)
-> (WeightedQuantileLoss -> String)
-> ([WeightedQuantileLoss] -> ShowS)
-> Show WeightedQuantileLoss
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. WeightedQuantileLoss -> Rep WeightedQuantileLoss x)
-> (forall x. Rep WeightedQuantileLoss x -> WeightedQuantileLoss)
-> Generic WeightedQuantileLoss
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:
--
-- '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.
--
-- '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.
newWeightedQuantileLoss ::
  WeightedQuantileLoss
newWeightedQuantileLoss :: WeightedQuantileLoss
newWeightedQuantileLoss =
  WeightedQuantileLoss' :: Maybe Double -> Maybe Double -> WeightedQuantileLoss
WeightedQuantileLoss'
    { $sel:quantile:WeightedQuantileLoss' :: Maybe Double
quantile = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:lossValue:WeightedQuantileLoss' :: Maybe Double
lossValue = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Double -> f (Maybe Double))
-> WeightedQuantileLoss -> f WeightedQuantileLoss
weightedQuantileLoss_quantile = (WeightedQuantileLoss -> Maybe Double)
-> (WeightedQuantileLoss -> Maybe Double -> WeightedQuantileLoss)
-> Lens
     WeightedQuantileLoss
     WeightedQuantileLoss
     (Maybe Double)
     (Maybe Double)
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)

-- | 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 :: (Maybe Double -> f (Maybe Double))
-> WeightedQuantileLoss -> f WeightedQuantileLoss
weightedQuantileLoss_lossValue = (WeightedQuantileLoss -> Maybe Double)
-> (WeightedQuantileLoss -> Maybe Double -> WeightedQuantileLoss)
-> Lens
     WeightedQuantileLoss
     WeightedQuantileLoss
     (Maybe Double)
     (Maybe Double)
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)

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

instance Prelude.Hashable WeightedQuantileLoss

instance Prelude.NFData WeightedQuantileLoss