File size: 1,176 Bytes
bff1736
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import pickle
import numpy as np

# Load Model
with open("house_price_model.pkl", "rb") as f:
    model = pickle.load(f)

# Streamlit App
st.title("🏠 House Price Prediction")
st.write("Enter house details to predict price")

# Input Fields
CRIM = st.number_input("Crime Rate", 0.0, 100.0, step=0.1)
ZN = st.number_input("Proportion of Residential Land", 0.0, 100.0, step=0.1)
INDUS = st.number_input("Proportion of Non-Retail Business Acres", 0.0, 50.0, step=0.1)
CHAS = st.selectbox("Charles River (1: Yes, 0: No)", [0, 1])
NOX = st.number_input("Nitrogen Oxide Concentration", 0.0, 1.0, step=0.01)
RM = st.number_input("Average Rooms per Dwelling", 1.0, 10.0, step=0.1)
AGE = st.number_input("Proportion of Owner-Occupied Units Built Before 1940", 0.0, 100.0, step=0.1)
DIS = st.number_input("Weighted Distance to Employment Centers", 0.0, 10.0, step=0.1)  # Missing Feature Added βœ…

# Prediction
if st.button("Predict"):
    features = np.array([[CRIM, ZN, INDUS, CHAS, NOX, RM, AGE, DIS]])  # Now 8 features βœ…
    prediction = model.predict(features)
    st.success(f"Estimated House Price: ${prediction[0]:,.2f}")