Aomsin's picture
Update app.py
5e3e2cb
import joblib
import pandas as pd
import streamlit as st
model = joblib.load('model.joblib')
unique_values = joblib.load('unique_values.joblib')
unique_area_type = unique_values["Area Type"]
unique_city = unique_values["City"]
unique_furnishing = unique_values["Furnishing Status"]
unique_tenant = unique_values["Tenant Preferred"]
unique_contact = unique_values["Point of Contact"]
def main():
st.title("House Rent Prediction")
with st.form("questionaire"):
BHK = st.slider("BHK",min_value=1,max_value=6)
Size = st.slider("Size",min_value=10,max_value=8000)
Bathroom = st.slider("Bathroom",min_value=1,max_value=10)
AreaType = st.selectbox("Area Type",options=unique_area_type)
city = st.selectbox("City",options=unique_city)
FurnishingStatus = st.selectbox("Furnishing Status",options=unique_furnishing)
TenantPreferred = st.selectbox("Tenant Preferred",options=unique_tenant)
PointofContact = st.selectbox("Point of Contact",options=unique_contact)
# clicked==True only when the button is clicked
clicked = st.form_submit_button("Predict Rent")
if clicked:
result=model.predict(pd.DataFrame({"BHK": [BHK],
"Size": [Size],
"Bathroom": [Bathroom],
"Area Type": [AreaType],
"City": [city],
"Furnishing Status": [FurnishingStatus],
"Tenant Preferred": [TenantPreferred],
"Point of Contact": [PointofContact]}))
# Show prediction
st.success(f'Your predicted Rent is {result}')
if __name__ == "__main__":
main()