AI Agents
--

RuleWise Resilience Agent: Data Analysis, Python Execution & OCR Capabilities

By RuleWise Compliance Team

RuleWise Resilience Agent: Data Analysis, Python Execution & OCR Capabilities

Compliance and risk management increasingly require sophisticated data analysis, visualization, and verification capabilities. The RuleWise Resilience agent provides Python code execution, optical character recognition (OCR), and advanced analytical tools that help compliance teams extract insights from data, verify information, and communicate findings effectively.

What is RuleWise Resilience?

RuleWise Resilience is a specialized AI agent designed to perform data analysis, execute Python code, extract text from images and documents, and create visualizations. Unlike other RuleWise agents focused on regulatory knowledge or training, Resilience excels at computational tasks requiring mathematical precision, data manipulation, and visual representation.

Core Capabilities

Python Code Execution: Resilience runs Python code in a secure sandbox environment with access to powerful libraries including matplotlib, pandas, numpy, and scipy. This enables complex calculations, statistical analysis, and data transformations.

Data Visualization: Create professional charts, graphs, and plots including bar charts, line graphs, scatter plots, heatmaps, box plots, and more. Visualizations are generated as high-quality PNG files for use in reports and presentations.

Optical Character Recognition (OCR): Extract text from images, scanned documents, receipts, invoices, forms, and charts. Resilience uses advanced AI vision capabilities to read and interpret visual information accurately.

Multi-Method Verification: Cross-check data using multiple approaches—OCR to extract values, Python calculations to verify numbers, and visualizations to identify trends and anomalies. This provides robust validation for compliance verification tasks.

Statistical Analysis: Perform statistical calculations, trend analysis, regression modeling, hypothesis testing, and other analytical techniques essential for risk assessment and regulatory reporting.

Image Analysis: Analyze images beyond text extraction—read data from charts and graphs, analyze table data, identify visual patterns, and verify information shown in images.

When to Use RuleWise Resilience

Resilience excels at tasks requiring computational analysis and visual representation:

Data Visualization: "Analyze our quarterly transaction volumes by product type and create a stacked bar chart showing trends over the past four quarters."

OCR Text Extraction: "Extract all text from this scanned regulatory notice and identify key compliance obligations mentioned."

Financial Calculations: "Calculate the net present value of this compliance program investment over five years with a 10% discount rate, then create a chart showing cash flows."

Statistical Analysis: "Analyze our AML alert investigation times for the past year. Calculate mean, median, standard deviation, and create a distribution histogram."

Data Verification: "Verify the numbers in this quarterly board report by extracting data from the attached spreadsheet image and recalculating the totals."

Trend Identification: "Create a time-series plot showing our regulatory capital ratios over the past two years and identify any concerning trends."

Report Generation: "Read the data from this table image, perform variance analysis against budget, and create visualizations showing over/under performance by category."

How Resilience Works: The Analysis Process

Understanding Resilience's methodology helps you leverage its capabilities effectively.

Step 1: Task Understanding

When you request analysis, Resilience determines:

  • What type of analysis is required (calculation, visualization, OCR, etc.)
  • What data sources are involved (numbers, images, text, etc.)
  • What output format is needed (chart, calculation result, extracted text)
  • What level of detail and precision is appropriate

Step 2: Data Acquisition

Resilience gathers necessary data from:

  • Image URLs attached to your message (for OCR and image analysis)
  • Numerical data you provide in your request
  • Datasets or values mentioned in your query
  • Previously extracted or calculated information in conversation history

Step 3: Method Selection

Based on requirements, Resilience chooses appropriate methods:

For Visualization: Determines chart type (bar, line, scatter, etc.), data transformation needed, styling requirements, and axis configurations.

For OCR: Identifies optimal text extraction approach, determines structure (tables, lists, paragraphs), and formats output appropriately.

For Calculations: Selects mathematical methods, determines precision requirements, identifies intermediate steps needed, and validates results.

For Verification: Determines multiple verification methods (e.g., OCR + calculation), cross-references results, identifies discrepancies, and provides confidence assessment.

Step 4: Execution

