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

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

-- | The parameters to configure the find matches transform.
--
-- /See:/ 'newFindMatchesParameters' smart constructor.
data FindMatchesParameters = FindMatchesParameters'
  { -- | The value to switch on or off to force the output to match the provided
    -- labels from users. If the value is @True@, the @find matches@ transform
    -- forces the output to match the provided labels. The results override the
    -- normal conflation results. If the value is @False@, the @find matches@
    -- transform does not ensure all the labels provided are respected, and the
    -- results rely on the trained model.
    --
    -- Note that setting this value to true may increase the conflation
    -- execution time.
    FindMatchesParameters -> Maybe Bool
enforceProvidedLabels :: Prelude.Maybe Prelude.Bool,
    -- | The value that is selected when tuning your transform for a balance
    -- between accuracy and cost. A value of 0.5 means that the system balances
    -- accuracy and cost concerns. A value of 1.0 means a bias purely for
    -- accuracy, which typically results in a higher cost, sometimes
    -- substantially higher. A value of 0.0 means a bias purely for cost, which
    -- results in a less accurate @FindMatches@ transform, sometimes with
    -- unacceptable accuracy.
    --
    -- Accuracy measures how well the transform finds true positives and true
    -- negatives. Increasing accuracy requires more machine resources and cost.
    -- But it also results in increased recall.
    --
    -- Cost measures how many compute resources, and thus money, are consumed
    -- to run the transform.
    FindMatchesParameters -> Maybe Double
accuracyCostTradeoff :: Prelude.Maybe Prelude.Double,
    -- | The value selected when tuning your transform for a balance between
    -- precision and recall. A value of 0.5 means no preference; a value of 1.0
    -- means a bias purely for precision, and a value of 0.0 means a bias for
    -- recall. Because this is a tradeoff, choosing values close to 1.0 means
    -- very low recall, and choosing values close to 0.0 results in very low
    -- precision.
    --
    -- The precision metric indicates how often your model is correct when it
    -- predicts a match.
    --
    -- The recall metric indicates that for an actual match, how often your
    -- model predicts the match.
    FindMatchesParameters -> Maybe Double
precisionRecallTradeoff :: Prelude.Maybe Prelude.Double,
    -- | The name of a column that uniquely identifies rows in the source table.
    -- Used to help identify matching records.
    FindMatchesParameters -> Maybe Text
primaryKeyColumnName :: Prelude.Maybe Prelude.Text
  }
  deriving (FindMatchesParameters -> FindMatchesParameters -> Bool
(FindMatchesParameters -> FindMatchesParameters -> Bool)
-> (FindMatchesParameters -> FindMatchesParameters -> Bool)
-> Eq FindMatchesParameters
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FindMatchesParameters -> FindMatchesParameters -> Bool
$c/= :: FindMatchesParameters -> FindMatchesParameters -> Bool
== :: FindMatchesParameters -> FindMatchesParameters -> Bool
$c== :: FindMatchesParameters -> FindMatchesParameters -> Bool
Prelude.Eq, ReadPrec [FindMatchesParameters]
ReadPrec FindMatchesParameters
Int -> ReadS FindMatchesParameters
ReadS [FindMatchesParameters]
(Int -> ReadS FindMatchesParameters)
-> ReadS [FindMatchesParameters]
-> ReadPrec FindMatchesParameters
-> ReadPrec [FindMatchesParameters]
-> Read FindMatchesParameters
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FindMatchesParameters]
$creadListPrec :: ReadPrec [FindMatchesParameters]
readPrec :: ReadPrec FindMatchesParameters
$creadPrec :: ReadPrec FindMatchesParameters
readList :: ReadS [FindMatchesParameters]
$creadList :: ReadS [FindMatchesParameters]
readsPrec :: Int -> ReadS FindMatchesParameters
$creadsPrec :: Int -> ReadS FindMatchesParameters
Prelude.Read, Int -> FindMatchesParameters -> ShowS
[FindMatchesParameters] -> ShowS
FindMatchesParameters -> String
(Int -> FindMatchesParameters -> ShowS)
-> (FindMatchesParameters -> String)
-> ([FindMatchesParameters] -> ShowS)
-> Show FindMatchesParameters
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FindMatchesParameters] -> ShowS
$cshowList :: [FindMatchesParameters] -> ShowS
show :: FindMatchesParameters -> String
$cshow :: FindMatchesParameters -> String
showsPrec :: Int -> FindMatchesParameters -> ShowS
$cshowsPrec :: Int -> FindMatchesParameters -> ShowS
Prelude.Show, (forall x. FindMatchesParameters -> Rep FindMatchesParameters x)
-> (forall x. Rep FindMatchesParameters x -> FindMatchesParameters)
-> Generic FindMatchesParameters
forall x. Rep FindMatchesParameters x -> FindMatchesParameters
forall x. FindMatchesParameters -> Rep FindMatchesParameters x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FindMatchesParameters x -> FindMatchesParameters
$cfrom :: forall x. FindMatchesParameters -> Rep FindMatchesParameters x
Prelude.Generic)

