#Imports import pandas as pd from sklearn.linear_model import LinearRegression import gradio as gr # Data Loading house_data = './India_house_Price300' 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=1000, maximum=30000, randomize=True, label="Area of the House"), gr.Slider(minimum=600, maximum=7000, randomize=True, step = 1,label="Living Area"), gr.Slider(minimum=1, maximum=8, randomize=True,step = 1, label="Number of Bedrooms"), gr.Slider(minimum=1, maximum=5, randomize=True,step = 1, label="Number of Bathrooms"), gr.Slider(minimum=1,maximum=3.5,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 Gradio-powered Indian House Prediction Model employs Linear Regression to estimate house prices based on essential features. The model is trained on a dataset that includes key factors influencing house prices in India. ***Features:*** Lot Area: The total area of the plot on which the house is built. Living Area: The total living space within the house. Number of Bedrooms: The count of bedrooms in the house. Number of Bathrooms: The count of bathrooms in the house. Number of Floors: The total number of floors in the house. ***How it works:*** *Linear Regression analyzes the relationship between these features and the house prices. By learning from historical data, the model establishes a linear equation that maps these input features to the predicted house price.* ***Usage:*** Input Features: Users input the specific values for the house's lot area, living area, number of bedrooms, bathrooms, and floors. Prediction: The model processes these inputs and provides an estimated house price based on the learned linear relationship. Application: This predictive model is valuable for individuals in the Indian real estate market looking to get an approximate idea of house prices based on specific characteristics. It can be a useful tool for property buyers, sellers, and real estate professionals to make informed decisions. ***Disclaimer:*** While this model provides estimations, actual house prices may vary due to additional factors not considered in this model. It is advisable to consult with real estate experts for precise valuations. Feel free to customize this description based on any additional details or specific characteristics of your model''' ) if __name__ == "__main__": demo.launch()