From 0e99dfddd22590ad38ba54a14a8adc9d30f1a534 Mon Sep 17 00:00:00 2001 From: Nitzan Pomerantz <9297302+nitzpo@users.noreply.github.com> Date: Sun, 30 Nov 2025 23:54:00 +0200 Subject: [PATCH] Fix: Lower outlier detection threshold from 10 to 5 deals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Problem:** Outlier detection was skipped for 9-deal datasets due to threshold=10, allowing extreme outliers (₪920K vs ₪1.75M median) to skew valuation results. **Root Cause:** Real-world filtered queries (e.g., 3 rooms, ~60m²) often yield 5-9 comparables. Small samples NEED outlier filtering more than large ones (one outlier = 11-20% of dataset). **Solution:** Lower ANALYSIS_MIN_DEALS_FOR_OUTLIER_DETECTION: 10 → 5 **Impact:** - IQR & percentage methods valid with 5+ deals - Real estate valuation uses 5-10 comparables standard - Verified: 9-deal test now removes 2 outliers correctly **Changes:** - nadlan_mcp/config.py: Default threshold 10 → 5 - CLAUDE.md: Updated config documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- CLAUDE.md | 2 +- nadlan_mcp/config.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index cec08b2..9162bcd 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -345,7 +345,7 @@ The MCP now includes configurable outlier detection and robust statistical measu # Outlier Detection Strategy ANALYSIS_OUTLIER_METHOD=iqr # Options: iqr, percent, none (default: iqr) ANALYSIS_IQR_MULTIPLIER=1.0 # 1.0=aggressive, 1.5=moderate, 3.0=conservative (default: 1.0) -ANALYSIS_MIN_DEALS_FOR_OUTLIER_DETECTION=10 # Minimum deals needed (default: 10) +ANALYSIS_MIN_DEALS_FOR_OUTLIER_DETECTION=5 # Minimum deals needed (default: 5) # Percentage-based Backup Filtering (catches extreme outliers in heterogeneous data) ANALYSIS_USE_PERCENTAGE_BACKUP=true # Enable percentage backup (default: true) diff --git a/nadlan_mcp/config.py b/nadlan_mcp/config.py index 0e08e3a..17ec72a 100644 --- a/nadlan_mcp/config.py +++ b/nadlan_mcp/config.py @@ -64,7 +64,7 @@ class GovmapConfig: default_factory=lambda: float(os.getenv("ANALYSIS_IQR_MULTIPLIER", "1.0")) ) analysis_min_deals_for_outlier_detection: int = field( - default_factory=lambda: int(os.getenv("ANALYSIS_MIN_DEALS_FOR_OUTLIER_DETECTION", "10")) + default_factory=lambda: int(os.getenv("ANALYSIS_MIN_DEALS_FOR_OUTLIER_DETECTION", "5")) ) # Percentage-based backup filtering (catches extreme outliers in heterogeneous data)