Spaces:
Sleeping
Sleeping
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") | |