Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

test_app.py 2.8 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
  1. import streamlit as st
  2. import pandas as pd
  3. import plotly.express as px
  4. import random
  5. #Business Simulation Function
  6. def business_target_simulation(S, L, M, C, A, T, BT):
  7. revenue = (S*(L * M)) - (L * (C * (A/T)))
  8. if revenue > BT:
  9. return True
  10. else:
  11. return False
  12. p = 0.01
  13. st.title('Insurance Cross-Selling Business Simulation')
  14. url = 'https://raw.githubusercontent.com/cornelliusyudhawijaya/Cross-Sell-Insurance-Business-Simulation/main/train.csv'
  15. train = pd.read_csv(url, index_col=0, skiprows=lambda i: i>0 and random.random() > p)
  16. # Change to Categorical data
  17. train['Region_Code'] = train['Region_Code'].astype('string')
  18. train['Policy_Sales_Channel'] = train['Policy_Sales_Channel'].astype('string')
  19. train['Driving_License'] = train['Driving_License'].astype('string')
  20. train['Previously_Insured'] = train['Previously_Insured'].astype('string')
  21. st.subheader('100 Sample Data')
  22. st.dataframe(train.sample(100))
  23. st.subheader('Data Visualization with respect to Response (1% Samples)')
  24. left_column, right_column = st.columns(2)
  25. with left_column:
  26. 'Numerical Plot'
  27. num_feat = st.selectbox(
  28. 'Select Numerical Feature',
  29. train.select_dtypes('number').columns)
  30. fig = px.histogram(train, x = num_feat, color = 'Response')
  31. # Plot!
  32. st.plotly_chart(fig, use_container_width=True)
  33. with right_column:
  34. 'Categorical column'
  35. cat_feat = st.selectbox(
  36. 'Select Categorical Feature',
  37. train.select_dtypes(exclude = 'number').columns)
  38. fig = px.histogram(train, x =cat_feat, color = 'Response' )
  39. # Plot!
  40. st.plotly_chart(fig, use_container_width=True)
  41. st.subheader('Business Simulation')
  42. """This Business Simulation concerns
  43. with how the Precision would meet the Business Target or Not"""
  44. "We would use the following equation for simulate the business requirements"
  45. st.latex(r'BT <= (S * (L * M)) - (L*(C * (A/T))')
  46. """Where BT = Business Target, S = Success Income, L = Number of Leads,
  47. M = Model Metrics, C = Cost per Call, A = Number of Agent, T = Timeline"""
  48. 'Fill up your number here (Currency on Indian Rupee)'
  49. one_col, two_col, three_col, four_col = st.columns(4)
  50. with one_col:
  51. BT = st.number_input('Business Target')
  52. with two_col:
  53. S = st.number_input('Success Income')
  54. with three_col:
  55. L = st.number_input('Number of Leads')
  56. with four_col:
  57. M = st.number_input('Model Metrics')
  58. five_col, six_col, seven_col = st.columns(3)
  59. with five_col:
  60. C = st.number_input('Cost per Call')
  61. with six_col:
  62. A= st.number_input('Number of Agents')
  63. with seven_col:
  64. T = st.number_input('Timeline')
  65. if st.button('Simulate the Business Requirements'):
  66. if business_target_simulation(S=S, L=L, M=M/100, C=C, A=A, T=T, BT=BT) == True:
  67. st.header("Business Target are met")
  68. else:
  69. st.header("Business Target are not Met")
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...