Introducing the Insurance Underwriting Expert: Your Go-To Solution for Risk Assessment
Published: 2024-06-24 06:32:03

The insurance industry is a critical sector that provides financial protection and peace of mind to individuals and businesses. A core function within this industry is underwriting — the process of evaluating risks and determining the terms and conditions of insurance policies. Traditional underwriting is often complex, time-consuming, and reliant on manual data processing and expert judgment. This can lead to inconsistencies, delays, and increased operational costs.

**Current Challenges**
Manual Data Processing: Underwriting requires collecting and analyzing a vast amount of data, including personal, health, and lifestyle information. Manual data entry and analysis are prone to errors and inefficiencies.
Inconsistent Decision-Making: Human underwriters may have varying levels of expertise and judgment, leading to inconsistent risk assessments and policy decisions.
Time-Consuming Procedures: The traditional underwriting process can take days or even weeks to complete, causing delays in policy issuance and customer dissatisfaction.
High Operational Costs: Extensive manual processing and the need for specialized underwriters increase the operational costs for insurance companies.
Regulatory Compliance: Ensuring compliance with regulatory requirements is essential but can be challenging and resource-intensive when done manually.

**Insurance Underwriting Expert**
The Insurance Underwriting Expert is an AI-driven application designed to revolutionize the underwriting process. It aims to address the aforementioned challenges by providing a user-friendly platform where insurance companies can:

Automate Data Processing: Utilize AI to collect, verify, and analyze applicant data quickly and accurately.
Ensure Consistent Risk Assessments: Apply standardized AI models to ensure uniform risk evaluations across all applications.
Speed Up Decision-Making: Significantly reduce the time required to assess risks and issue policies.
Lower Operational Costs: Minimize the need for extensive manual labor and specialized underwriters.
Enhance Regulatory Compliance: Implement built-in compliance checks to ensure adherence to regulatory standards.

**How the Insurance Underwriting Expert Works**
Our AI-powered underwriting solution utilizes Lyzr Automata and OpenAI to evaluate applicant data and generate comprehensive underwriting reports. Here’s a step-by-step guide on how to use our tool:

1. Enter Applicant Information
The process begins with collecting basic information about the applicant, including their name, age, and address. This step is crucial for establishing the applicant’s identity and context.

2. Provide Personal and Health Information
Next, we gather detailed personal and health information. This includes the applicant’s occupation, annual income, marital status, medical history, dependents, lifestyle, and family medical history. This data is essential for assessing the overall risk profile of the applicant.

3. Generate the Underwriting Report
Once the data is entered, our AI system processes the information to calculate a risk status (low, neutral, or high). Based on this risk status, it generates a detailed underwriting report. This report includes:

Risk Assessment Summary: An overview of the risk score and factors contributing to it.
Underwriting Decision: A summary of the underwriting decision based on the risk assessment.
Policy Terms and Conditions: Detailed terms and conditions of the proposed policy, including coverage amount, premium calculation, payment options, policy riders, exclusions, and more.
Approval Conditions: Conditions that must be met for the policy to be approved.
Policy Issuance Details: Information about the effective date, renewal date, and beneficiary designation.
**Setting Up the Environment**
**Imports:**

Imports necessary libraries: os, streamlit, libraries from lyzr_automata, and dotenv.

```
pip install lyzr_automata streamlit
```

```
import streamlit as st
from lyzr_automata.ai_models.openai import OpenAIModel
from lyzr_automata import Agent,Task
from lyzr_automata.pipelines.linear_sync_pipeline import LinearSyncPipeline
from PIL import Image
```

**API Key Input:**
```
api = st.sidebar.text_input("Enter our OPENAI API KEY Here", type="password")
if api:
    openai_model = OpenAIModel(
        api_key=api,
        parameters={
            "model": "gpt-4-turbo-preview",
            "temperature": 0.2,
            "max_tokens": 1500,
        },
    )
else:
    st.sidebar.error("Please Enter Your OPENAI API KEY")
```
Creates a text input field in the sidebar using st.sidebar.text_input to capture the OpenAI API key. It hides the input text using the type="password" argument.
Conditionally checks for the entered API key:
If a key is entered, it creates an OpenAIModel object using the provided parameters (model name, temperature, and maximum tokens).
If no key is entered, it displays an error message using st.sidebar.error.

**Example Underwriting Document:**

