{-# 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.Glue.Types.ConfusionMatrix
-- 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.Glue.Types.ConfusionMatrix where

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

-- | The confusion matrix shows you what your transform is predicting
-- accurately and what types of errors it is making.
--
-- For more information, see
-- <https://en.wikipedia.org/wiki/Confusion_matrix Confusion matrix> in
-- Wikipedia.
--
-- /See:/ 'newConfusionMatrix' smart constructor.
data ConfusionMatrix = ConfusionMatrix'
  { -- | The number of nonmatches in the data that the transform correctly
    -- rejected, in the confusion matrix for your transform.
    ConfusionMatrix -> Maybe Integer
numTrueNegatives :: Prelude.Maybe Prelude.Integer,
    -- | The number of matches in the data that the transform didn\'t find, in
    -- the confusion matrix for your transform.
    ConfusionMatrix -> Maybe Integer
numFalseNegatives :: Prelude.Maybe Prelude.Integer,
    -- | The number of matches in the data that the transform correctly found, in
    -- the confusion matrix for your transform.
    ConfusionMatrix -> Maybe Integer
numTruePositives :: Prelude.Maybe Prelude.Integer,
    -- | The number of nonmatches in the data that the transform incorrectly
    -- classified as a match, in the confusion matrix for your transform.
    ConfusionMatrix -> Maybe Integer
numFalsePositives :: Prelude.Maybe Prelude.Integer
  }
  deriving (ConfusionMatrix -> ConfusionMatrix -> Bool
(ConfusionMatrix -> ConfusionMatrix -> Bool)
-> (ConfusionMatrix -> ConfusionMatrix -> Bool)
-> Eq ConfusionMatrix
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConfusionMatrix -> ConfusionMatrix -> Bool
$c/= :: ConfusionMatrix -> ConfusionMatrix -> Bool
== :: ConfusionMatrix -> ConfusionMatrix -> Bool
$c== :: ConfusionMatrix -> ConfusionMatrix -> Bool
Prelude.Eq, ReadPrec [ConfusionMatrix]
ReadPrec ConfusionMatrix
Int -> ReadS ConfusionMatrix
ReadS [ConfusionMatrix]
(Int -> ReadS ConfusionMatrix)
-> ReadS [ConfusionMatrix]
-> ReadPrec ConfusionMatrix
-> ReadPrec [ConfusionMatrix]
-> Read ConfusionMatrix
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConfusionMatrix]
$creadListPrec :: ReadPrec [ConfusionMatrix]
readPrec :: ReadPrec ConfusionMatrix
$creadPrec :: ReadPrec ConfusionMatrix
readList :: ReadS [ConfusionMatrix]
$creadList :: ReadS [ConfusionMatrix]
readsPrec :: Int -> ReadS ConfusionMatrix
$creadsPrec :: Int -> ReadS ConfusionMatrix
Prelude.Read, Int -> ConfusionMatrix -> ShowS
[ConfusionMatrix] -> ShowS
ConfusionMatrix -> String
(Int -> ConfusionMatrix -> ShowS)
-> (ConfusionMatrix -> String)
-> ([ConfusionMatrix] -> ShowS)
-> Show ConfusionMatrix
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConfusionMatrix] -> ShowS
$cshowList :: [ConfusionMatrix] -> ShowS
show :: ConfusionMatrix -> String
$cshow :: ConfusionMatrix -> String
showsPrec :: Int -> ConfusionMatrix -> ShowS
$cshowsPrec :: Int -> ConfusionMatrix -> ShowS
Prelude.Show, (forall x. ConfusionMatrix -> Rep ConfusionMatrix x)
-> (forall x. Rep ConfusionMatrix x -> ConfusionMatrix)
-> Generic ConfusionMatrix
forall x. Rep ConfusionMatrix x -> ConfusionMatrix
forall x. ConfusionMatrix -> Rep ConfusionMatrix x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConfusionMatrix x -> ConfusionMatrix
$cfrom :: forall x. ConfusionMatrix -> Rep ConfusionMatrix x
Prelude.Generic)