-- |
-- Create a value of 'FindMatchesParameters' 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:
--
-- 'enforceProvidedLabels', 'findMatchesParameters_enforceProvidedLabels' - The value to switch on or off to force the output to match the provided
-- labels from users. If the value is @True@, the @find matches@ transform
-- forces the output to match the provided labels. The results override the
-- normal conflation results. If the value is @False@, the @find matches@
-- transform does not ensure all the labels provided are respected, and the
-- results rely on the trained model.
--
-- Note that setting this value to true may increase the conflation
-- execution time.
--
-- 'accuracyCostTradeoff', 'findMatchesParameters_accuracyCostTradeoff' - The value that is selected when tuning your transform for a balance
-- between accuracy and cost. A value of 0.5 means that the system balances
-- accuracy and cost concerns. A value of 1.0 means a bias purely for
-- accuracy, which typically results in a higher cost, sometimes
-- substantially higher. A value of 0.0 means a bias purely for cost, which
-- results in a less accurate @FindMatches@ transform, sometimes with
-- unacceptable accuracy.
--
-- Accuracy measures how well the transform finds true positives and true
-- negatives. Increasing accuracy requires more machine resources and cost.
-- But it also results in increased recall.
--
-- Cost measures how many compute resources, and thus money, are consumed
-- to run the transform.
--
-- 'precisionRecallTradeoff', 'findMatchesParameters_precisionRecallTradeoff' - The value selected when tuning your transform for a balance between
-- precision and recall. A value of 0.5 means no preference; a value of 1.0
-- means a bias purely for precision, and a value of 0.0 means a bias for
-- recall. Because this is a tradeoff, choosing values close to 1.0 means
-- very low recall, and choosing values close to 0.0 results in very low
-- precision.
--
-- The precision metric indicates how often your model is correct when it
-- predicts a match.
--
-- The recall metric indicates that for an actual match, how often your
-- model predicts the match.
--
-- 'primaryKeyColumnName', 'findMatchesParameters_primaryKeyColumnName' - The name of a column that uniquely identifies rows in the source table.
-- Used to help identify matching records.
newFindMatchesParameters ::
  FindMatchesParameters
newFindMatchesParameters :: FindMatchesParameters
newFindMatchesParameters =
  FindMatchesParameters' :: Maybe Bool
-> Maybe Double
-> Maybe Double
-> Maybe Text
-> FindMatchesParameters
FindMatchesParameters'
    { $sel:enforceProvidedLabels:FindMatchesParameters' :: Maybe Bool
enforceProvidedLabels =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:accuracyCostTradeoff:FindMatchesParameters' :: Maybe Double
accuracyCostTradeoff = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:precisionRecallTradeoff:FindMatchesParameters' :: Maybe Double
precisionRecallTradeoff = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:primaryKeyColumnName:FindMatchesParameters' :: Maybe Text
primaryKeyColumnName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The value to switch on or off to force the output to match the provided
-- labels from users. If the value is @True@, the @find matches@ transform
-- forces the output to match the provided labels. The results override the
-- normal conflation results. If the value is @False@, the @find matches@
-- transform does not ensure all the labels provided are respected, and the
-- results rely on the trained model.
--
-- Note that setting this value to true may increase the conflation
-- execution time.
findMatchesParameters_enforceProvidedLabels :: Lens.Lens' FindMatchesParameters (Prelude.Maybe Prelude.Bool)
findMatchesParameters_enforceProvidedLabels :: (Maybe Bool -> f (Maybe Bool))
-> FindMatchesParameters -> f FindMatchesParameters
findMatchesParameters_enforceProvidedLabels = (FindMatchesParameters -> Maybe Bool)
-> (FindMatchesParameters -> Maybe Bool -> FindMatchesParameters)
-> Lens
     FindMatchesParameters
     FindMatchesParameters
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FindMatchesParameters' {Maybe Bool
enforceProvidedLabels :: Maybe Bool
$sel:enforceProvidedLabels:FindMatchesParameters' :: FindMatchesParameters -> Maybe Bool
enforceProvidedLabels} -> Maybe Bool
enforceProvidedLabels) (\s :: FindMatchesParameters
s@FindMatchesParameters' {} Maybe Bool
a -> FindMatchesParameters
s {$sel:enforceProvidedLabels:FindMatchesParameters' :: Maybe Bool
enforceProvidedLabels = Maybe Bool
a} :: FindMatchesParameters)

