# Improved Criteria Evaluation System

## Overview
This document describes the improvements made to the FarmMatch property evaluation system to deliver higher quality, more accurate property assessments.

## What Was Improved

### 1. Enhanced Evaluation Prompt (`prompt.txt`)

#### **More Detailed Scoring Guidance**
- **Old**: Simple 1-5 scale with basic explanation
- **New**: Comprehensive scoring with clear meaning for each level:
  - 1 = Ongeschikt (unsuitable, fundamental issues)
  - 2 = Beperkt geschikt (limited suitability, major modifications needed)
  - 3 = Gemiddeld geschikt (average, mix of pros/cons)
  - 4 = Goed geschikt (good fit, minor adjustments)
  - 5 = Uitstekend geschikt (ideal, ready to use)

#### **Detailed Criterion Definitions**

**1. Market Garden (Regenerative)**
- **Requirements checklist**: Minimum 1500m², 6+ hours sunlight, water access, fertile soil
- **Positive factors** (+0.5-1 point): Existing garden, flat terrain, windbreak, proximity to nature
- **Negative factors** (-0.5-1 point): Steep slopes, shade, contaminated soil, too small

**2. Guest Accommodation**
- **Requirements**: Existing building with 2+ bedrooms, accessible roads
- **Positive factors**: Charming character property, quiet location, views, pool/garden, <45min to airport
- **Negative factors**: Major renovation needed, noisy location, remote, no tourist appeal

**3. Workshop / Food Processing**
- **Requirements**: Existing building 30m²+, sturdy construction, utilities available
- **Positive factors**: Large space (50m²+), high ceilings, 3-phase power, proper zoning
- **Negative factors**: Dilapidated, too small, no electricity, moisture issues

**4. Rental Units**
- **Requirements**: 3+ bedrooms OR multiple buildings OR large splitable property
- **Positive factors**: Separate entrances, multiple bathrooms, rental demand in area
- **Negative factors**: Too small, legal restrictions, low rental market

**5. Location (Coast/City/Airport)**
- **Distance categories**:
  - Airport: <1h excellent, 1-2h good, 2-3h fair, >3h poor
  - City: <15min excellent, 15-30min good, 30-60min fair, >60min remote
  - Coast: <30min excellent, 30-60min good, >60min far
- **Quality factors**: Direct flights from NL, paved roads, public transport

**6. Local Market Access**
- **Positive factors**: Within 15km of 5000+ inhabitants, tourist area, farmers markets, affluent region
- **Negative factors**: >30km remote, weak economy, low purchasing power

#### **Comprehensive Risk Assessment**

**Low Risk:**
- Permitted zoning
- Good building condition
- Stable growing economy
- Clear ownership
- EU property rights

**Medium Risk:**
- Zoning change may be needed
- Renovation €20-50k
- Seasonal economy
- Unclear local regulations

**High Risk:**
- Prohibited use
- Major renovation >€50k
- Unstable region
- Legal complications (leasehold, usufruct)
- Environmental risks (flooding, fires)

#### **Detailed Output Requirements**
- Each criterion must include **specific measurable details**:
  - Market Garden: m² size, sunlight hours, water source, soil type
  - Guest: bedroom count, maintenance state, travel times, investment needed
  - Workshop: m² size, construction quality, utilities, zoning compliance
  - Rental: number of units possible, local demand, regulations
  - Location: exact travel times, road quality, climate
  - Market: km to nearest city, local economy, tourism levels

### 2. Improved Criteria Weights (`analyze_from_urls.py`)

#### **Old Weights** (Total: 12.5)
```python
{
    "regeneratieve market garden": 2.0,
    "gastenverblijf": 2.5,
    "werkplaats": 2.0,
    "zelfstandige verhuureenheden": 1.5,
    "locatie": 3.0,          # Too high
    "afstand tot lokale markt": 1.5
}
```

#### **New Weights** (Total: 13.0) - More Balanced
```python
{
    "regeneratieve market garden": 2.5,  # ↑ Core business revenue
    "gastenverblijf": 3.0,               # Highest - main income + lifestyle
    "werkplaats": 2.0,                   # Value-added products
    "zelfstandige verhuureenheden": 2.5, # ↑ Important secondary income
    "locatie": 2.0,                      # ↓ Important but not decisive
    "afstand tot lokale markt": 1.0      # ↓ Less critical, nice to have
}
```

**Rationale:**
- **Guest accommodation** = highest weight (3.0) - primary income source and lifestyle quality
- **Market garden** increased to 2.5 - core business activity
- **Rental units** increased to 2.5 - significant passive income potential
- **Location** reduced to 2.0 - important but shouldn't override business viability
- **Local market** reduced to 1.0 - can often sell online/to tourists

### 3. Key Improvements Summary

| Aspect | Before | After | Impact |
|--------|--------|-------|--------|
| **Prompt Length** | ~50 lines | ~220 lines | More comprehensive guidance |
| **Score Definitions** | Vague | 5 clear levels with examples | More consistent scoring |
| **Requirements** | Implicit | Explicit checklists | Better validation |
| **Positive/Negative Factors** | Mixed into description | Clearly separated lists | Easier to evaluate |
| **Risk Assessment** | 3 categories | Detailed framework with examples | More accurate risk rating |
| **Output Format** | Brief explanations | Detailed measurable analysis | Higher quality data |
| **Weights Balance** | Arbitrary | Based on business impact | Better overall scores |

## Expected Benefits

### 1. **Higher Quality Analysis**
- More detailed evaluations with specific measurements
- Clear reasoning behind each score
- Consistent scoring across all properties

### 2. **Better Accuracy**
- Explicit requirements prevent inappropriate high scores
- Checklist approach reduces subjective bias
- Measurable criteria (m², hours, km) enable verification

### 3. **More Useful Output**
- Specific details (e.g., "needs €30k renovation" vs "needs work")
- Actionable insights for decision-making
- Better risk transparency

### 4. **Improved Ranking**
- Guest accommodation properly weighted as primary business
- Market garden and rental units elevated importance
- Location balanced - no longer overriding business viability

## Usage

The improved system is now active. To use it:

1. **Automatic** - The system now uses `prompt.txt` which contains the improved version
2. **Manual evaluation** - Use the Criteria Manager interface as before
3. **Batch re-evaluation** - Run `analyze_from_urls.py` to re-analyze all properties with new criteria

## Files Modified

1. **`prompt.txt`** - Replaced with improved version (original backed up to `prompt_original_backup.txt`)
2. **`analyze_from_urls.py`** - Updated criteria weights (lines 48-57)
3. **`prompt_improved.txt`** - New detailed prompt template (preserved for reference)

## Rollback

If needed, restore original system:
```bash
cp prompt_original_backup.txt prompt.txt
# Manually restore old weights in analyze_from_urls.py
```

## Next Steps

Consider:
1. Re-running evaluation on all 186 properties with new criteria
2. Comparing old vs new scores to validate improvements
3. Fine-tuning weights based on actual property performance
4. Adding more specific local market criteria (e.g., farmers market density)

---

**Created**: 2025-10-12
**Author**: Claude Code Assistant
**Version**: 2.0
