Manojkumarpandi commited on
Commit
bff1736
Β·
verified Β·
1 Parent(s): dc8c1b5

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +27 -0
  2. house_price_model.pkl +3 -0
  3. model.py +26 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pickle
3
+ import numpy as np
4
+
5
+ # Load Model
6
+ with open("house_price_model.pkl", "rb") as f:
7
+ model = pickle.load(f)
8
+
9
+ # Streamlit App
10
+ st.title("🏠 House Price Prediction")
11
+ st.write("Enter house details to predict price")
12
+
13
+ # Input Fields
14
+ CRIM = st.number_input("Crime Rate", 0.0, 100.0, step=0.1)
15
+ ZN = st.number_input("Proportion of Residential Land", 0.0, 100.0, step=0.1)
16
+ INDUS = st.number_input("Proportion of Non-Retail Business Acres", 0.0, 50.0, step=0.1)
17
+ CHAS = st.selectbox("Charles River (1: Yes, 0: No)", [0, 1])
18
+ NOX = st.number_input("Nitrogen Oxide Concentration", 0.0, 1.0, step=0.01)
19
+ RM = st.number_input("Average Rooms per Dwelling", 1.0, 10.0, step=0.1)
20
+ AGE = st.number_input("Proportion of Owner-Occupied Units Built Before 1940", 0.0, 100.0, step=0.1)
21
+ DIS = st.number_input("Weighted Distance to Employment Centers", 0.0, 10.0, step=0.1) # Missing Feature Added βœ…
22
+
23
+ # Prediction
24
+ if st.button("Predict"):
25
+ features = np.array([[CRIM, ZN, INDUS, CHAS, NOX, RM, AGE, DIS]]) # Now 8 features βœ…
26
+ prediction = model.predict(features)
27
+ st.success(f"Estimated House Price: ${prediction[0]:,.2f}")
house_price_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c6b674affa293155e18bffdb6764ae6ed41de7f461d64bd23a0d97d958d1355f
3
+ size 709
model.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import numpy as np
3
+ import pickle
4
+ from sklearn.model_selection import train_test_split
5
+ from sklearn.linear_model import LinearRegression
6
+ from sklearn.datasets import fetch_california_housing
7
+
8
+ # Load California Housing Dataset
9
+ data = fetch_california_housing()
10
+ df = pd.DataFrame(data.data, columns=data.feature_names)
11
+ df['PRICE'] = data.target
12
+
13
+ # Prepare Data
14
+ X = df.drop(columns=['PRICE'])
15
+ y = df['PRICE']
16
+ X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
17
+
18
+ # Train Model
19
+ model = LinearRegression()
20
+ model.fit(X_train, y_train)
21
+
22
+ # Save Model
23
+ with open("house_price_model.pkl", "wb") as f:
24
+ pickle.dump(model, f)
25
+
26
+ print("βœ… Model trained and saved as 'house_price_model.pkl'")