Pravincoder's picture
Descritpion bug fix
845e256 verified
raw
history blame
2.85 kB
#Imports
import pandas as pd
from sklearn.linear_model import LinearRegression
import gradio as gr
# Data Loading
house_data = './Indiahouse'
houses = pd.read_csv(house_data)
# Feature Selection
X_features = ['Area','living area','number of bedrooms','number of bathrooms','number of floors']
X = houses[X_features]
y_target = ['Price']
y = houses[y_target]
# Data Split
from sklearn.model_selection import train_test_split
X_train, X_test,y_train,y_test = train_test_split(X,y, train_size = 0.8, test_size = 0.2, random_state = 100)
# Modeling
lm = LinearRegression()
lm.fit(X_train, y_train)
# Gradio Function
def input(area,living_area,bedrooms,bathrooms,floors):
input = [area,living_area,bedrooms,bathrooms,floors]
output = lm.predict([input])
return int(output)
demo = gr.Interface(
input,
[
gr.Slider(minimum=800, maximum=18500, randomize=True, label="Area of the House ***(Sq.mtr)***"),
gr.Slider(minimum=350, maximum=3000, randomize=True, step = 1,label="Living Area ***(Sq.mtr)***"),
gr.Slider(minimum=1, maximum=4, randomize=True,step = 1, label="Number of Bedrooms"),
gr.Slider(minimum=1, maximum=3, randomize=True,step = 1, label="Number of Bathrooms"),
gr.Slider(minimum=1,maximum=3,randomize=True,step=0.5,label="Number of stories/Floors")
],
"number",
examples=[
[1000, 600, 1, 1, 1],
[2000,1200,2,3,1],
[4000,1900,2,3,2],
[28000,3000,5,3,3],
],
title="Indian House Price Prediction Model",
description="""
***Overview:***
This model predicts house prices in India using Linear Regression. Trained on key features like lot area, living area, bedrooms, bathrooms, and floors, it estimates house prices based on historical data.
***🚀Features:***
- Lot Area
- Living Area
- Bedrooms
- Bathrooms
- Floors
***⚒How it works:***
Linear Regression analyzes the relationship between input features and house prices, establishing a linear equation for predictions.
***📝Usage:***
1. Input specific values for lot area, living area, bedrooms, bathrooms, and floors.
2. Get an estimated house price based on the learned linear relationship.
***📳Application:***
Useful for individuals in the Indian real estate market to gauge approximate house prices. Ideal for property buyers, sellers, and real estate professionals for informed decision-making.
***📊Disclaimer:***
This model provides estimations. Actual house prices may vary due to unconsidered factors. Consult real estate experts for precise valuations.
***🤗Demo Info:***
- Mean Absolute Error (MAE): 0.11
- The Output of the Model depends on the DataSet
- For demo and learning purposes only.
***♥Feel free to explore and understand how key features influence house prices in India.♥***
"""
)
if __name__ == "__main__":
demo.launch()