Resilience executes the analysis:

Python Execution: Runs code in secure sandbox, handles errors gracefully, generates outputs (calculations, files, plots), and captures results.

OCR Processing: Analyzes images using AI vision, extracts text with structure preservation, handles tables and complex layouts, and validates extraction quality.

Visualization Creation: Generates professional plots, applies appropriate styling, saves as PNG files, and ensures readability and clarity.

Step 5: Results Delivery

Resilience provides results with:

  • Clear summary of findings
  • Generated visualizations or extracted text
  • Calculation results with appropriate precision
  • Verification status and confidence levels
  • Suggested next steps or additional analysis

Best Practices for Using Resilience

Provide Clear Data Context

Good: "Here are our monthly AML alert volumes for Q4 2024: Oct: 245, Nov: 287, Dec: 312. Create a line chart showing the trend and calculate the month-over-month growth rate."

Less Effective: "Make a chart with these numbers: 245, 287, 312."

Context helps Resilience create meaningful, well-labeled outputs.

Specify Visualization Requirements

When requesting charts:

  • Indicate preferred chart type if you have one
  • Specify axis labels and titles
  • Mention any specific colors or styling needs
  • Indicate size requirements if relevant
  • Request legends, gridlines, or annotations as needed

Example: "Create a horizontal bar chart comparing our five largest AML training program costs, sorted by amount, with clear labels showing department names and dollar amounts."

Attach Images for OCR

When using OCR capabilities:

  • Ensure images are clear and well-lit
  • Provide context about what the image contains
  • Indicate specific information you want extracted
  • Mention any special formatting (tables, lists, forms)

Example: "This image shows our monthly regulatory reporting checklist. Extract all task names, due dates, and assigned owners from the table."

Critical: Always attach image URLs when requesting image analysis. Resilience cannot access images unless URLs are provided.

Request Multi-Step Analysis

Resilience can perform complex, multi-step workflows:

  1. "Extract the transaction volumes from this chart image"
  2. "Calculate year-over-year growth rates"
  3. "Create a new visualization showing growth trends"
  4. "Identify any quarters with negative growth"

Each step builds on previous results for comprehensive analysis.

Use for Verification Tasks

Leverage Resilience's multi-method verification:

"I need to verify the calculations in this financial crime risk assessment. The image shows a risk matrix with scores. Extract the individual risk scores, recalculate the weighted total risk score, and confirm whether the documented total is correct."

Specify Precision Requirements

For calculations, indicate needed precision:

  • "Calculate to two decimal places"
  • "Round to nearest whole number"
  • "Express as percentage to one decimal place"
  • "Show full precision for verification purposes"

Common Use Cases

Regulatory Reporting Analysis

Analyze regulatory reporting data:

Example: "Our last four quarterly regulatory capital ratios were: Q1: 18.2%, Q2: 17.8%, Q3: 17.5%, Q4: 17.9%. Create a line chart showing the trend, calculate the average ratio, and identify the quarter with minimum ratio."

Resilience creates professional visualizations for board presentations and regulatory submissions.

Transaction Monitoring Metrics

Analyze AML transaction monitoring effectiveness:

Example: "Last month we generated 487 AML alerts: 23 escalated to SAR, 464 closed as false positive. This month: 512 alerts, 31 SARs, 481 false positives. Calculate the SAR conversion rate for each month and create a visualization showing alert volumes and conversion rates."

Training Effectiveness Measurement

Analyze compliance training data:

Example: "We trained 145 employees on AML this quarter. Pre-training quiz average: 67%. Post-training average: 89%. Create a visualization comparing scores and calculate the improvement percentage."

Risk Assessment Scoring

Calculate risk scores systematically:

Example: "Our risk assessment model uses these weights: Inherent Risk 40%, Control Effectiveness 30%, Residual Risk 30%. Business Unit A scores: 75, 85, 60. Calculate the weighted overall risk score."

Document Data Extraction

Extract data from scanned documents:

Example: "This image is a scanned invoice from our compliance consultant. Extract the vendor name, invoice number, date, line items with amounts, and total amount due."