-- |
-- Create a value of 'ConfusionMatrix' 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:
--
-- 'numTrueNegatives', 'confusionMatrix_numTrueNegatives' - The number of nonmatches in the data that the transform correctly
-- rejected, in the confusion matrix for your transform.
--
-- 'numFalseNegatives', 'confusionMatrix_numFalseNegatives' - The number of matches in the data that the transform didn\'t find, in
-- the confusion matrix for your transform.
--
-- 'numTruePositives', 'confusionMatrix_numTruePositives' - The number of matches in the data that the transform correctly found, in
-- the confusion matrix for your transform.
--
-- 'numFalsePositives', 'confusionMatrix_numFalsePositives' - The number of nonmatches in the data that the transform incorrectly
-- classified as a match, in the confusion matrix for your transform.
newConfusionMatrix ::
  ConfusionMatrix
newConfusionMatrix :: ConfusionMatrix
newConfusionMatrix =
  ConfusionMatrix' :: Maybe Integer
-> Maybe Integer
-> Maybe Integer
-> Maybe Integer
-> ConfusionMatrix
ConfusionMatrix'
    { $sel:numTrueNegatives:ConfusionMatrix' :: Maybe Integer
numTrueNegatives =
        Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:numFalseNegatives:ConfusionMatrix' :: Maybe Integer
numFalseNegatives = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:numTruePositives:ConfusionMatrix' :: Maybe Integer
numTruePositives = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:numFalsePositives:ConfusionMatrix' :: Maybe Integer
numFalsePositives = Maybe Integer
forall a. Maybe a
Prelude.Nothing
    }

-- | The number of nonmatches in the data that the transform correctly
-- rejected, in the confusion matrix for your transform.
confusionMatrix_numTrueNegatives :: Lens.Lens' ConfusionMatrix (Prelude.Maybe Prelude.Integer)
confusionMatrix_numTrueNegatives :: (Maybe Integer -> f (Maybe Integer))
-> ConfusionMatrix -> f ConfusionMatrix
confusionMatrix_numTrueNegatives = (ConfusionMatrix -> Maybe Integer)
-> (ConfusionMatrix -> Maybe Integer -> ConfusionMatrix)
-> Lens
     ConfusionMatrix ConfusionMatrix (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfusionMatrix' {Maybe Integer
numTrueNegatives :: Maybe Integer
$sel:numTrueNegatives:ConfusionMatrix' :: ConfusionMatrix -> Maybe Integer
numTrueNegatives} -> Maybe Integer
numTrueNegatives) (\s :: ConfusionMatrix
s@ConfusionMatrix' {} Maybe Integer
a -> ConfusionMatrix
s {$sel:numTrueNegatives:ConfusionMatrix' :: Maybe Integer
numTrueNegatives = Maybe Integer
a} :: ConfusionMatrix)

-- | The number of matches in the data that the transform didn\'t find, in
-- the confusion matrix for your transform.
confusionMatrix_numFalseNegatives :: Lens.Lens' ConfusionMatrix (Prelude.Maybe Prelude.Integer)
confusionMatrix_numFalseNegatives :: (Maybe Integer -> f (Maybe Integer))
-> ConfusionMatrix -> f ConfusionMatrix
confusionMatrix_numFalseNegatives = (ConfusionMatrix -> Maybe Integer)
-> (ConfusionMatrix -> Maybe Integer -> ConfusionMatrix)
-> Lens
     ConfusionMatrix ConfusionMatrix (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfusionMatrix' {Maybe Integer
numFalseNegatives :: Maybe Integer
$sel:numFalseNegatives:ConfusionMatrix' :: ConfusionMatrix -> Maybe Integer
numFalseNegatives} -> Maybe Integer
numFalseNegatives) (\s :: ConfusionMatrix
s@ConfusionMatrix' {} Maybe Integer
a -> ConfusionMatrix
s {$sel:numFalseNegatives:ConfusionMatrix' :: Maybe Integer
numFalseNegatives = Maybe Integer
a} :: ConfusionMatrix)

