About Me Projects Articles Experience Education Contact
Resume PDF Switch to Portuguese 🇧🇷
Back to Projects
LEGAL ANALYTICS LABOR RISK PRESCRIPTIVE AI

Jurimetrics & Legal Ops: From Raw Data to a Bulletproof Employment Contract with Power BI & AI

How I built a Predictive and Prescriptive Labor Analytics PoC, audited BRL 1M+ in legal risk, and used reverse engineering to draft a litigation-proof contract.

Mar 2026 14 min read Power BI, Python, LLMs, Labor Compliance

Predictive Labor Risk & Probatory Impact Dashboard

Sample: 65 Claims | TRT5
Interactive Dashboard Anonymized Data (LGPD/GDPR Compliant)
Labor Jurimetrics © 2026

Tech Stack Used in this Project

Power BI
Advanced DAX
Python (Pandas)
Qwen2.5 7B (LLM)
Legal Ops & Compliance

1. Business Context

In the corporate world, labor liability management tends to be purely reactive: the company gets sued, the legal department scrambles to put out the fire, and the cycle repeats itself. But what happens when we inject Data Science, Artificial Intelligence, and Legal Ops into the equation to break this loop once and for all?

This article details the construction of a Predictive and Prescriptive Jurimetrics project, developed as a Proof of Concept (PoC). The target? Analyzing labor lawsuits involving the Security Guard function (CBO 5174-20) at TRT5 (the 5th Regional Labor Court, Bahia, Brazil), quantifying financial risk, and then applying reverse engineering to draft a Bulletproof Employment Contract.

The starting point was a pain widely shared across the security and facilities sector: a high volume of litigation tied to the Security Guard role. Historically, contracts for this function tend to be generic or even verbal. The lack of clear scope delimitation frequently opens the door to claims seeking equiparation to Armed Security Officer, triggering million-dollar liabilities in Hazard Pay Premiums and Overtime.

For this study, I collected a sample of 17 real labor rulings (which unfolded into 65 specific claims analyzed). This sampling served as a Toy Dataset to validate the technological pipeline architecture before scaling it to handle large data volumes.

2. Project Objectives

This BI and AI project was designed to answer three analytical layers, forming a complete data-to-action cycle:

  • Descriptive: What is actually happening in the historical case base? Map frequency, values, and patterns.
  • Predictive: What is the statistical probability of an adverse ruling and the projected financial impact?
  • Prescriptive: How can the company change its behavior (via contract design and governance) to prevent new litigation before it materializes?

3. Data, AI Extraction & ETL

The raw material consisted of piles of legal petitions in PDF format. To transform these unstructured documents into a bilingual, interactive dashboard, I structured a robust data pipeline with three core layers:

