def calc_ratios_for_inference()

in src/lambda/InvokeFraudEndpointLambda/lambda_function.py [0:0]


def calc_ratios_for_inference(
        transaction_amount,
        avg_amt_last_10m,
        avg_amt_last_1w,
        num_trans_last_10m,
        num_trans_last_1w,
        cutoff_condition ):

    # Initialize ratios
    amt_ratio1 = 0.0
    amt_ratio2 = 0.0
    count_ratio = 0.0

    # Check for zero-fill conditions: zero denominator, time cutoff
    if (avg_amt_last_1w > 0) and (num_trans_last_1w > 0) and (not cutoff_condition):
        # Calculate Ratios to be passed to Inference
        amt_ratio1 = avg_amt_last_10m / avg_amt_last_1w
        amt_ratio2 = transaction_amount / avg_amt_last_1w
        count_ratio = num_trans_last_10m / num_trans_last_1w

    logging.debug(f'Ratios: {amt_ratio1} {amt_ratio2} {count_ratio}')
    return amt_ratio1, amt_ratio2, count_ratio