simran0608 commited on
Commit
c41f726
1 Parent(s): 0a4a484

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -27
app.py CHANGED
@@ -4,26 +4,12 @@ import seaborn as sns
4
  import numpy as np
5
  import pickle
6
  import matplotlib.pyplot as plt
7
- from data_preparation import preprocess_data
8
- from clustering import perform_clustering, plot_clusters
9
  from feature_selection import select_features_pca, select_features_rfe, select_features_rf
10
  from sklearn.preprocessing import StandardScaler
11
- feature_descriptions = {
12
- "CustID": "Unique identifier for each customer.",
13
- "FirstPolYear": "Year when the customer first bought an insurance policy.",
14
- "BirthYear": "Birth year of the customer, used to calculate age.",
15
- "EducDeg": "Highest educational degree obtained by the customer.",
16
- "MonthSal": "Monthly salary of the customer. (Numerical, float64)",
17
- "GeoLivArea": "Geographical area where the customer lives.",
18
- "Children": "Number of children the customer has.",
19
- "CustMonVal": "Total monetary value of the customer to the company.",
20
- "ClaimsRate": "Rate at which the customer files insurance claims.",
21
- "PremMotor": "Premium amount for motor insurance.",
22
- "PremHousehold": "Premium amount for household insurance.",
23
- "PremHealth": "Premium amount for health insurance.",
24
- "PremLife": "Premium amount for life insurance.",
25
- "PremWork": "Premium amount for work insurance."
26
- }
27
 
28
  def load_data(dataset_choice):
29
  if dataset_choice == "Insurance":
@@ -33,13 +19,6 @@ def load_data(dataset_choice):
33
  elif dataset_choice == "Banking":
34
  data = pd.read_csv('bankingdata.csv', encoding='latin1')
35
  return data
36
-
37
- return data
38
- # Function to summarize cluster characteristics
39
- def summarize_cluster_characteristics(clustered_data, labels, cluster_number):
40
- cluster_data = clustered_data[labels == cluster_number]
41
- summary = cluster_data.mean().to_dict()
42
- return summary
43
 
44
  # Function to display Business Understanding section
45
  def display_business_understanding():
@@ -70,8 +49,9 @@ def display_dataset_selection():
70
  if dataset_choice=="Insurance":
71
  st.write(feature_descriptions)
72
  return data
 
73
  # Function to display Modeling & Evaluation section
74
- def display_modeling_evaluation():
75
  dataset_choice = st.selectbox("Select Dataset", ("Insurance", "Retail", "Banking"))
76
  data = load_data(dataset_choice)
77
  data = preprocess_data(data)
@@ -119,7 +99,18 @@ def display_modeling_evaluation():
119
  with st.form(key='prediction_form'):
120
  user_input = {}
121
  for feature in st.session_state.selected_features:
122
- user_input[feature] = st.number_input(f'Enter {feature}', value=0.0)
 
 
 
 
 
 
 
 
 
 
 
123
 
124
  submit_button = st.form_submit_button(label='Predict')
125
 
 
4
  import numpy as np
5
  import pickle
6
  import matplotlib.pyplot as plt
7
+ from data_preparation import preprocess_data,data_imp
8
+ from clustering import perform_clustering, plot_clusters,,summarize_cluster_characteristics
9
  from feature_selection import select_features_pca, select_features_rfe, select_features_rf
10
  from sklearn.preprocessing import StandardScaler
11
+
12
+ feature_descriptions,insurance_defaults,banking_defaults,retail_defaults=data_imp()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  def load_data(dataset_choice):
15
  if dataset_choice == "Insurance":
 
19
  elif dataset_choice == "Banking":
20
  data = pd.read_csv('bankingdata.csv', encoding='latin1')
21
  return data
 
 
 
 
 
 
 
22
 
23
  # Function to display Business Understanding section
24
  def display_business_understanding():
 
49
  if dataset_choice=="Insurance":
50
  st.write(feature_descriptions)
51
  return data
52
+
53
  # Function to display Modeling & Evaluation section
54
+ def display_modeling_evaluation(insurance_defaults,banking_defaults,retail_defaults):
55
  dataset_choice = st.selectbox("Select Dataset", ("Insurance", "Retail", "Banking"))
56
  data = load_data(dataset_choice)
57
  data = preprocess_data(data)
 
99
  with st.form(key='prediction_form'):
100
  user_input = {}
101
  for feature in st.session_state.selected_features:
102
+
103
+ # Set default values based on the dataset choice
104
+ if dataset_choice == "Insurance":
105
+ default_value = insurance_defaults.get(feature, 0.0)
106
+ elif dataset_choice == "Banking":
107
+ default_value = banking_defaults.get(feature, 0.0)
108
+ elif dataset_choice == "Retail":
109
+ default_value = retail_defaults.get(feature, 0.0)
110
+ else:
111
+ default_value = 0.0
112
+
113
+ user_input[feature] = st.number_input(f'Enter {feature}', value=default_value)
114
 
115
  submit_button = st.form_submit_button(label='Predict')
116