CoolFace
Apppublic

Karan1908/Weather-Type-Classification

sourceHugging Faceotherupdated 2y agoView on Hugging Face
0likes
test.py74 linesDownload Raw Back to root
1'''2Author       : Karan Chauhan3github       : @Karan-Chauhan194Email        : kc879022@gmail.com5Organization : L.J University6'''7 8 9import pandas as pd10import numpy as np11from train import *12import streamlit as st13 14class TestDataPreprocessing :15    def __init__(self) :16        pass17    def testing(self) :18 19        st.sidebar.title("Select Parameter ")20        mt = ModelTrain()21        selected_algorithm,model_pipeline =  mt.train_model()22 23        # Create a single column on the left side24        left_col, _ = st.columns([1, 3])  # 1:3 ratio for left column vs right empty space25        with left_col:26            # User inputs for numerical data27            temperature = st.sidebar.number_input("Temperature (°C):", min_value=-50.0, max_value=60.0, value=25.0)28            humidity = st.sidebar.number_input("Humidity (%):", min_value=0, max_value=100, value=50)29            wind_speed = st.sidebar.number_input("Wind Speed (km/h):", min_value=0.0, max_value=200.0, value=10.0)30            precipitation = st.sidebar.number_input("Precipitation (%):", min_value=0, max_value=100, value=20)31            atmospheric_pressure = st.sidebar.number_input("Atmospheric Pressure (hPa):", min_value=800.0, max_value=1100.0, value=1013.0)32            uv_index = st.sidebar.number_input("UV Index:", min_value=0, max_value=11, value=5)33            visibility = st.sidebar.number_input("Visibility (km):", min_value=0.0, max_value=100.0, value=10.0)34 35            # Dropdown menus with a placeholder to ensure a valid selection36            cloud_cover = st.sidebar.selectbox("Cloud Cover:", ['partly cloudy', 'clear', 'overcast', 'cloudy'])37            season = st.sidebar.selectbox("Season:", ['Winter', 'Spring', 'Summer', 'Autumn'])38 39            st.markdown("""40            <style>41            /* Change font size for all labels */42            .stSelectbox {43                font-size: 50px !important;44            }45            </style>46            """, unsafe_allow_html=True)47 48            user_input = {'Temperature': temperature, 'Humidity':humidity, 'Wind_Speed':wind_speed, 'Precipitation (%)':precipitation,49            'Cloud_Cover':cloud_cover, 'Atmospheric_Pressure':atmospheric_pressure, 'UV_Index':uv_index, 'Season':season,50           'Visibility (km)':visibility}51        52        if st.sidebar.button("Submit") :53 54            user_df = pd.DataFrame([user_input])55            user_input_transform = model_pipeline.transform(user_df)56            user_prediction = selected_algorithm.predict(user_input_transform)57 58            if user_prediction == ''.join(['Sunny']) :59                output_message = "The weather is likely to be Sunny ☀️"60                st.image("sun.png",width=400, use_column_width=False)61            elif user_prediction == ''.join(['Rainy']):62                output_message = "The weather is likely to be Rainy 🌧️"63                st.image("storm.png",width=400, use_column_width=False)64            elif user_prediction == ''.join(['Cloudy']) :65                output_message = "The weather is likely to be Cloudy ☁️"66                st.image("cloudy.png",width=400, use_column_width=False)67            elif user_prediction == ''.join(['Snowy']) :68                output_message = "The weather is likely to be Snowy ❄️"69                st.image("snow.png",width=400, use_column_width=False)70            else :71                pass72 73            # Display the output message with bold and increased font size74            st.markdown(f"<h2>{output_message}</h2>", unsafe_allow_html=True)