Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import joblib | |
| html_temp = """ | |
| <div style="background-color:tomato;padding:10px"> | |
| <h2 style="color:white;text-align:center;">Streamlit ML App for CO2 Emission Prediction </h2> | |
| </div> | |
| """ | |
| st.markdown(html_temp, unsafe_allow_html=True) | |
| image_url="https://www.greengeeks.com/blog/wp-content/uploads/2018/12/carbon-emissions.jpg" | |
| st.image(image_url, use_container_width=True) | |
| # Make | |
| options_make = ['ACURA', 'ALFA ROMEO', 'ASTON MARTIN', 'AUDI', 'BENTLEY', 'BMW', | |
| 'BUICK', 'CADILLAC', 'CHEVROLET', 'CHRYSLER', 'DODGE', 'FIAT', | |
| 'FORD', 'GMC', 'HONDA', 'HYUNDAI', 'INFINITI', 'JAGUAR', 'JEEP', | |
| 'KIA', 'LAMBORGHINI', 'LAND ROVER', 'LEXUS', 'LINCOLN', 'MASERATI', | |
| 'MAZDA', 'MERCEDES-BENZ', 'MINI', 'MITSUBISHI', 'NISSAN', | |
| 'PORSCHE', 'RAM', 'ROLLS-ROYCE', 'SCION', 'SMART', 'SRT', 'SUBARU', | |
| 'TOYOTA', 'VOLKSWAGEN', 'VOLVO', 'GENESIS', 'BUGATTI'] | |
| make= st.selectbox('Choose an make:', options_make) | |
| make_value=options_make.index(make) | |
| # Vehicle_Class_input | |
| options_Vechile_class=['COMPACT', 'SUV - SMALL', 'MID-SIZE', 'TWO-SEATER', 'MINICOMPACT', | |
| 'SUBCOMPACT', 'FULL-SIZE', 'STATION WAGON - SMALL', | |
| 'SUV - STANDARD', 'VAN - CARGO', 'VAN - PASSENGER', | |
| 'PICKUP TRUCK - STANDARD', 'MINIVAN', 'SPECIAL PURPOSE VEHICLE', | |
| 'STATION WAGON - MID-SIZE', 'PICKUP TRUCK - SMALL'] | |
| Vehicle_Class_input = st.selectbox('Choose an Vehicle Class:', options_Vechile_class) | |
| vechicle_class_value=options_Vechile_class.index(Vehicle_Class_input) | |
| # Engine_Size | |
| Engine_Size=float(st.slider("Slide Size of the Engine",min_value=0,max_value=8,value=1)) | |
| #cylinder | |
| options_cylinder=[ 4, 6, 12, 8, 10, 3, 5, 16] | |
| Cylinders =(st.selectbox('Choose an Cylinders:', options_cylinder)) | |
| Cylinders_value=options_cylinder.index(Cylinders) | |
| # Transmission | |
| options_Transmission=['AS5', 'M6', 'AV7', 'AS6', 'AM6', 'A6', 'AM7', 'AV8', 'AS8', 'A7', | |
| 'A8', 'M7', 'A4', 'M5', 'AV', 'A5', 'AS7', 'A9', 'AS9', 'AV6', | |
| 'AS4', 'AM5', 'AM8', 'AM9', 'AS10', 'A10', 'AV10'] | |
| Transmison=st.selectbox("Choose an Transmision",options_Transmission) | |
| Transmison_values=options_Transmission.index(Transmison) | |
| # fuel type | |
| option_fuel_type=['Z', 'D', 'X', 'E', 'N'] | |
| fuel_Type=st.selectbox('Select Type of the Fuel',option_fuel_type) | |
| fuel_Type_value=option_fuel_type.index(fuel_Type) | |
| Fuel_Consumption_City=st.slider('slide the Fuel_Consumption in the City',min_value=4,max_value=30,value=1) | |
| Fuel_Consumption_Hwy=st.slider("slide the Fuel Consumption in the Hwy ",min_value=4,max_value=20,value=1) | |
| Fuel_Consumption_Comb=st.slider('slide the Fuel Consumption Comb ',min_value=4,max_value=26,value=1) | |
| Fuel_Consumption_Comb1=(st.slider('enter the Fuel_Consumption Comb1:',min_value=11,max_value=69,value=1)) | |
| model=joblib.load("co2_emission_model.joblib") | |
| if st.button('submit'): | |
| output=model.predict([[make_value,vechicle_class_value,Engine_Size,Cylinders_value,Transmison_values,fuel_Type_value, | |
| Fuel_Consumption_City,Fuel_Consumption_Hwy,Fuel_Consumption_Comb,Fuel_Consumption_Comb1]]) | |
| st.text_area('',output[0]) |