Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,9 +2,26 @@ import pickle as pkl
|
|
2 |
import streamlit as st
|
3 |
from sklearn.linear_model import LinearRegression
|
4 |
import pandas as pd
|
|
|
5 |
|
|
|
|
|
|
|
|
|
6 |
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
# FUNCTION
|
9 |
def user_report():
|
10 |
Income = st.sidebar.slider('Income', 17795,107702, 18000 )
|
@@ -30,11 +47,6 @@ user_data = user_report()
|
|
30 |
st.subheader('Housing Data')
|
31 |
st.write(user_data)
|
32 |
|
33 |
-
lr = LinearRegression()
|
34 |
-
#Open the saved file with read-binary mode
|
35 |
-
lr_pickle = pkl.load(open('linear_saved_model', 'rb'))
|
36 |
-
|
37 |
-
|
38 |
# MODEL
|
39 |
user_result = lr.predict(user_data)
|
40 |
|
|
|
2 |
import streamlit as st
|
3 |
from sklearn.linear_model import LinearRegression
|
4 |
import pandas as pd
|
5 |
+
from sklearn.model_selection import train_test_split
|
6 |
|
7 |
+
# loading the data
|
8 |
+
df = pd.read_csv('/content/drive/MyDrive/housing.csv')
|
9 |
+
df.rename(columns = {'Avg. Area Income':'Income','Avg. Area House Age':'House_age', 'Avg. Area Number of Rooms':'No_rooms',
|
10 |
+
'Avg. Area Number of Bedrooms':'No_bedrooms', 'Area Population':'population'},inplace = True)
|
11 |
|
12 |
|
13 |
+
X_train,X_test,y_train,y_test = train_test_split(df.drop(columns =['Price']),
|
14 |
+
df['Price'],
|
15 |
+
test_size = 0.2,
|
16 |
+
random_state =2)
|
17 |
+
#model building
|
18 |
+
from sklearn.linear_model import LinearRegression
|
19 |
+
|
20 |
+
lr = LinearRegression()
|
21 |
+
# training the model or fitting the model
|
22 |
+
|
23 |
+
lr.fit(X_train,y_train)
|
24 |
+
|
25 |
# FUNCTION
|
26 |
def user_report():
|
27 |
Income = st.sidebar.slider('Income', 17795,107702, 18000 )
|
|
|
47 |
st.subheader('Housing Data')
|
48 |
st.write(user_data)
|
49 |
|
|
|
|
|
|
|
|
|
|
|
50 |
# MODEL
|
51 |
user_result = lr.predict(user_data)
|
52 |
|