File size: 2,253 Bytes
522db38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import joblib
import streamlit as st
from sklearn.ensemble import RandomForestRegressor
import base64


# Using "with" notation
st.markdown(
    f'''
        <style>
            .sidebar .sidebar-content {{
                width: 375px;
            }}
        </style>
    ''',
    unsafe_allow_html=True
)

with st.sidebar:
    st.link_button("more_information", "https://www.kaggle.com/code/pankajsinghardh/p-tax-fare")
st.success("")

model = joblib.load("model.joblib")
titleimg = "new.jpg"

#impliment background formating
def set_bg_hack(main_bg):
    # set bg name
    main_bg_ext = "jpg"
    st.markdown(
        f"""
         <style>
         .stApp {{
             background: url(data:image/{main_bg_ext};base64,{base64.b64encode(open(main_bg, "rb").read()).decode()});
             background-repeat: no-repeat;
             background-position: right 50% bottom 95% ;
             background-size: cover;
             background-attachment: scroll;
         }}
         </style>
         """,
        unsafe_allow_html=True,
    )

set_bg_hack(titleimg)




st.markdown("<h1><font color='yellow'><center>'Taxi_Fare'</center></font></h1>",unsafe_allow_html=True)
le = r'''
$\textsf{
    \LARGE Hour\
}$
'''
hour = st.selectbox(f":red[{le}]",range(1,25))
le = r'''
$\textsf{
    \LARGE Distance\
}$
'''
distance = st.number_input(f":red[{le}]",step=1)
le = r'''
$\textsf{
    \LARGE Weekday\
}$
'''
weekday = st.selectbox(f":red[{le}]",["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"])

day = {"Sunday":0,"Monday":1,"Tuesday":3,"Wednesday":4,"Thursday":5,"Friday":6,"Saturday":7}
btn = st.button("predict")
if btn:
    price = model.predict([[hour,distance,day[weekday]]])

    st.snow()

    st.write( ":red[Fare_in_USD]",price)
    def autoplay_audio(file_path: str):
        with open(file_path, "rb") as f:
            data = f.read()
            b64 = base64.b64encode(data).decode()
            md = f"""
                <audio controls autoplay="true">
                <source src="data:audio/mp3;base64,{b64}" type="audio/mp3">
                </audio>
                """
            st.markdown(
                md,
                unsafe_allow_html=True,
            )

    autoplay_audio("synthesize.mp3")