Spaces:
Build error
Build error
File size: 2,175 Bytes
04167c3 4b8f582 04167c3 4b8f582 537af35 3e8e14a 04167c3 ab198eb 04167c3 652a1c2 04167c3 29912f0 04167c3 ab198eb 04167c3 6a9db90 04167c3 6a9db90 9bead7d 52ceb79 6a9db90 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
import pandas as pd
import streamlit as st
import numpy as np
from PIL import Image
from sklearn.metrics import r2_score
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
import seaborn as sns
# loading the data
df = pd.read_csv('housing.csv')
# Renaming columns
df.rename(columns = {'Avg. Area Income':'Income','Avg. Area House Age':'House_age', 'Avg. Area Number of Rooms':'No_rooms',
'Avg. Area Number of Bedrooms':'No_bedrooms', 'Area Population':'population'},inplace = True)
# Image
image = Image.open('houseprice.jpg')
st.image(image,caption = 'House Price Prediction',width =500)
# HEADINGS
st.title('House Price Prediction')
st.sidebar.header('Housing Data')
#st.subheader('Training Data Stats')
#st.write(df.describe())
# X AND Y DATA
x = df.drop(['Price'], axis = 1)
y = df.iloc[:, -1]
x_train, x_test, y_train, y_test = train_test_split(x,y, test_size = 0.2, random_state = 0)
# FUNCTION
def user_report():
Income = st.sidebar.slider('Income', 17795,107702, 90000 )
House_age = st.sidebar.slider('House_age', 2,10, 4 )
No_rooms = st.sidebar.slider('No_rooms', 3,11, 6 )
No_bedrooms = st.sidebar.slider('No_bedrooms', 2,7, 4 )
population = st.sidebar.slider('population', 170,70000, 50000 )
user_report_data = {
'Income':Income,
'House_age':House_age,
'No_rooms':No_rooms,
'No_bedrooms':No_bedrooms,
'population':population
}
report_data = pd.DataFrame(user_report_data, index=[0])
return report_data
# Housing Data
user_data = user_report()
st.subheader('Your Customization of House ')
st.write(user_data)
# MODEL
lr = LinearRegression()
lr.fit(x_train, y_train)
user_result = lr.predict(user_data)
# VISUALISATIONS
st.title('Price of House your Dream House is : ')
# COLOR FUNCTION
if user_result[0]==0:
color = 'blue'
else:
color = 'red'
# OUTPUT
#st.subheader('Price of House your Dream House is : ')
st.subheader(str('Rs') + str(np.round(user_result)))
#st.title('output')
#st.subheader('r2_score: ')
#st.write(str(r2_score(y_test, lr.predict(x_test))*100)+'%')
st.write('For More Details Contact Thirdeye Data')
|