Skip to the content.

🏠 House Price Predictor (Supervised Learning)

Python FastAPI React License

🧠 A supervised learning project for predicting house prices using Linear Regression and Decision Tree Regression, powered by FastAPI backend and React frontend with Vite.
💻 Designed for educational purposes, showcasing model training, evaluation, and real-time predictions with a modern web interface.


📘 Project Overview

Feature Description
🎯 Goal Predict house prices based on features like area, bedrooms, stories, and year built.
⚙️ Algorithms Used Linear Regression and Decision Tree Regression from Scikit-learn.
💾 Dataset Synthetic house data (~1000 rows) generated with Faker.
🧮 Tech Stack FastAPI • Scikit-learn • Pandas • NumPy • React • Vite • Tailwind CSS • Framer Motion • Recharts
🧱 Architecture Modular (Backend: API, Model, Data; Frontend: UI Components, Pages)
🪟 Compatibility Fully functional on Windows, Linux, and macOS.

🔹 Objective

To build and deploy a supervised learning system that predicts house prices using regression models, with an interactive UI for model exploration and real-time predictions.

🔹 Approach


💡 Key Features

Tech Stack

Backend

Frontend

Other Tools

Project Structure

📂 supervised-learning-project/
│
├── backend/
│   ├── 📝 README.md                # Backend-specific notes
│   ├── 🐍 main.py                 # FastAPI app with endpoints
│   ├── 📄 pyproject.toml          # Dependencies via Poetry
│   ├── 📋 requirements.txt        # Pip-installable dependencies
│   ├── 🐍 .python-version         # Specifies Python 3.11
│   ├── data/
│   │   ├── 📊 house_data.csv      # Synthetic dataset (~1000 rows)
│   │   └── 🐍 house_data.py       # Script to generate data
│   └── model/
│       ├── 🐍 __init__.py
│       ├── 🐍 trainer.py          # Model training logic
│       └── saved_models/          # Stores .pkl models and .json metrics
│
├── frontend/
│   ├── 📝 README.md               # Frontend-specific notes
│   ├── 🔍 eslint.config.js        # ESLint configuration
│   ├── 🌐 index.html             # Entry HTML
│   ├── 📦 package.json           # Dependencies
│   ├── 📜 tsconfig.app.json      # TypeScript config for app
│   ├── 📜 tsconfig.json          # Main TypeScript config
│   ├── 📜 tsconfig.node.json     # TypeScript config for Node
│   ├── ⚡ vite.config.ts          # Vite configuration
│   └── src/
│       ├── ⚛️ App.tsx            # Main app with routing and animations
│       ├── 🎨 index.css          # Global styles with Tailwind
│       ├── ⚛️ main.tsx           # React entry point
│       ├── components/
│       │   ├── 📉 ChartPanel.tsx     # Recharts-based line chart
│       │   ├── 🌟 Hero.tsx           # Hero section
│       │   ├── 📊 MetricCard.tsx     # Displays metrics like R²/MSE
│       │   ├── 🧭 Navbar.tsx         # Navigation bar
│       │   └── 🔮 PredictionPanel.tsx # Form for predictions
│       └── pages/
│           ├── 📚 About.tsx       # Educational content on ML concepts
│           ├── 📊 Dashboard.tsx   # Metrics, charts, and predictions
│           └── 🏠 Home.tsx        # Landing page with overview
│
├── requirements.txt
└── README.md

Installation

Prerequisites

Backend Setup

  1. Clone the repo:
    git clone <repo-url>
    cd supervised-learning-project/backend
    
  2. Install dependencies:
    • Using Poetry (recommended):
      poetry install
      
    • Or using pip:
      pip install -r requirements.txt
      
    • Generate data if needed (assumes house_data.py exists):
      python data/house_data.py
      
    • Run the API:
      uvicorn main:app --reload --port 8000
      
    • Access Swagger docs at http://localhost:8000/docs.

Frontend Setup

  1. Navigate to frontend:
    cd ../frontend
    
  2. Install dependencies:
    npm install
    
  3. Run the dev server:
    npm run dev
    

Usage

Backend API Endpoints

Frontend Pages

Example Workflow

  1. Start backend and train models via API or Dashboard.
  2. Use Dashboard to switch algorithms, view metrics/charts.
  3. Enter features in Prediction Panel for real-time predictions.

ML Details

Contributing

  1. Fork the repo.
  2. Create a feature branch: git checkout -b feature/new-feature.
  3. Commit changes: git commit -m 'Add new feature'.
  4. Push: git push origin feature/new-feature.
  5. Open a Pull Request.

License

MIT License. See LICENSE for details.

Acknowledgments

For issues, open a ticket or contact the maintainer.