Download src/streamlit_app.py from MSK34/rainfall-prediction-challenge: direct link, hf CLI and curl.
- Browser
- Download file 2.18 kB
-
https://huggingface.co/spaces/MSK34/rainfall-prediction-challenge/resolve/main/src/streamlit_app.py
- Command line
-
hf download hf://spaces/MSK34/rainfall-prediction-challenge/src/streamlit_app.py
-
curl -L -o streamlit_app.py https://huggingface.co/spaces/MSK34/rainfall-prediction-challenge/resolve/main/src/streamlit_app.py
2.18 kB
| import os | |
| import joblib | |
| import pandas as pd | |
| import streamlit as st | |
| # Model dosyasını yüklüyoruz. | |
| BASE_DIR = os.path.dirname(__file__) | |
| MODEL_PATH = os.path.join(BASE_DIR, "rainfall_rf_model.pkl") | |
| model = joblib.load(MODEL_PATH) | |
| st.set_page_config( | |
| page_title="Rainfall Prediction Challenge", | |
| page_icon="🌧️", | |
| layout="centered" | |
| ) | |
| st.title("🌧️ Rainfall Prediction Challenge") | |
| st.write(""" | |
| Bu uygulama hava durumu göstergelerini kullanarak yağmur yağıp yağmayacağını tahmin eder. | |
| Değerleri girdikten sonra **Tahmin Yap** butonuna basınız. | |
| """) | |
| day = st.slider("Gün", 1, 31, 15) | |
| pressure = st.number_input("Basınç", value=1013.0) | |
| maxtemp = st.number_input("Maksimum Sıcaklık", value=28.0) | |
| temperature = st.number_input("Ortalama Sıcaklık", value=25.0) | |
| mintemp = st.number_input("Minimum Sıcaklık", value=22.0) | |
| dewpoint = st.number_input("Çiy Noktası", value=20.0) | |
| humidity = st.slider("Nem Oranı", 0.0, 100.0, 80.0) | |
| cloud = st.slider("Bulutluluk Oranı", 0.0, 100.0, 70.0) | |
| sunshine = st.number_input("Güneşlenme Süresi", value=4.0) | |
| winddirection = st.number_input("Rüzgar Yönü", value=180.0) | |
| windspeed = st.number_input("Rüzgar Hızı", value=20.0) | |
| humidity_cloud = humidity * cloud | |
| humidity_sunshine_ratio = humidity / (sunshine + 1) | |
| temp_range = maxtemp - mintemp | |
| cloud_sunshine_ratio = cloud / (sunshine + 1) | |
| input_data = pd.DataFrame({ | |
| "day": [day], | |
| "pressure": [pressure], | |
| "maxtemp": [maxtemp], | |
| "temparature": [temperature], | |
| "mintemp": [mintemp], | |
| "dewpoint": [dewpoint], | |
| "humidity": [humidity], | |
| "cloud": [cloud], | |
| "sunshine": [sunshine], | |
| "winddirection": [winddirection], | |
| "windspeed": [windspeed], | |
| "humidity_cloud": [humidity_cloud], | |
| "humidity_sunshine_ratio": [humidity_sunshine_ratio], | |
| "temp_range": [temp_range], | |
| "cloud_sunshine_ratio": [cloud_sunshine_ratio] | |
| }) | |
| if st.button("Tahmin Yap"): | |
| prediction = model.predict(input_data)[0] | |
| st.subheader("Tahmin Sonucu") | |
| if prediction == 1: | |
| st.error("🌧️ Model tahminine göre yağmur bekleniyor.") | |
| else: | |
| st.success("☀️ Model tahminine göre yağmur beklenmiyor.") |