Raghavendra0827 commited on
Commit
0acd932
1 Parent(s): ca51891

Upload 5 files

Browse files
Soli_to_recommandation_model_Raghuu.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1afa2e0ebbb7a999fd6eeceaf9e9be1342913ba45f777e95ff069e49a0ef84df
3
+ size 133
Soli_to_recommandation_model_Simha.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d40e3831a83c7bc49ba167e1e410157ea591413cf13cf86e2631d54fd957826c
3
+ size 39907328
Weather_app.py ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import streamlit as st
3
+ import time
4
+ import math
5
+ import pickle as pk
6
+ import seaborn as sns
7
+ import matplotlib.pyplot as plt
8
+ import pandas as pd
9
+ import numpy as np
10
+ import streamlit as st
11
+ import plotly.express as px
12
+ import pandas as pd
13
+
14
+ def get_weather_details(city_name):
15
+ base_url = "https://api.openweathermap.org/data/2.5/weather"
16
+ params = {
17
+ 'q': city_name,
18
+ 'appid': "d73ec4f18aca81c32b1836a8ac2506e0"
19
+ }
20
+
21
+ try:
22
+ response = requests.get(base_url, params=params)
23
+ data = response.json()
24
+
25
+ # Check if the request was successful
26
+ if response.status_code == 200:
27
+ # Extract weather details
28
+ weather_details = {
29
+ 'city': city_name,
30
+ 'temperature': data['main']['temp'],
31
+ 'description': data['weather'][0]['description'],
32
+ 'humidity': data['main']['humidity'],
33
+ 'wind_speed': data['wind']['speed']
34
+ }
35
+ return weather_details
36
+ else:
37
+ st.write("Error {}: {}".format(response.status_code, data['message']))
38
+ return None
39
+ except Exception as e:
40
+ st.write("An error occurred:", e)
41
+ return None
42
+
43
+ # -------------------------------------------------------------------------------------------Api---------------------------------------------------------
44
+ # Replace with your actual values
45
+ def run_weather_app():
46
+ st.title("City Weather Overview")
47
+ try:
48
+ global city_name
49
+ city_name = st.selectbox('Enter City',("Bagalkot", "Ballari", "Belagavi", "Bidar", "Chikkaballapur", "Chikkamagaluru", "Chitradurga", "Davanagere", "Dharwad", "Gadag", "Hassan", "Haveri", "Kalaburagi", "Kodagu", "Kolar", "Koppal", "Mandya", "Mysuru", "Raichur", "Ramanagara", "Shivamogga", "Tumakuru", "Udupi", "Uttara Kannada", "Vijayapura","Yadgir"),key="unique_key_2")
50
+
51
+ if city_name:
52
+ # api_key = "d73ec4f18aca81c32b1836a8ac2506e0"
53
+
54
+ # Get weather details
55
+ prediction = ''
56
+ if st.button('Show'):
57
+ progress = st.progress(0)
58
+ for i in range(100):
59
+ time.sleep(0.005)
60
+ progress.progress(i+1)
61
+
62
+ weather_data = get_weather_details(city_name)
63
+ if weather_data:
64
+ column1, column2 = st.columns(2)
65
+ column1.metric("City", weather_data['city'].capitalize())
66
+ column1.metric("Temperature",value=f"{ round(weather_data['temperature'] - 273.15, 2) } °C",delta= weather_data['description'])
67
+ # column1.metric("Description", weather_data['description'])
68
+ column1.metric("Humidity",value= f"{weather_data['humidity']} %")
69
+ column1.metric("Wind Speed",value= f"{math.ceil(weather_data['wind_speed']*3.6)} km/hr")
70
+ else:
71
+ st.error("Invalid City Name")
72
+
73
+ except Exception as e:
74
+ st.error("An error occurred:", e)
75
+
76
+ return None
77
+ ###-------------------------------------------------------------------Current weather------------------------------------------------------------
78
+ forecast_model = pk.load(open('rain_forecast_model.pkl','rb'))
79
+
80
+ def run_forecast():
81
+ global forecast_data
82
+ num_months = st.number_input('Enter the number of months to forecast', min_value=1, max_value=48, value=1, step=1)
83
+ # st.write(num_months)
84
+ forecast_data = forecast_model.forecast(steps = 12+num_months)
85
+ st.title('Monthly Rainfall Overview')
86
+ df = pd.DataFrame({'Month': forecast_data.index.strftime('%Y-%m'), 'Values': np.round(forecast_data.values, 2)})
87
+ # Plotly bar chart with hover information
88
+ fig = px.bar(df, x='Month', y='Values', text='Values', color='Values',
89
+ labels={'Values': 'Precipitation'},
90
+ title='Monthly Forecast Data',
91
+ template='plotly',
92
+ color_continuous_scale='viridis')
93
+ # Set hover text to rounded values
94
+ fig.update_traces(texttemplate='%{text:.2f}', textposition='outside')
95
+ # Customize x-axis labels
96
+ # fig.update_xaxes(tickangle=45)
97
+ # Display the plot in Streamlit
98
+ st.plotly_chart(fig)
99
+
100
+ #-----------------------------------------------------------------------------------------------------------------------------
101
+
102
+ def india_precipitation():
103
+ st.title('India Monthly Precipitation')
104
+
105
+ data = pd.DataFrame({'Month': forecast_data.index.strftime('%Y-%m'), 'Precipitation': np.round(forecast_data.values, 2)})
106
+
107
+ fig = px.choropleth(data, locations=["India"] * len(data),
108
+ locationmode="country names",
109
+ color='Precipitation',
110
+ hover_name='Month',
111
+ animation_frame='Month', # Use 'Month' as the animation frame
112
+ range_color=[forecast_data.min(), forecast_data.max()], # Adjust the range
113
+ color_continuous_scale='Viridis'
114
+ )
115
+
116
+ st.plotly_chart(fig)
117
+
118
+
119
+ #--------------------------------------------------------------------------------------------------------------------------
120
+
121
+ def forecast_data_for_tab():
122
+ forecast_df = pd.DataFrame()
123
+ forecast_df['Months'] = forecast_data.index.strftime('%Y-%m')
124
+ forecast_df['Precipitation'] = forecast_data.values
125
+ st.table(forecast_df)
126
+
127
+ # Add a download button for CSV
128
+ csv_button = st.download_button(
129
+ label="Download Forecast Data as CSV",
130
+ data=forecast_df.to_csv(index=False).encode('utf-8'),
131
+ file_name='forecast_data.csv',
132
+ mime='text/csv'
133
+ )
134
+
135
+ #----------------------------------------------------------------------------------------------------------------
136
+
137
+ def weather_forecast_app():
138
+ # st.set_page_config(page_title="Weather App", page_icon=":cloud:")
139
+ if True:
140
+ run_weather_app()
141
+ if True:
142
+ tab1, tab2, tab3 = st.tabs(['Forecast Barplot', 'Forecast data', 'Map'])
143
+ with tab1:
144
+ run_forecast()
145
+ with tab2:
146
+ forecast_data_for_tab()
147
+ with tab3:
148
+ india_precipitation()
149
+
150
+
sum_insurance.py ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import pandas as pd
3
+ import numpy as np
4
+
5
+
6
+
7
+ data = pd.read_csv("insurance(R).csv")
8
+ data_new = data.copy(deep = True)
9
+
10
+
11
+
12
+ data.head()
13
+
14
+
15
+
16
+ import re
17
+
18
+ obj_columns = data.select_dtypes("object")
19
+
20
+ for col in obj_columns:
21
+ data[col] = data[col].apply(lambda x: re.sub(r'[^a-zA-Z0-9]', '', x.lower())).astype("str")
22
+
23
+
24
+
25
+ data.head()
26
+
27
+
28
+ season_catogory = list(data.season.values)
29
+ scheme_catogory = list(data.scheme.values)
30
+ state_catogory = list(data.state_name.values)
31
+ district_catogory = list(data.district_name.values)
32
+
33
+
34
+
35
+ columns = ['season','scheme','state_name','district_name']
36
+ from sklearn.preprocessing import LabelEncoder
37
+ encoder = LabelEncoder()
38
+ for col in columns:
39
+ data[col] = encoder.fit_transform(data[col])
40
+
41
+
42
+
43
+ season_label = list(data.season.values)
44
+ scheme_label = list(data.scheme.values)
45
+ state_label = list(data.state_name.values)
46
+ district_label = list(data.district_name.values)
47
+
48
+
49
+
50
+ season_category_label_dict = dict(zip(season_catogory, season_label))
51
+
52
+
53
+
54
+ scheme_category_label_dict = dict(zip(scheme_catogory, scheme_label))
55
+
56
+
57
+ state_category_label_dict = dict(zip(state_catogory, state_label))
58
+
59
+
60
+ district_category_label_dict = dict(zip(district_catogory, district_label))
61
+
62
+
63
+ from sklearn.compose import ColumnTransformer
64
+ from sklearn.ensemble import ExtraTreesRegressor
65
+ from sklearn.pipeline import Pipeline
66
+ from sklearn.preprocessing import LabelEncoder, StandardScaler, FunctionTransformer
67
+ from sklearn.model_selection import train_test_split
68
+
69
+
70
+ X = data.drop("sum_insured", axis=1)
71
+ y = data["sum_insured"]
72
+
73
+
74
+ def encoding(input_data):
75
+ input_data[0] = season_category_label_dict[input_data[0].lower().replace(" ","").replace(" ","").replace(" ","").replace(" ","")]
76
+ input_data[1] = scheme_category_label_dict[input_data[1].lower().replace(" ","").replace(" ","").replace(" ","").replace(" ","")]
77
+ input_data[2] = state_category_label_dict[input_data[2].lower().replace(" ","").replace(" ","").replace(" ","").replace(" ","")]
78
+ input_data[3] = district_category_label_dict[input_data[3].lower().replace(" ","").replace(" ","").replace(" ","").replace(" ","")]
79
+ return input_data
80
+
81
+
82
+
uploaded_image.jpg ADDED