def predict():
    """Predicts the Height of MLB Players"""

    json_payload = request.json
    LOG.info(f"JSON payload: {json_payload}")
    prediction = mlib.predict(json_payload['Weight'])
    return jsonify({'prediction': prediction})
def lambda_handler(event, context):
    """Sample pure Lambda function"""

    #Toggle Between Lambda function calls and API Gateway Requests
    print(f"RAW LAMBDA EVENT BODY: {event}")
    if 'body' in event:
        event = json.loads(event["body"])
        print("API Gateway Request event")
    else:
        print("Function Request")

    #If the payload is correct predict it
    if event and "Weight" in event:
        weight = event["Weight"]
        prediction = mlib.predict(weight)
        print(f"Prediction: {prediction}")
        return {
            "statusCode": 200,
            "body": json.dumps(prediction),
        }
    else:
        payload = {"Message": "Incorrect or Empty Payload"}
        return {
            "statusCode": 200,
            "body": json.dumps(payload),
        }
def predictcli(weight):
    """Predicts Height of an MLB player based on weight"""

    result = predict(weight)
    inches = result["height_inches"]
    human_readable = result["height_human_readable"]
    if int(inches) > 72:
        click.echo(click.style(human_readable, bg="green", fg="white"))
    else:
        click.echo(click.style(human_readable, bg="red", fg="white"))
        },
        "work_type_children": {
            "0": at_home_parent
        },
        "Residence_type_Rural": {
            "0": rural
        },
        "Residence_type_Urban": {
            "0": urban
        },
        "smoking_status_Unknown": {
            "0": smoke_unknown
        },
        "smoking_status_formerly smoked": {
            "0": former_smoker
        },
        "smoking_status_never smoked": {
            "0": never_smoked
        },
        "smoking_status_smokes": {
            "0": smoker
        }
    }
    return payload


if __name__ == "__main__":
    load = create_payload()
    result = predict(load)
    print(result)