Why run the LLM locally? In the Legal Ops universe, sending petitions—packed with sensitive data—to public APIs like ChatGPT runs head-on into serious Compliance and LGPD (Brazil's Data Protection Law) barriers. I chose the Qwen2.5 7B Instruct model (quantized in Q4_K_M), an LLM highly capable at reasoning and semantic extraction in Portuguese, yet lightweight enough to run 100% offline on standard hardware. This AI served as the bridge between raw text and structured analytics: it read unstructured petitions and extracted, with high precision, the claims, financial values, and whether witness testimony was decisive—all while ensuring full LGPD compliance.

Python
import pandas as pd
import numpy as np

# Loading the dataset extracted by Qwen2.5
df_processos = pd.read_csv('base_jurimetria_trt5_bruta.csv')

# Null handling and financial conversion
df_processos['Valor_Causa'] = pd.to_numeric(df_processos['Valor_Causa'].fillna(0))

# Risk Classification Based on Claim Type
risco_alto = ['Adicional de Periculosidade', 'Horas Extras', 'Reconhecimento de Vínculo']
df_processos['Nivel_Risco'] = np.where(df_processos['Objeto_Acao'].isin(risco_alto), 'Alto', 'Moderado')

# Anonymization (LGPD Compliance)
df_processos['Reclamante'] = 'Anonimizado_' + df_processos.index.astype(str)

df_processos.to_csv('fato_pedidos_clean.csv', index=False)
print(f"Cleaned dataset: {len(df_processos)} rows ready for Power BI modeling.")

With data cleaned, I modeled the database in Power BI following Star Schema principles. To meet the requirement of an internationally readable dashboard, I developed DAX measures that dynamically translate the entire panel (from Portuguese to English) based on user selection, while also computing conditional financial risk.

DAX
// Dynamic & Bilingual Financial Risk Measure
Risco Inicial Declarado = 
VAR RiscoTotal = SUM('Fato_Pedidos'[Valor_Causa])
VAR IdiomaIngles = ISFILTERED('Dim_Idioma'[Idioma_EN])
RETURN
    IF(
        IdiomaIngles,
        FORMAT(RiscoTotal, "$ #,##0.00"),  // C-Level International Format
        FORMAT(RiscoTotal, "R$ #,##0.00")  // Local Format
    )

// Conditional Probability by Witness Factor
% Derrota Com Testemunha = 
CALCULATE(
    [% Derrota Global],
    KEEPFILTERS(Fato_Pedidos[Prova_Testemunhal] = "Sim")
)

4. Dashboard Overview & Key Insights

With the data architecture in place, Power BI unveiled the true face of the company's labor liability. Here are the two main analytical views:

  • Predictive View — The Witness Factor: The dashboard centralized a declared liability of BRL 1,049,758.45 and an aggregate adverse ruling probability of 43.08%. But the real predictive insight emerged from probatory correlation: without decisive witness testimony, the company's loss probability drops to 24.39%. When solid testimony is present, that probability skyrockets to 75.00%. This metric was a game-changer: it showed the legal team that settlements should be pursued immediately once the claimant brings forward strong witnesses at the evidentiary stage.
  • Risk Map by Claim Type: A procedural lead time of 207 days and a strikingly high settlement rejection rate (47.06%). The breakdown was surgical: Employment Relationship Recognition was the most frequent claim (15 cases); Overtime had 10 cases with a 40% loss probability; and Hazard Pay Premium stood at only 6 cases, but with an alarming 83.33% loss rate. The conclusion was undeniable: the company's current hiring model was fundamentally broken and generating nearly automatic liabilities.
  • Probatory Correlation Matrix: Cross-referencing claim types with the presence of witness evidence revealed that Hazard Pay and Overtime claims, when accompanied by testimony, presented near-certain adverse outcomes. This insight shifted the legal strategy from a blanket defense posture to targeted, evidence-driven settlement decisions.

Integrated Perspectives

5. Prescriptive Jurimetrics: The Bulletproof Contract

Analytics without action is just curiosity. The real differentiator of Legal Ops is closing the loop. Armed with the Risk Matrix, I applied Prescriptive Jurimetrics. If the pain points exposed by TRT5 and mapped by Power BI were "Overtime" and "Hazard Pay," the definitive solution required redesigning the very foundation of the employment relationship.

Using the same local LLM and the relevant Collective Bargaining Agreement as a rule framework, I developed a Bulletproof Employment Contract. Key mitigation clauses were direct responses to the data: adoption of the 12x36 shift regime (expressly provided under Brazil's CLT Art. 59-A), which settles Sunday and holiday work; explicit prohibition of firearm carrying and ostensive patrol rounds, forensically decoupling the role from Armed Security Officer status; and crystal-clear scope definition for the patrimonial Security Guard function (access control and passive observation only).

6. Financial & Strategic Perspective

From a financial standpoint, the BRL 1.05M in mapped liability represented not just a legal exposure but a predictable, recurring drain on the P&L. The dashboard's cohort analysis showed that each new hire under the old contract model carried a statistically measurable expected liability.

By implementing the Bulletproof Contract, the company effectively eliminates the structural conditions that generated the 83.33% hazard pay loss rate. The ROI of this prescriptive intervention is not theoretical—it is directly derived from the historical probability metrics displayed in the dashboard. Legal departments that adopt this approach shift from being reactive cost centers to becoming business intelligence partners that generate real savings.

7. Compliance, Governance & Legal Analytics Perspective

This project sits at the intersection of Legal Strategy, Data Governance, and AI Compliance. Running the Qwen2.5 model entirely offline was not a technical whim—it was a deliberate architectural decision to keep sensitive petition data under the company's full control, aligned with both LGPD (Brazil's data protection law) and GDPR principles. No claimant names, procedural identifiers, or case specifics ever left the local environment.

Legal Analytics Note: This is an analytical interpretation designed for business decision support and does not constitute formal legal advice. However, maintaining a recurring 83% loss rate on hazard pay claims without structural intervention exposes governance gaps and fiduciary risk for senior management. The prescriptive contract framework demonstrated here illustrates how data-driven Legal Ops can proactively align employment practices with judicial reality, materially reducing litigation exposure before cases are even filed.

8. Data Quality & Analytical Limitations

The sample size of 17 rulings (65 claims) was deliberately small for this PoC, designed to validate the pipeline architecture rather than deliver statistically exhaustive conclusions. The model's predictive signals—particularly the witness testimony correlation—are directionally robust but would benefit from scaling to hundreds of cases for tighter confidence intervals. Additionally, the LLM extraction layer, while highly accurate for structured fields like claim types and amounts, requires periodic human validation for nuanced legal classifications that may evolve with case law. The current limitation lies in the model's scope: it covers a single CBO function at one regional court. Scaling this architecture to multiple roles across different TRT jurisdictions is the natural next step for enterprise-grade deployment.

9. Impact & Strategic Recommendations

With the analytical foundations validated, I delivered strategic guidelines that reshape how the legal department interfaces with business operations:

Proactive Contract Design

Shift from generic templates to data-informed contracts where every clause responds to a mapped judicial risk, eliminating structural liability at the source.

Evidence-Driven Settlements

Use the witness testimony probability trigger (24% → 75% loss swing) as a hard decision rule for immediate settlement authorization during the evidentiary phase.

Scalable AI Pipeline

The offline LLM extraction architecture is jurisdiction-agnostic and ready to scale across multiple CBOs, courts, and legal domains with minimal adaptation.

10. Conclusion

This project demonstrates the transformative power of uniting Law, Data, and AI. We started with obscure labor petitions, extracted structured data without violating LGPD/GDPR using a locally-hosted Qwen2.5 model, audited over BRL 1 million in financial risk on Power BI, and concluded with a Preventive Contract capable of shielding the employer before litigation even arises.

When organizations move from subjective legal guesswork to Strategic Jurimetrics, the legal department ceases to be a reactive cost center and begins to operate as a business intelligence partner that generates tangible savings for the corporation. This is the future of Corporate Law and Legal Ops—and it's already happening.

Impressed by the Legal Analytics depth of this project?

Share this Jurimetrics and Legal Ops case with your executive network.

Does your organization need to align Legal Data, AI, and Compliance?

Talk to Darlan