| import streamlit as st |
| import numpy as np |
| import pickle |
| import streamlit.components.v1 as components |
| from sklearn.preprocessing import LabelEncoder |
| le = LabelEncoder() |
|
|
| |
| def load_model(): |
| return pickle.load(open('Diamond_Price_Prediction_LinearRegression.pkl', 'rb')) |
|
|
| |
| 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(): |
| |
| 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") |
| |
| |
| features = [[Carat,Cut,Color,Clarity,Depth,Table,X_length,Y_width,Z_depth]] |
| |
| |
| model = load_model() |
| |
| |
| if st.button('Predict Price'): |
| predicted_value = model_prediction(model, features) |
| st.success(f"The Price is: {predicted_value}") |
|
|
|
|
|
|
| def main(): |
|
|
| |
| 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() |