-- | The value that is selected when tuning your transform for a balance
-- between accuracy and cost. A value of 0.5 means that the system balances
-- accuracy and cost concerns. A value of 1.0 means a bias purely for
-- accuracy, which typically results in a higher cost, sometimes
-- substantially higher. A value of 0.0 means a bias purely for cost, which
-- results in a less accurate @FindMatches@ transform, sometimes with
-- unacceptable accuracy.
--
-- Accuracy measures how well the transform finds true positives and true
-- negatives. Increasing accuracy requires more machine resources and cost.
-- But it also results in increased recall.
--
-- Cost measures how many compute resources, and thus money, are consumed
-- to run the transform.
findMatchesParameters_accuracyCostTradeoff :: Lens.Lens' FindMatchesParameters (Prelude.Maybe Prelude.Double)
findMatchesParameters_accuracyCostTradeoff :: (Maybe Double -> f (Maybe Double))
-> FindMatchesParameters -> f FindMatchesParameters
findMatchesParameters_accuracyCostTradeoff = (FindMatchesParameters -> Maybe Double)
-> (FindMatchesParameters -> Maybe Double -> FindMatchesParameters)
-> Lens
     FindMatchesParameters
     FindMatchesParameters
     (Maybe Double)
     (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FindMatchesParameters' {Maybe Double
accuracyCostTradeoff :: Maybe Double
$sel:accuracyCostTradeoff:FindMatchesParameters' :: FindMatchesParameters -> Maybe Double
accuracyCostTradeoff} -> Maybe Double
accuracyCostTradeoff) (\s :: FindMatchesParameters
s@FindMatchesParameters' {} Maybe Double
a -> FindMatchesParameters
s {$sel:accuracyCostTradeoff:FindMatchesParameters' :: Maybe Double
accuracyCostTradeoff = Maybe Double
a} :: FindMatchesParameters)

-- | The value selected when tuning your transform for a balance between
-- precision and recall. A value of 0.5 means no preference; a value of 1.0
-- means a bias purely for precision, and a value of 0.0 means a bias for
-- recall. Because this is a tradeoff, choosing values close to 1.0 means
-- very low recall, and choosing values close to 0.0 results in very low
-- precision.
--
-- The precision metric indicates how often your model is correct when it
-- predicts a match.
--
-- The recall metric indicates that for an actual match, how often your
-- model predicts the match.
findMatchesParameters_precisionRecallTradeoff :: Lens.Lens' FindMatchesParameters (Prelude.Maybe Prelude.Double)
findMatchesParameters_precisionRecallTradeoff :: (Maybe Double -> f (Maybe Double))
-> FindMatchesParameters -> f FindMatchesParameters
findMatchesParameters_precisionRecallTradeoff = (FindMatchesParameters -> Maybe Double)
-> (FindMatchesParameters -> Maybe Double -> FindMatchesParameters)
-> Lens
     FindMatchesParameters
     FindMatchesParameters
     (Maybe Double)
     (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FindMatchesParameters' {Maybe Double
precisionRecallTradeoff :: Maybe Double
$sel:precisionRecallTradeoff:FindMatchesParameters' :: FindMatchesParameters -> Maybe Double
precisionRecallTradeoff} -> Maybe Double
precisionRecallTradeoff) (\s :: FindMatchesParameters
s@FindMatchesParameters' {} Maybe Double
a -> FindMatchesParameters
s {$sel:precisionRecallTradeoff:FindMatchesParameters' :: Maybe Double
precisionRecallTradeoff = Maybe Double
a} :: FindMatchesParameters)