-- | The number of matches in the data that the transform correctly found, in
-- the confusion matrix for your transform.
confusionMatrix_numTruePositives :: Lens.Lens' ConfusionMatrix (Prelude.Maybe Prelude.Integer)
confusionMatrix_numTruePositives :: (Maybe Integer -> f (Maybe Integer))
-> ConfusionMatrix -> f ConfusionMatrix
confusionMatrix_numTruePositives = (ConfusionMatrix -> Maybe Integer)
-> (ConfusionMatrix -> Maybe Integer -> ConfusionMatrix)
-> Lens
     ConfusionMatrix ConfusionMatrix (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfusionMatrix' {Maybe Integer
numTruePositives :: Maybe Integer
$sel:numTruePositives:ConfusionMatrix' :: ConfusionMatrix -> Maybe Integer
numTruePositives} -> Maybe Integer
numTruePositives) (\s :: ConfusionMatrix
s@ConfusionMatrix' {} Maybe Integer
a -> ConfusionMatrix
s {$sel:numTruePositives:ConfusionMatrix' :: Maybe Integer
numTruePositives = Maybe Integer
a} :: ConfusionMatrix)

-- | The number of nonmatches in the data that the transform incorrectly
-- classified as a match, in the confusion matrix for your transform.
confusionMatrix_numFalsePositives :: Lens.Lens' ConfusionMatrix (Prelude.Maybe Prelude.Integer)
confusionMatrix_numFalsePositives :: (Maybe Integer -> f (Maybe Integer))
-> ConfusionMatrix -> f ConfusionMatrix
confusionMatrix_numFalsePositives = (ConfusionMatrix -> Maybe Integer)
-> (ConfusionMatrix -> Maybe Integer -> ConfusionMatrix)
-> Lens
     ConfusionMatrix ConfusionMatrix (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfusionMatrix' {Maybe Integer
numFalsePositives :: Maybe Integer
$sel:numFalsePositives:ConfusionMatrix' :: ConfusionMatrix -> Maybe Integer
numFalsePositives} -> Maybe Integer
numFalsePositives) (\s :: ConfusionMatrix
s@ConfusionMatrix' {} Maybe Integer
a -> ConfusionMatrix
s {$sel:numFalsePositives:ConfusionMatrix' :: Maybe Integer
numFalsePositives = Maybe Integer
a} :: ConfusionMatrix)

instance Core.FromJSON ConfusionMatrix where
  parseJSON :: Value -> Parser ConfusionMatrix
parseJSON =
    String
-> (Object -> Parser ConfusionMatrix)
-> Value
-> Parser ConfusionMatrix
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ConfusionMatrix"
      ( \Object
x ->
          Maybe Integer
-> Maybe Integer
-> Maybe Integer
-> Maybe Integer
-> ConfusionMatrix
ConfusionMatrix'
            (Maybe Integer
 -> Maybe Integer
 -> Maybe Integer
 -> Maybe Integer
 -> ConfusionMatrix)
-> Parser (Maybe Integer)
-> Parser
     (Maybe Integer
      -> Maybe Integer -> Maybe Integer -> ConfusionMatrix)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"NumTrueNegatives")
            Parser
  (Maybe Integer
   -> Maybe Integer -> Maybe Integer -> ConfusionMatrix)
-> Parser (Maybe Integer)
-> Parser (Maybe Integer -> Maybe Integer -> ConfusionMatrix)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"NumFalseNegatives")
            Parser (Maybe Integer -> Maybe Integer -> ConfusionMatrix)
-> Parser (Maybe Integer)
-> Parser (Maybe Integer -> ConfusionMatrix)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"NumTruePositives")
            Parser (Maybe Integer -> ConfusionMatrix)
-> Parser (Maybe Integer) -> Parser ConfusionMatrix
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"NumFalsePositives")
      )

instance Prelude.Hashable ConfusionMatrix

instance Prelude.NFData ConfusionMatrix