```
example= f"""
#### *Risk Assessment Summary*
A risk score of 0.65 indicates a moderate level of risk. This score takes into account factors such as age, health, lifestyle, occupation, and family medical history. While the applicant presents a generally low-risk profile, the score suggests some areas of potential concern that require consideration in the policy terms.

#### *Underwriting Decision*

Based on the risk score of 0.65 and the comprehensive assessment, the underwriting decision includes the following terms and conditions:

#### *Policy Terms and Conditions*

1.⁠ ⁠*Policy Type*:
   - 20-Year Term Life Insurance

2.⁠ ⁠*Coverage Amount*:
   - $500,000

3.⁠ ⁠*Premium Calculation*:
   - *Base Premium*: $750 per year
   - *Risk Score Adjustment*: +10% ($75)
   - *Total Annual Premium*: $825

4.⁠ ⁠*Payment Options*:
   - Annual Payment: $825
   - Semi-Annual Payment: $420 (x2)
   - Monthly Payment: $70 (x12)

5.⁠ ⁠*Policy Riders*:
   - *Accidental Death Benefit Rider*: Additional $100,000 coverage for $50 per year
   - *Waiver of Premium Rider*: Waives premium payments in case of total disability for $40 per year
   - *Child Term Rider*: $10,000 coverage per child for $50 per year

6.⁠ ⁠*Exclusions*:
   - *Suicide Clause*: No payout if the insured commits suicide within the first two years of the policy
   - *High-Risk Activities*: No coverage for death resulting from participation in high-risk activities such as skydiving, scuba diving, or racing
   - *Illegal Activities*: No coverage for death resulting from involvement in illegal activities

7.⁠ ⁠*Medical Examination*:
   - A medical examination is required to confirm the applicant’s health status. The examination must be completed within 30 days of policy approval. The cost will be covered by the insurance company.

8.⁠ ⁠*Renewal and Conversion*:
   - The policy can be renewed at the end of the 20-year term, subject to a re-evaluation of risk factors and premium adjustment.
   - The policyholder has the option to convert the term policy into a whole life policy without additional medical examination before the age of 60.

9.⁠ ⁠*Beneficiary Designation*:
   - Primary Beneficiary: Jane Doe (Spouse)
   - Contingent Beneficiaries: John Doe Jr. and Jane Doe Jr. (Children)

#### *Approval Conditions*
1.⁠ ⁠*Verification of Information*:
   - Confirmation of personal and health information provided during the application process.

2.⁠ ⁠*Medical Examination*:
   - Completion and satisfactory results of the required medical examination.

#### *Policy Issuance*
•⁠  ⁠*Policy Effective Date*: June 1, 2024
•⁠  ⁠*Renewal Date*: June 1, 2044
•⁠  ⁠*Policyholder Signature*: Required on the policy document to confirm acceptance of terms and conditions.

#### *Contact Information*
For any questions or further assistance, please contact our customer service team at 1-800-LIFEPOLICY or email support@lifeinsurancecompany.com.
"""
```
Defines a multi-line string variable example containing a sample insurance underwriting document with various sections like risk assessment summary, underwriting decision, policy terms and conditions, etc. This serves as a reference format for the AI-generated output.

**insurance_underwriting Function:**

```

def insurance_underwriting():
    insurance_agent = Agent(
        role="Insurance Consultant",
        prompt_persona=f"You are an Expert Insurance Underwriter.Your Task is to generate Risk Assessment summary,Underwriting Decision,Policy Terms & Condition,Approval Condition and Policy Issuance."
    )

    prompt = f"""
    You are a Insurance Underwriting expert.
    Based On Below Input:
    Applicant Information:
    name: {st.session_state.form1_data['name']}
    Age: {st.session_state.form1_data['age']}
    Address: {st.session_state.form1_data['address']}
    Personal and Health Information:
    Occupation: {st.session_state.form2_data['occupation']}
    Annual Income: {st.session_state.form2_data['annual_income']}
    Marital Status: {st.session_state.form2_data['marital_status']}
    Medical_history: {st.session_state.form2_data['medical_history']}
    Dependents: {st.session_state.form2_data['dependents']}
    Lifestyle: {st.session_state.form2_data['lifestyle']}
    Family Medical History: {st.session_state.form2_data['family_medical_history']}
    
    Follow Given Steps:
    1/ CALCULATE Risk Status Based On Personal And Health Information [Risk Status: Low,Neutral,High]
    2/ BASED ON RISK STATUS write an Insurance Underwriting
    3/ Consider The Following Format to write Insurance Underwriting
    
    Example: 
    Risk Status : Low
    {example}
    """

    underwriting_task = Task(
        name="Insurance Underwriting",
        model=openai_model,
        agent=insurance_agent,
        instructions=prompt,
    )

    output = LinearSyncPipeline(
        name="Insurance underwriting Pipline",
        completion_message="Underwriting completed",
        tasks=[
            underwriting_task
        ],
    ).run()

    answer = output[0]['task_output']

    return answer
```
This function defines the core logic for generating the insurance underwriting document.
Creates an Agent object from lyzr_automata specifying the agent's role and prompt persona (an expert insurance underwriter with specific tasks).
Constructs a long string variable named prompt that incorporates instructions for the AI model.
It includes placeholders for applicant information retrieved from the Streamlit app’s session state.
It outlines the steps to be followed:
Calculate risk status based on personal and health information (possible outputs — Low, Neutral, High).
Based on the risk status, write an insurance underwriting document.
Consider the provided example format for writing the document.
Creates a Task object specifying the task name (Insurance Underwriting), model to be used (from the API key input), agent, and instructions (the prompt string).
Defines a LinearSyncPipeline object specifying the pipeline name, completion message, and a list containing the underwriting task. This pipeline likely executes the task using the specified model and agent.
Runs the pipeline and retrieves the task output.
Returns the task output, which is the AI-generated insurance underwriting document.