Trend Analysis

Identify patterns in compliance data:

Example: "Here's our monthly gifts and entertainment spend by quarter for two years: [data]. Create a time-series plot, calculate quarterly averages, identify any seasonal patterns, and flag any months exceeding 150% of average."

Benchmark Comparison

Compare performance against benchmarks:

Example: "Our AML investigation closure time: Average 12 days, Median 9 days. Industry benchmark: Average 15 days, Median 11 days. Create a comparison bar chart and calculate our percentage difference from benchmark."

Board Reporting Visualizations

Create executive-level visualizations:

Example: "Create a professional dashboard-style visualization showing our top 5 compliance KPIs for Q4: Training completion (94%), Policy attestation (97%), AML alert backlog (23), Control testing completion (89%), Regulatory submissions on-time (100%). Use a horizontal bar chart with color coding: green for above target, yellow for at target, red for below."

Python Code Execution Capabilities

Resilience's Python capabilities enable sophisticated analysis:

Available Libraries

Resilience has access to:

  • matplotlib: Data visualization and plotting
  • pandas: Data manipulation and analysis
  • numpy: Numerical computing and arrays
  • scipy: Scientific computing and statistics
  • datetime: Date and time manipulation
  • math: Mathematical functions
  • statistics: Statistical calculations

Code Execution Guidelines

Resilience executes Python code that:

  • Performs calculations and data transformations
  • Creates visualizations and saves them as PNG files
  • Processes numerical data and arrays
  • Performs statistical analysis
  • Handles dates and time-series data

Resilience cannot:

  • Access external files or network resources
  • Use interactive functions requiring user input
  • Run infinite loops or long-running processes
  • Import libraries outside the approved list

Example Python Tasks

Statistical Calculations:

import numpy as np
data = [12, 15, 14, 18, 16, 19, 17, 20]
mean = np.mean(data)
std = np.std(data)
print(f"Mean: {mean:.2f}, Std Dev: {std:.2f}")

Visualization Creation:

import matplotlib.pyplot as plt
categories = ['AML', 'Market Conduct', 'Data Protection', 'Conflicts']
values = [45, 32, 28, 19]
plt.bar(categories, values)
plt.title('Compliance Issues by Category')
plt.ylabel('Number of Issues')
plt.savefig('compliance_issues.png')

Time Series Analysis:

import pandas as pd
dates = pd.date_range('2024-01-01', periods=12, freq='M')
values = [245, 267, 289, 301, 287, 295, 310, 324, 318, 330, 345, 352]
df = pd.DataFrame({'Date': dates, 'Alerts': values})
growth = ((df['Alerts'].iloc[-1] - df['Alerts'].iloc[0]) / df['Alerts'].iloc[0]) * 100
print(f"Annual growth: {growth:.1f}%")

OCR and Image Analysis

Resilience's vision capabilities extend beyond simple text extraction:

OCR Use Cases

Invoice Processing: Extract vendor details, line items, amounts, and totals from scanned invoices.

Form Data Extraction: Pull data from completed forms, applications, or questionnaires.

Chart Reading: Extract data points from charts, graphs, or plots in images.

Table Extraction: Pull structured data from tables in images or scanned documents.

Receipt Parsing: Extract transaction details from receipts for expense verification.

Certificate Verification: Read information from certificates, licenses, or credentials.

Image Analysis Capabilities

Beyond text extraction, Resilience can:

  • Describe chart types and visual structure
  • Identify trends visible in graphical data
  • Verify consistency between visual and textual information
  • Analyze table layouts and relationships
  • Identify missing or unclear information

OCR Best Practices

Image Quality: Use clear, well-lit, high-resolution images for best results.

Orientation: Ensure images are properly oriented (not upside down or sideways).

Context: Explain what the image contains to guide extraction.

Verification: For critical data, cross-verify OCR results.

Format: Indicate desired output format (table, list, paragraph, structured data).

Multi-Method Verification

Resilience's verification capabilities provide confidence in data accuracy:

Verification Workflow

Step 1 - OCR Extraction: Extract values from source document image.

