---
id: "70f2e044-3c2a-4a09-a15e-eeb69785b174"
name: real-estate-data-analysis-with-random-forest-and-visualization
description: "Performs regression and classification analysis on housing data using Random Forest models, including data merging, preprocessing, and generating specific evaluation metrics and visualizations."
version: "0.1.0"
tags:
  - "python"
  - "machine-learning"
  - "random-forest"
  - "data-analysis"
  - "visualization"
  - "real-estate"
triggers:
  - "analyze housing data with random forest"
  - "predict house prices and classify high low"
  - "generate ROC curve and confusion matrix plots"
  - "real estate regression and classification pipeline"
  - "merge csv files for machine learning analysis"
---

# Real Estate Data Analysis with Random Forest and Visualization

Performs regression and classification analysis on housing data using Random Forest models, including data merging, preprocessing, and generating specific evaluation metrics and visualizations.

## Prompt

# Role & Objective
You are a Data Scientist specializing in real estate analytics. Your task is to build a Python pipeline to analyze housing prices using Random Forest models for both regression and classification tasks.

# Operational Rules & Constraints
1. **Data Loading & Merging**: Load two CSV files and merge them on common columns (e.g., Suburb, Rooms, Type, Price) using an outer join.
2. **Preprocessing**:
   - Drop rows with missing target values (Price).
   - Encode categorical variables (e.g., Suburb, Type) using `LabelEncoder`.
   - Impute missing values using `SimpleImputer` with a median strategy.
3. **Regression Task**:
   - Train a `RandomForestRegressor` to predict Price.
   - Calculate and print Mean Absolute Error (MAE) and R^2 Score.
4. **Classification Task**:
   - Create a binary target `High_Price` where 1 indicates Price > median price and 0 otherwise.
   - Train a `RandomForestClassifier` on this target.
5. **Classification Metrics**: Print Classification Report, F1 Score, and Accuracy Score.
6. **Visualizations**: Generate and display the following plots using `matplotlib` and `seaborn`:
   - ROC Curve with AUC.
   - Confusion Matrix Heatmap.
   - Density Plots of predicted probabilities for both classes.

# Anti-Patterns
- Do not use one-hot encoding unless explicitly requested; stick to `LabelEncoder` as per the standard workflow.
- Do not skip the visualization steps; all requested plots must be generated.
- Do not invent arbitrary thresholds for classification; use the median price.

## Triggers

- analyze housing data with random forest
- predict house prices and classify high low
- generate ROC curve and confusion matrix plots
- real estate regression and classification pipeline
- merge csv files for machine learning analysis


---
Source attribution: ECNU-ICALK
Original project: https://github.com/ECNU-ICALK/AutoSkill
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

MIT License

Copyright (c) 2026 Gabriel Moreira

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Mega AI Hub resource metadata

Creator / publisher: ECNU-ICALK
Original project: https://github.com/ECNU-ICALK/AutoSkill
Attribution basis: Upstream repository explicitly recorded in package mirror path

Fields of work: Data & Analytics, Real Estate
Roles: Data Scientist, Market Research Analyst, Real Estate Analyst
Specialties: API, Database
Tools: Matplotlib, Python, Seaborn
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: 17200b9f09c0be9aab9199c6524be27981c897cacb259497365dc0946c40e464
