File size: 2,024 Bytes
131aba4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import streamlit as st
import numpy as np
import pickle
import streamlit.components.v1 as components
from sklearn.preprocessing import LabelEncoder
le = LabelEncoder()

# Load the pickled model
def load_model():
    return pickle.load(open('Diamond_Price_Prediction_LinearRegression.pkl', 'rb'))

# Function for model prediction
def model_prediction(model, features):
    predicted = str(model.predict(features)[0])
    return predicted
    
def transform(text):
    text = le.fit_transform(text)
    return text[0]

def app_design():
    # Add input fields for High, Open, and Low values
    image = ''
    st.image(image, use_column_width=True)
    
    st.subheader("Enter the following values:")

    Carat = st.number_input("Carat(Weight of Daimond)")
    Cut = st.text_input("Cut(Quality) ('Ideal','Premium','Good','Very Good','Fair')")
    Cut = transform([Cut])
    Color = st.text_input("Color ('E','I','J','H','F','G','D')")
    Color=transform([Color])
    Clarity = st.text_input("Clarity ('SI2','SI1','VS1','VS2','VVS2','VVS1','I1','IF')")
    Clarity=transform([Clarity])
    Depth = st.number_input("Depth")
    Table = st.number_input("Table")
    X_length = st.number_input("X length")
    Y_width = st.number_input("Y width")
    Z_depth = st.number_input("Z depth")
 
    # Create a feature list from the user inputs
    features = [[Carat,Cut,Color,Clarity,Depth,Table,X_length,Y_width,Z_depth]]
    
    # Load the model
    model = load_model()
    
    # Make a prediction when the user clicks the "Predict" button
    if st.button('Predict Price'):
        predicted_value = model_prediction(model, features)
        st.success(f"The Price is: {predicted_value}")       



def main():

        # Set the app title and add your website name and logo
        st.set_page_config(
        page_title="Diamond Price Prediction",
        page_icon=":chart_with_upwards_trend:",
        )
    
        st.title("Welcome to our Diamond Price Prediction App!")
    

if __name__ == '__main__':
        main()