"use client" import { useState } from "react" import { ChevronRight, Info, ArrowRight, Home, Building, Ruler, Calendar, Coins, Droplets, Wind, Sun, Car, School, ShoppingBag, } from "lucide-react" import Link from "next/link" import { Button } from "@/components/ui/button" import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card" import { Progress } from "@/components/ui/progress" import { Slider } from "@/components/ui/slider" import { FeatureImportanceChart } from "./components/feature-importance-chart" import { PriceComparisonChart } from "./components/price-comparison-chart" import { MapSidebar } from "../map/components/map-sidebar" import { SidebarProvider } from "@/components/ui/sidebar" import { ThemeProvider } from "@/components/theme-provider" export default function ModelExplanationPage() { const [activeStep, setActiveStep] = useState(1) const [propertySize, setPropertySize] = useState(150) const [propertyAge, setPropertyAge] = useState(5) // Sample data for the model explanation const propertyDetails = { address: "123 Sukhumvit Road, Bangkok", type: "Condominium", size: 150, // sqm bedrooms: 3, bathrooms: 2, age: 5, // years floor: 15, amenities: ["Swimming Pool", "Gym", "Security", "Parking"], predictedPrice: 15000000, // THB similarProperties: [ { address: "125 Sukhumvit Road", price: 14500000, size: 145, age: 6 }, { address: "130 Sukhumvit Road", price: 16200000, size: 160, age: 3 }, { address: "118 Sukhumvit Road", price: 13800000, size: 140, age: 7 }, ], features: [ { name: "Location", importance: 35, value: "Prime Area", impact: "positive" }, { name: "Size", importance: 25, value: "150 sqm", impact: "positive" }, { name: "Age", importance: 15, value: "5 years", impact: "neutral" }, { name: "Amenities", importance: 10, value: "4 amenities", impact: "positive" }, { name: "Floor", importance: 8, value: "15th floor", impact: "positive" }, { name: "Environmental Factors", importance: 7, value: "Low flood risk", impact: "positive" }, ], } const steps = [ { id: 1, title: "Property Details", description: "Basic information about the property", icon: Home, }, { id: 2, title: "Feature Analysis", description: "How each feature affects the price", icon: Ruler, }, { id: 3, title: "Market Comparison", description: "Comparison with similar properties", icon: Building, }, { id: 4, title: "Environmental Factors", description: "Impact of environmental conditions", icon: Droplets, }, { id: 5, title: "Final Prediction", description: "The predicted price and confidence level", icon: Coins, }, ] // Calculate a new price based on slider changes const calculateAdjustedPrice = () => { // Simple formula for demonstration const sizeImpact = (propertySize - 150) * 50000 // 50,000 THB per sqm const ageImpact = (5 - propertyAge) * 200000 // 200,000 THB per year newer return propertyDetails.predictedPrice + sizeImpact + ageImpact } const adjustedPrice = calculateAdjustedPrice() return (
{/* Header */}
Map Price Prediction Model
{/* Main content */}

Explainable Price Prediction Model

Understand how our AI model predicts property prices and what factors influence the valuation.

{/* Steps navigation */}
{steps.map((step) => ( ))}
{/* Step content */}
{/* Left column - Property details */}
Property Details {propertyDetails.address}
Type {propertyDetails.type}
Size {propertySize} sqm
Bedrooms {propertyDetails.bedrooms}
Bathrooms {propertyDetails.bathrooms}
Age {propertyAge} years
Floor {propertyDetails.floor}
Adjust Parameters See how changes affect the prediction
{propertySize} sqm
setPropertySize(value[0])} />
{propertyAge} years
setPropertyAge(value[0])} />
Adjusted Price {new Intl.NumberFormat("th-TH", { style: "currency", currency: "THB", minimumFractionDigits: 0, maximumFractionDigits: 0, }).format(adjustedPrice)}
{adjustedPrice > propertyDetails.predictedPrice ? "↑" : "↓"} {Math.abs(adjustedPrice - propertyDetails.predictedPrice).toLocaleString()} THB from original prediction
{/* Middle column - Step content */}
{activeStep === 1 && ( Property Overview Basic information used in our prediction model

Our AI model begins by analyzing the core attributes of your property. These fundamental characteristics form the baseline for our prediction.

Property Type

{propertyDetails.type} properties in this area have specific market dynamics

Size & Layout

{propertyDetails.size} sqm with {propertyDetails.bedrooms} bedrooms and{" "} {propertyDetails.bathrooms} bathrooms

Property Age

Built {propertyDetails.age} years ago, affecting depreciation calculations

Floor & View

Located on floor {propertyDetails.floor}, impacting value and desirability

)} {activeStep === 2 && ( Feature Analysis How different features impact the predicted price

Our model analyzes various features of your property and determines how each one contributes to the final price prediction. Below is a breakdown of the most important factors.

{propertyDetails.features.map((feature) => (
{feature.name} {feature.impact === "positive" ? "↑ Positive" : feature.impact === "negative" ? "↓ Negative" : "→ Neutral"}{" "} Impact
{feature.importance}%

{feature.value}

))}
)} {activeStep === 3 && ( Market Comparison How your property compares to similar properties in the area

Our model analyzes recent sales data from similar properties in your area to establish a baseline for comparison. This helps ensure our prediction is aligned with current market conditions.

({ name: p.address.split(" ")[0], price: p.price, size: p.size, age: p.age, }))} />

Similar Properties

{propertyDetails.similarProperties.map((property, index) => (
{property.address}
{property.size} sqm, {property.age} years old
{new Intl.NumberFormat("th-TH", { style: "currency", currency: "THB", minimumFractionDigits: 0, maximumFractionDigits: 0, }).format(property.price)}
))}
)} {activeStep === 4 && ( Environmental Factors How environmental conditions affect the property value

Environmental factors can significantly impact property values. Our model considers various environmental conditions to provide a more accurate prediction.

Flood Risk

Moderate

Historical data shows moderate flood risk in this area

Air Quality

Poor

Air quality is below average, affecting property value

Noise Level

Low

The area has relatively low noise pollution

Proximity to Amenities

Public Transport: 300m
Schools: 1.2km
Shopping: 500m
Hospitals: 2.5km
)} {activeStep === 5 && ( Final Prediction The predicted price and confidence level

Predicted Price

{new Intl.NumberFormat("th-TH", { style: "currency", currency: "THB", minimumFractionDigits: 0, maximumFractionDigits: 0, }).format(adjustedPrice)}
Confidence Level: 92%

Price Range

Based on our model's confidence level, the price could range between:

Lower Bound
{new Intl.NumberFormat("th-TH", { style: "currency", currency: "THB", minimumFractionDigits: 0, maximumFractionDigits: 0, }).format(adjustedPrice * 0.95)}
Prediction
{new Intl.NumberFormat("th-TH", { style: "currency", currency: "THB", minimumFractionDigits: 0, maximumFractionDigits: 0, }).format(adjustedPrice)}
Upper Bound
{new Intl.NumberFormat("th-TH", { style: "currency", currency: "THB", minimumFractionDigits: 0, maximumFractionDigits: 0, }).format(adjustedPrice * 1.05)}

Summary of Factors

The final prediction is based on a combination of all factors analyzed in previous steps:

  • Property characteristics (size, age, layout)
  • Location and neighborhood analysis
  • Market trends and comparable properties
  • Environmental factors and amenities
)}
) }