kidu14 commited on
Commit
4c147c4
·
verified ·
1 Parent(s): ce4d279

initial commit

Browse files
Files changed (6) hide show
  1. README.md +11 -14
  2. app.py.py +82 -0
  3. house_rent_prediction_all.ipynb +0 -0
  4. model.joblib +3 -0
  5. requirements.txt +8 -0
  6. scaler.joblib +3 -0
README.md CHANGED
@@ -1,14 +1,11 @@
1
- ---
2
- title: House Rental Predictor
3
- emoji: 🌍
4
- colorFrom: purple
5
- colorTo: gray
6
- sdk: gradio
7
- sdk_version: 5.25.0
8
- app_file: app.py
9
- pinned: false
10
- license: mit
11
- short_description: 'This app predicts rental prices based on given properties '
12
- ---
13
-
14
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+ # Real Estate Rent Prediction
2
+
3
+ This app predicts house rental prices based on input features like location, size, and furnishing status.
4
+
5
+ - Built with: Gradio, Scikit-learn, TensorFlow
6
+ - Model: Linear Regression
7
+ - UI: Gradio Interface
8
+
9
+ Just enter the values, and get your rent prediction instantly!
10
+
11
+ **Note:** The model was trained on foreign data, so the predictions are based on foreign country cities and area types.
 
 
 
app.py.py ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """GradioUI.ipynb
3
+
4
+ Automatically generated by Colab.
5
+
6
+ Original file is located at
7
+ https://colab.research.google.com/drive/13606Sv5nfECx_rbwG8DGuXDHspZ6t4kA
8
+ """
9
+
10
+ import gradio as gr
11
+ import joblib
12
+ import numpy as np
13
+ import pandas as pd
14
+ from sklearn.preprocessing import MinMaxScaler
15
+
16
+ # Load the model and scaler
17
+ model = joblib.load('model.joblib')
18
+ scaler = joblib.load('scaler.joblib')
19
+
20
+ # Prediction function
21
+ def predict_rent(BHK, Size, Furnishing_Status, Bathroom, floor_number,
22
+ Area_Type, City):
23
+
24
+ try:
25
+ # Prepare the input DataFrame with dummy variables
26
+ input_data = pd.DataFrame({
27
+ 'BHK': [BHK],
28
+ 'Size': [Size],
29
+ 'Furnishing Status': [Furnishing_Status],
30
+ 'Bathroom': [Bathroom],
31
+ 'floor_number': [floor_number],
32
+ 'Area Type_Carpet Area': [0],
33
+ 'Area Type_Super Area': [0],
34
+ 'City_Chennai': [0],
35
+ 'City_Delhi': [0],
36
+ 'City_Hyderabad': [0],
37
+ 'City_Kolkata': [0],
38
+ 'City_Mumbai': [0],
39
+ })
40
+
41
+ # Update one-hot encoded fields
42
+ if Area_Type == "Carpet Area":
43
+ input_data['Area Type_Carpet Area'] = [1]
44
+ elif Area_Type == "Super Area":
45
+ input_data['Area Type_Super Area'] = [1]
46
+
47
+ if City == "Chennai":
48
+ input_data['City_Chennai'] = [1]
49
+ elif City == "Delhi":
50
+ input_data['City_Delhi'] = [1]
51
+ elif City == "Hyderabad":
52
+ input_data['City_Hyderabad'] = [1]
53
+ elif City == "Kolkata":
54
+ input_data['City_Kolkata'] = [1]
55
+ elif City == "Mumbai":
56
+ input_data['City_Mumbai'] = [1]
57
+
58
+ rent = model.predict(input_data)[0]
59
+ return f"💰 Predicted Rent: ${rent:,.2f} per month"
60
+
61
+ except Exception as e:
62
+ return f"❌ Error: {e}"
63
+
64
+ # Inputs
65
+ inputs = [
66
+ gr.Number(label="BHK", minimum=1, maximum=6),
67
+ gr.Number(label="Size (in sqft)", minimum=100, maximum=80000),
68
+ gr.Number(label="Furnishing Status (0: Unfurnished, 1: Semi-Furnished, 2: Furnished)", minimum=0, maximum=2),
69
+ gr.Number(label="Bathrooms", minimum=1, maximum=3),
70
+ gr.Number(label="Floor Number", minimum=0, maximum=10),
71
+ gr.Dropdown(choices=["Carpet Area", "Super Area"], label="Area Type"),
72
+ gr.Dropdown(choices=["Chennai", "Delhi", "Hyderabad", "Kolkata", "Mumbai"], label="City"),
73
+ ]
74
+
75
+ # Gradio UI
76
+ gr.Interface(
77
+ fn=predict_rent,
78
+ inputs=inputs,
79
+ outputs=gr.Textbox(label="Prediction Result"),
80
+ title="🏡 Rent Prediction App",
81
+ description="Welcome to Leo's RealEstate! Our valued customer, please fill your preferences to get the predicted monthly rent."
82
+ ).launch()
house_rent_prediction_all.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
model.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fd5179f7144a89200e3ab67b5b114368f50f4f170db25368339c520d16af1fbc
3
+ size 1257
requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ gradio
2
+ joblib
3
+ numpy
4
+ pandas
5
+ seaborn
6
+ matplotlib
7
+ scikit-learn
8
+ tensorflow
scaler.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fe99e53249f8f5e3f7f2e6c3240443d3bc821ffc3bd4281d497318ef31f5d6f9
3
+ size 1247