<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Elio Coppola</title>
    <description>The latest articles on DEV Community by Elio Coppola (@rechtssysteem).</description>
    <link>https://dev.to/rechtssysteem</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4119990%2Fe9d3cd9f-153d-4907-ac16-6e1169f1663e.jpg</url>
      <title>DEV Community: Elio Coppola</title>
      <link>https://dev.to/rechtssysteem</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rechtssysteem"/>
    <language>en</language>
    <item>
      <title>How We Cut Target Leakage from 92% to 0.1% in Court Outcome Prediction (and Built a Triple-A MCP Server)</title>
      <dc:creator>Elio Coppola</dc:creator>
      <pubDate>Fri, 11 Sep 2026 00:39:12 +0000</pubDate>
      <link>https://dev.to/rechtssysteem/how-we-cut-target-leakage-from-92-to-01-in-court-outcome-prediction-and-built-a-triple-a-mcp-478g</link>
      <guid>https://dev.to/rechtssysteem/how-we-cut-target-leakage-from-92-to-01-in-court-outcome-prediction-and-built-a-triple-a-mcp-478g</guid>
      <description>&lt;p&gt;When building AI for court outcome prediction, there is a massive hidden trap that invalidates most benchmarks: target leakage.&lt;/p&gt;

&lt;p&gt;In Dutch court rulings, roughly 92% of raw texts contain the actual outcome verbatim (dictum or conclusion sentences like "the court dismisses the claim"). If you feed raw text to a model, it does not learn legal logic. It simply learns to read the answer back to you.&lt;/p&gt;

&lt;p&gt;Here is how we solved this across 609,715 cases, built a traceable LightGBM model, and exposed it as a zero-dependency open-core MCP server.&lt;/p&gt;

&lt;h1&gt;
  
  
  1. The Pre-Training Cut: 92% to 0.1% Leakage
&lt;/h1&gt;

&lt;p&gt;Before training any classifier, we implemented a strict sanitization step:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The dictum, summary lines, and outcome-announcing phrases are stripped from the text.&lt;/li&gt;
&lt;li&gt;We continuously measure residual outcome markers.&lt;/li&gt;
&lt;li&gt;Result: Leakage dropped from 92% to 0.1% (around 1 in 1,000 texts).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Only on this sanitized dataset did we train.&lt;/p&gt;

&lt;h1&gt;
  
  
  2. Why LightGBM Instead of an LLM
&lt;/h1&gt;

&lt;p&gt;We intentionally picked LightGBM over deep neural networks or fine-tuned LLMs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fast and cheap: Sub-10ms inference without GPUs.&lt;/li&gt;
&lt;li&gt;Traceable: Clear tree structures and feature importance.&lt;/li&gt;
&lt;li&gt;Deterministic calibration: If confidence drops below 55%, the model does not guess. It returns "insufficient certainty".&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  3. Benchmark on 609,715 Cases (Out-of-Fold)
&lt;/h1&gt;

&lt;p&gt;Evaluated through 5-fold cross-validation, strictly measured out-of-fold:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Overall Accuracy: 78.2% (against a 43.7% majority baseline)&lt;/li&gt;
&lt;li&gt;Macro-F1: 77.1%&lt;/li&gt;
&lt;li&gt;Per-Class F1:

&lt;ul&gt;
&lt;li&gt;Dismissed: 0.827&lt;/li&gt;
&lt;li&gt;Partly granted: 0.726&lt;/li&gt;
&lt;li&gt;Granted: 0.761&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Domain Breakdown:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Criminal Law (n=105,151): 82.6% accuracy, 0.804 macro-F1 (strongest performance)&lt;/li&gt;
&lt;li&gt;Administrative Law (n=316,273): 81.0% accuracy, 0.685 macro-F1 (high accuracy, but government victory is the majority class)&lt;/li&gt;
&lt;li&gt;Civil Law (n=188,177): 71.0% accuracy, 0.656 macro-F1 (most complex due to factual nuances)&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  4. Model Context Protocol (MCP) Interface
&lt;/h1&gt;

&lt;p&gt;To make this accessible to AI assistants (Claude, Cursor, autonomous agents), we wrapped the pipeline into an MCP server.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Zero external dependencies: Single Python file using only standard library (sys, json, urllib).&lt;/li&gt;
&lt;li&gt;Audited on Glama: Triple-A rating (5/5 on coherence and completeness).&lt;/li&gt;
&lt;li&gt;3 Tools:

&lt;ol&gt;
&lt;li&gt;rechtspraak_cijfers (keyless): Benchmark statistics and baseline metrics.&lt;/li&gt;
&lt;li&gt;lekkage_check (keyless): Paste any legal text to test for outcome leakage before and after the cut.&lt;/li&gt;
&lt;li&gt;voorspel_uitkomst (key required): Outcome risk classification.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Links
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;GitHub Repo (Apache 2.0): &lt;a href="https://github.com/rechtssysteem-ai/rechtssysteem-mcp" rel="noopener noreferrer"&gt;https://github.com/rechtssysteem-ai/rechtssysteem-mcp&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Live Benchmark: &lt;a href="https://rechtssysteem.ai/benchmark" rel="noopener noreferrer"&gt;https://rechtssysteem.ai/benchmark&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Glama Audit: &lt;a href="https://glama.ai/mcp/servers/@rechtssysteem-ai/rechtssysteem-mcp" rel="noopener noreferrer"&gt;https://glama.ai/mcp/servers/@rechtssysteem-ai/rechtssysteem-mcp&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Keyless API: &lt;a href="https://api.rechtssysteem.ai/cijfers" rel="noopener noreferrer"&gt;https://api.rechtssysteem.ai/cijfers&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Disclaimer: Not legal advice. Built as an open, verifiable yardstick for legal tech developers and agents.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>python</category>
      <category>machinelearning</category>
    </item>
  </channel>
</rss>
