ninte commited on
Commit
776574f
·
1 Parent(s): e56c1c5

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -0
app.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ from sklearn.ensemble import RandomForestClassifier
4
+ import joblib
5
+
6
+ def load_model():
7
+ # Load the pre-trained model
8
+ model = joblib.load('weather_model.joblib')
9
+ return model
10
+
11
+ def predict_weather_conditions(model, input_data):
12
+ # Make predictions on the input data
13
+ predictions = model.predict(input_data)
14
+ return predictions[0]
15
+
16
+ def main():
17
+ # Load the pre-trained model
18
+ model = load_model()
19
+
20
+ # Add a title to your app
21
+ st.title("Weather Prediction App")
22
+
23
+ # Get user input
24
+ temp_c = st.slider("Temperature in Celsius", min_value=-10.0, max_value=40.0, value=20.0)
25
+ dew_point_temp_c = st.slider("Dew Point Temperature in Celsius", min_value=-10.0, max_value=30.0, value=15.0)
26
+ rel_humidity = st.slider("Relative Humidity (%)", min_value=0, max_value=100, value=50)
27
+ wind_speed_kmh = st.slider("Wind Speed in km/h", min_value=0, max_value=50, value=10)
28
+ visibility_km = st.slider("Visibility in km", min_value=0.1, max_value=50.0, value=10.0)
29
+ press_kpa = st.slider("Atmospheric Pressure in kPa", min_value=90.0, max_value=110.0, value=101.0)
30
+
31
+ # Create a DataFrame with user input
32
+ input_data = pd.DataFrame({
33
+ 'Temp_C': [temp_c],
34
+ 'Dew Point Temp_C': [dew_point_temp_c],
35
+ 'Rel Hum_%': [rel_humidity],
36
+ 'Wind Speed_km/h': [wind_speed_kmh],
37
+ 'Visibility_km': [visibility_km],
38
+ 'Press_kPa': [press_kpa],
39
+ })
40
+
41
+ # Make predictions
42
+ if st.button("Predict Weather"):
43
+ predicted_weather = predict_weather_conditions(model, input_data)
44
+ st.success(f"Predicted Weather Condition: {predicted_weather}")
45
+
46
+ if __name__ == '__main__':
47
+ main()