-- | The name of a column that uniquely identifies rows in the source table.
-- Used to help identify matching records.
findMatchesParameters_primaryKeyColumnName :: Lens.Lens' FindMatchesParameters (Prelude.Maybe Prelude.Text)
findMatchesParameters_primaryKeyColumnName :: (Maybe Text -> f (Maybe Text))
-> FindMatchesParameters -> f FindMatchesParameters
findMatchesParameters_primaryKeyColumnName = (FindMatchesParameters -> Maybe Text)
-> (FindMatchesParameters -> Maybe Text -> FindMatchesParameters)
-> Lens
     FindMatchesParameters
     FindMatchesParameters
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FindMatchesParameters' {Maybe Text
primaryKeyColumnName :: Maybe Text
$sel:primaryKeyColumnName:FindMatchesParameters' :: FindMatchesParameters -> Maybe Text
primaryKeyColumnName} -> Maybe Text
primaryKeyColumnName) (\s :: FindMatchesParameters
s@FindMatchesParameters' {} Maybe Text
a -> FindMatchesParameters
s {$sel:primaryKeyColumnName:FindMatchesParameters' :: Maybe Text
primaryKeyColumnName = Maybe Text
a} :: FindMatchesParameters)

instance Core.FromJSON FindMatchesParameters where
  parseJSON :: Value -> Parser FindMatchesParameters
parseJSON =
    String
-> (Object -> Parser FindMatchesParameters)
-> Value
-> Parser FindMatchesParameters
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FindMatchesParameters"
      ( \Object
x ->
          Maybe Bool
-> Maybe Double
-> Maybe Double
-> Maybe Text
-> FindMatchesParameters
FindMatchesParameters'
            (Maybe Bool
 -> Maybe Double
 -> Maybe Double
 -> Maybe Text
 -> FindMatchesParameters)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Double
      -> Maybe Double -> Maybe Text -> FindMatchesParameters)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EnforceProvidedLabels")
            Parser
  (Maybe Double
   -> Maybe Double -> Maybe Text -> FindMatchesParameters)
-> Parser (Maybe Double)
-> Parser (Maybe Double -> Maybe Text -> FindMatchesParameters)
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
"AccuracyCostTradeoff")
            Parser (Maybe Double -> Maybe Text -> FindMatchesParameters)
-> Parser (Maybe Double)
-> Parser (Maybe Text -> FindMatchesParameters)
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
"PrecisionRecallTradeoff")
            Parser (Maybe Text -> FindMatchesParameters)
-> Parser (Maybe Text) -> Parser FindMatchesParameters
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PrimaryKeyColumnName")
      )

instance Prelude.Hashable FindMatchesParameters

instance Prelude.NFData FindMatchesParameters

instance Core.ToJSON FindMatchesParameters where
  toJSON :: FindMatchesParameters -> Value
toJSON FindMatchesParameters' {Maybe Bool
Maybe Double
Maybe Text
primaryKeyColumnName :: Maybe Text
precisionRecallTradeoff :: Maybe Double
accuracyCostTradeoff :: Maybe Double
enforceProvidedLabels :: Maybe Bool
$sel:primaryKeyColumnName:FindMatchesParameters' :: FindMatchesParameters -> Maybe Text
$sel:precisionRecallTradeoff:FindMatchesParameters' :: FindMatchesParameters -> Maybe Double
$sel:accuracyCostTradeoff:FindMatchesParameters' :: FindMatchesParameters -> Maybe Double
$sel:enforceProvidedLabels:FindMatchesParameters' :: FindMatchesParameters -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"EnforceProvidedLabels" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
enforceProvidedLabels,
            (Text
"AccuracyCostTradeoff" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Double -> Pair) -> Maybe Double -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
accuracyCostTradeoff,
            (Text
"PrecisionRecallTradeoff" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Double -> Pair) -> Maybe Double -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
precisionRecallTradeoff,
            (Text
"PrimaryKeyColumnName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
primaryKeyColumnName
          ]
      )