AjiNiktech commited on
Commit
131aba4
1 Parent(s): 4fad6f9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +66 -0
app.py CHANGED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import numpy as np
3
+ import pickle
4
+ import streamlit.components.v1 as components
5
+ from sklearn.preprocessing import LabelEncoder
6
+ le = LabelEncoder()
7
+
8
+ # Load the pickled model
9
+ def load_model():
10
+ return pickle.load(open('Diamond_Price_Prediction_LinearRegression.pkl', 'rb'))
11
+
12
+ # Function for model prediction
13
+ def model_prediction(model, features):
14
+ predicted = str(model.predict(features)[0])
15
+ return predicted
16
+
17
+ def transform(text):
18
+ text = le.fit_transform(text)
19
+ return text[0]
20
+
21
+ def app_design():
22
+ # Add input fields for High, Open, and Low values
23
+ image = ''
24
+ st.image(image, use_column_width=True)
25
+
26
+ st.subheader("Enter the following values:")
27
+
28
+ Carat = st.number_input("Carat(Weight of Daimond)")
29
+ Cut = st.text_input("Cut(Quality) ('Ideal','Premium','Good','Very Good','Fair')")
30
+ Cut = transform([Cut])
31
+ Color = st.text_input("Color ('E','I','J','H','F','G','D')")
32
+ Color=transform([Color])
33
+ Clarity = st.text_input("Clarity ('SI2','SI1','VS1','VS2','VVS2','VVS1','I1','IF')")
34
+ Clarity=transform([Clarity])
35
+ Depth = st.number_input("Depth")
36
+ Table = st.number_input("Table")
37
+ X_length = st.number_input("X length")
38
+ Y_width = st.number_input("Y width")
39
+ Z_depth = st.number_input("Z depth")
40
+
41
+ # Create a feature list from the user inputs
42
+ features = [[Carat,Cut,Color,Clarity,Depth,Table,X_length,Y_width,Z_depth]]
43
+
44
+ # Load the model
45
+ model = load_model()
46
+
47
+ # Make a prediction when the user clicks the "Predict" button
48
+ if st.button('Predict Price'):
49
+ predicted_value = model_prediction(model, features)
50
+ st.success(f"The Price is: {predicted_value}")
51
+
52
+
53
+
54
+ def main():
55
+
56
+ # Set the app title and add your website name and logo
57
+ st.set_page_config(
58
+ page_title="Diamond Price Prediction",
59
+ page_icon=":chart_with_upwards_trend:",
60
+ )
61
+
62
+ st.title("Welcome to our Diamond Price Prediction App!")
63
+
64
+
65
+ if __name__ == '__main__':
66
+ main()