Spaces:
Sleeping
Sleeping
Application file
Browse files
app.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from sklearn.linear_model import LinearRegression
|
3 |
+
import pickle
|
4 |
+
import numpy as np
|
5 |
+
|
6 |
+
# Load the pre-trained model and scaler
|
7 |
+
with open('regression_model.pkl', 'rb') as model_file:
|
8 |
+
model = pickle.load(model_file)
|
9 |
+
|
10 |
+
with open('scaler.pkl', 'rb') as scaler_file:
|
11 |
+
scaler = pickle.load(scaler_file)
|
12 |
+
|
13 |
+
# Streamlit Input Fields
|
14 |
+
st.title("Boston Housing Pred App ⌨🏠")
|
15 |
+
crim = st.number_input("Enter the crim", value=0.0)
|
16 |
+
zn = st.number_input("Enter the zn", value=0.0)
|
17 |
+
indus = st.number_input("Enter the indus", value=0.0)
|
18 |
+
chas = st.number_input("Enter the chas", value=0.0)
|
19 |
+
nox = st.number_input("Enter the nox", value=0.0)
|
20 |
+
rm = st.number_input("Enter the rm", value=0.0)
|
21 |
+
age = st.number_input("Enter your age", value=0.0)
|
22 |
+
dis = st.number_input("Enter the dis", value=0.0)
|
23 |
+
rad = st.number_input("Enter the rad", value=0.0)
|
24 |
+
ptratio = st.number_input("Enter the ptratio", value=0.0)
|
25 |
+
b = st.number_input("Enter B", value=0.0)
|
26 |
+
istat = st.number_input("Enter istat", value=0.0)
|
27 |
+
tax = st.number_input("Enter tax", value=0.0)
|
28 |
+
|
29 |
+
# Predict when button is pressed
|
30 |
+
if st.button("Predict"):
|
31 |
+
# Prepare the input data
|
32 |
+
input_data = np.array([[crim,zn, indus, chas, nox, rm, age, dis, rad, ptratio, b, istat, tax]])
|
33 |
+
|
34 |
+
# Scale the input data
|
35 |
+
input_data_scaled = scaler.transform(input_data)
|
36 |
+
|
37 |
+
# Make the prediction
|
38 |
+
result = model.predict(input_data_scaled)
|
39 |
+
|
40 |
+
# Display the prediction
|
41 |
+
st.write(f"The predicted result is: {result[0]:.2f}$")
|
42 |
+
|