**Main Function:**

```
def main():
    # Initialize session state to store form data
    if 'form1_data' not in st.session_state:
        st.session_state.form1_data = {"name": "", "age": "", "address": ""}
    if 'form2_data' not in st.session_state:
        st.session_state.form2_data = {"occupation": "", "annual_income": "", "marital_status": "", "dependents": "", "medical_history": "", "lifestyle": "", "family_medical_history": ""}

    # Create sidebar navigation
    page = st.sidebar.radio("Navigation", ["Applicant Information", "Personal And Health Information", "Result"])

    if page == "Applicant Information":
        st.title("Applicant Information")
        with st.form(key='form1'):
            st.session_state.form1_data['name'] = st.text_input("Enter your name:", st.session_state.form1_data['name'], placeholder="John Dae")
            st.session_state.form1_data['age'] = st.text_input("Enter your age:", st.session_state.form1_data['age'], placeholder="35")
            st.session_state.form1_data['address'] = st.text_input("Enter your Address:", st.session_state.form1_data['address'], placeholder="123, Elm Street,Springfield")
            submit_button = st.form_submit_button(label='Submit Applicant Details')
            if st.session_state.form1_data['name'] == "" or st.session_state.form1_data['age'] == "" or st.session_state.form1_data['address'] == "":
                st.error("Please fill All details")

    elif page == "Personal And Health Information":
        st.title("Personal And Health Information")
        with st.form(key='form2'):
            st.session_state.form2_data['occupation'] = st.text_input("Occupation:", st.session_state.form2_data['occupation'], placeholder="Software Engineer")
            st.session_state.form2_data['annual_income'] = st.text_input("Annual Income:", st.session_state.form2_data['annual_income'], placeholder="$100,000")
            st.session_state.form2_data['marital_status'] = st.selectbox("Marital Status:", ["Married", "Single", "Widowed", "Seperated", "Divorced"], index=0 if st.session_state.form2_data['marital_status'] == "" else ["Married", "Single", "Widowed", "Seperated", "Divorced"].index(st.session_state.form2_data['marital_status']))
            st.session_state.form2_data['medical_history'] = st.text_input("Medical_history:", st.session_state.form2_data['medical_history'], placeholder="No significant medical conditions reported")
            st.session_state.form2_data['dependents'] = st.number_input("Dependents:", min_value=0)
            st.session_state.form2_data['lifestyle'] = st.text_input("Lifestyle:", st.session_state.form2_data['lifestyle'], placeholder="Non-smoker, occasional alcohol consumption, regular exercise")
            st.session_state.form2_data['family_medical_history'] = st.text_input("Family Medical History:", st.session_state.form2_data['family_medical_history'], placeholder="Father is suffering with cancer.")
            submit_button = st.form_submit_button(label='Submit Form 2')

    elif page == "Result":
        st.title("Result Page")
        result = insurance_underwriting()
        st.markdown(result)
```
The main function serves as the entry point for the Streamlit app.
Initializes session state variables (form1_data and form2_data) as dictionaries to store applicant and personal/health information submitted through forms.
Creates a radio button element in the sidebar using st.sidebar.radio to allow users to navigate between different sections of the app (Applicant Information, Personal And Health Information, and Result).
The code utilizes conditional statements (based on the selected navigation option) to display forms and capture user input for applicant and personal/health information.
Each section uses Streamlit form elements like st.text_input, st.selectbox, and st.number_input to collect data.
Form submissions are handled using st.form_submit_button.
Basic input validation is included to ensure users fill out all required fields before submission.
The “Result” page retrieves the underwriting document using the insurance_underwriting function and displays it as markdown content using st.markdown.
**Running the App:**

```

if __name__ == "__main__":
    main()
```
An if __name__ == "__main__": block ensures the main function only runs when the script is executed directly.

try it now: https://lyzr-insurance-underwriter.streamlit.app/

For more information explore the website: [Lyzr](https://lyzr.ai)

Github: https://github.com/harshit-lyzr/Insurance_underwriting