Step 2 - Calculation: Recalculate totals, percentages, or derived values using Python.

Step 3 - Comparison: Compare OCR-extracted results with Python calculations.

Step 4 - Discrepancy Analysis: Identify any differences and analyze causes.

Step 5 - Confidence Assessment: Provide confidence level in verification results.

Verification Use Cases

Regulatory Report Validation: "Verify the calculations in this regulatory capital report by extracting values from the image and recalculating ratios."

Financial Statement Review: "Verify the year-over-year variance calculations in this quarterly financial statement."

Risk Score Auditing: "Verify that the overall risk scores in this assessment were calculated correctly based on the component scores shown."

Advanced Resilience Techniques

Multi-Dimensional Analysis

Analyze data across multiple dimensions:

"Our AML alerts by month and risk category: High-risk: [monthly data], Medium-risk: [monthly data], Low-risk: [monthly data]. Create a stacked area chart showing composition over time and calculate what percentage of total alerts are high-risk."

Correlation Analysis

Identify relationships between variables:

"We have monthly data for training completion rates and compliance incidents. Training: [data], Incidents: [data]. Calculate the correlation coefficient and create a scatter plot to visualize any relationship."

Forecasting and Projection

Project future trends:

"Based on our quarterly compliance costs for the past two years [data], calculate the trend line and project costs for the next four quarters. Visualize historical and projected data."

Anomaly Detection

Identify outliers and unusual patterns:

"Here's our daily transaction monitoring alert volume for the past 90 days [data]. Identify any days that are statistical outliers (more than 2 standard deviations from mean) and flag them for investigation."

Comparative Analysis

Compare across categories, time periods, or entities:

"Compare our three business units on five compliance metrics [data]. Create a radar/spider chart showing the profile for each unit and calculate which unit has the highest overall compliance score."

Combining Resilience with Other Agents

Resilience integrates powerfully with other RuleWise agents:

Insight + Resilience: Research regulations with Insight, then analyze compliance data with Resilience.

"Use Insight to find regulatory reporting requirements, then use Resilience to verify our quarterly report calculations."

Inspector + Resilience: Conduct simulations with Inspector, then analyze results with Resilience.

"Run quarterly Inspector readiness simulations for a year, then use Resilience to create trend charts and calculate improvement rates."

Quest + Resilience: Analyze training data with Resilience, then create programs with Quest.

"Use Resilience to identify which compliance topics have lowest quiz scores, then use Quest to create enhanced training on those topics."

Probe + Resilience: Prepare data for interviews with Resilience.

"We have a regulatory interview tomorrow. Use Resilience to create visualizations of our key compliance metrics for the presentation."

Real-World Example

Here's how a Guernsey investment firm uses Resilience:

Weekly Metrics: Every Monday, the compliance team uses Resilience to create visualizations of key compliance metrics (alert volumes, investigation times, training completion) for the weekly executive dashboard.

Quarterly Board Reporting: Before board meetings, Resilience creates professional charts showing compliance trends, risk scores, and performance against targets.

Regulatory Submissions: When preparing regulatory reports, Resilience verifies all calculations by recalculating values and comparing with drafted reports.

Vendor Invoice Processing: Resilience extracts data from consultant invoices, categorizes spending, and creates spending analysis reports.

Risk Assessment: During annual risk assessments, Resilience calculates weighted risk scores, creates heat maps, and identifies highest-risk areas.

Training Analysis: After compliance training programs, Resilience analyzes pre/post quiz scores, calculates improvement rates, and identifies topics needing reinforcement.

Conclusion

RuleWise Resilience brings computational power, data visualization, and verification capabilities to compliance and risk management. By combining Python execution, OCR, and analytical tools, Resilience helps compliance teams extract insights from data, verify information accuracy, and communicate findings effectively.

Start with simple visualizations and calculations, then expand to more sophisticated analysis as you become comfortable with Resilience's capabilities. The agent's versatility makes it valuable across numerous compliance use cases.

Ready to analyze your compliance data? Start your first Resilience task today.

Related articles: Agent Best Practices Guide and Multi-Agent Workflows