Spaces:
Runtime error
Runtime error
Upload 3 files
Browse files- app.py +109 -0
- requirements.txt +6 -0
- xgboost_project_risk_prediction.pickle +3 -0
app.py
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import pandas as pd
|
3 |
+
import pickle
|
4 |
+
import shap
|
5 |
+
import xgboost
|
6 |
+
import matplotlib
|
7 |
+
import matplotlib.pyplot as plt
|
8 |
+
import io
|
9 |
+
matplotlib.use('Agg')
|
10 |
+
pc = ["Enterprise System", "Management Information System", "Safety Critical System", "Transaction Processing System" ]
|
11 |
+
rc = ['Constraints','Functional','Interfaces','Performance','Reliability&Availability','Safety','Security','Standards','Supportability','Usability']
|
12 |
+
rtc = ['Budget','Business','Cost','Design','Functional Validity','Organizational Environment','Overdrawn Budget','People','Performance','Personal','Planning&Control','Process','Project complexity','Quality','Requirement','Resource availability','Schedule','Software','Team','TimeDimension','Unrealistic Requirements','User']
|
13 |
+
mor = ['Extreme','High','Low','Medium','Negligible','Very High','Very Low']
|
14 |
+
imp = ["Low", "Catastrophic", "High", "Insignificant", "High", "Moderate"]
|
15 |
+
dor = ['Cost','Estimations','Organizational Environment','Organizational Requirements','Planning and Control','Project Complexity','Project complexity','Requirements','Schedule','Software Requirement','Team','User','Planning and Control']
|
16 |
+
def ml_function(probability, affecting_no_of_modules,
|
17 |
+
fixing_duration, project_category, requirement_category, risk_target_category,
|
18 |
+
magnitude_of_risk, impact, dimension_of_risk, fix_cost_percent_of_project):
|
19 |
+
data = list()
|
20 |
+
data.append(probability)
|
21 |
+
data.append(affecting_no_of_modules)
|
22 |
+
data.append(fixing_duration)
|
23 |
+
data.extend([bool(c in project_category) for c in pc])
|
24 |
+
data.extend([bool(c in requirement_category) for c in rc])
|
25 |
+
data.extend([bool(c in risk_target_category) for c in rtc])
|
26 |
+
data.extend([bool(c in magnitude_of_risk) for c in mor])
|
27 |
+
data.extend([bool(c in impact) for c in imp])
|
28 |
+
data.extend([bool(c in dimension_of_risk) for c in dor])
|
29 |
+
fix_cost_percent_of_project_one_hot = [False] * 10
|
30 |
+
fix_cost_percent_of_project_one_hot[fix_cost_percent_of_project] = True
|
31 |
+
data.extend(fix_cost_percent_of_project_one_hot)
|
32 |
+
|
33 |
+
df = pd.DataFrame([data])
|
34 |
+
df.columns = ['Probability', 'Afftecting No of Modules', 'Fixing Duration (Days)',
|
35 |
+
'project Category_Enterprise System',
|
36 |
+
'project Category_Management Information System',
|
37 |
+
'project Category_Safety Critical System',
|
38 |
+
'project Category_Transaction Processing System',
|
39 |
+
'Requirement Category_Constraints', 'Requirement Category_Functional',
|
40 |
+
'Requirement Category_Interfaces', 'Requirement Category_Performance',
|
41 |
+
'Requirement Category_Reliability & Availability',
|
42 |
+
'Requirement Category_Safety', 'Requirement Category_Security',
|
43 |
+
'Requirement Category_Standards', 'Requirement Category_Supportability',
|
44 |
+
'Requirement Category_Usability', 'Risk Target Category_Budget',
|
45 |
+
'Risk Target Category_Business', 'Risk Target Category_Cost',
|
46 |
+
'Risk Target Category_Design',
|
47 |
+
'Risk Target Category_FunctionalValidity',
|
48 |
+
'Risk Target Category_Organizational Environment',
|
49 |
+
'Risk Target Category_Overdrawn Budget', 'Risk Target Category_People',
|
50 |
+
'Risk Target Category_Performance', 'Risk Target Category_Personal',
|
51 |
+
'Risk Target Category_Planning & Control',
|
52 |
+
'Risk Target Category_Process',
|
53 |
+
'Risk Target Category_Project complexity',
|
54 |
+
'Risk Target Category_Quality', 'Risk Target Category_Requirement',
|
55 |
+
'Risk Target Category_Resource availability',
|
56 |
+
'Risk Target Category_Schedule', 'Risk Target Category_Software',
|
57 |
+
'Risk Target Category_Team', 'Risk Target Category_Time Dimension',
|
58 |
+
'Risk Target Category_Unrealistic Requirements',
|
59 |
+
'Risk Target Category_User', 'Magnitude of Risk_Extreme',
|
60 |
+
'Magnitude of Risk_High', 'Magnitude of Risk_Low',
|
61 |
+
'Magnitude of Risk_Medium', 'Magnitude of Risk_Negligible',
|
62 |
+
'Magnitude of Risk_Very High', 'Magnitude of Risk_Very Low',
|
63 |
+
'Impact_Low', 'Impact_catastrophic', 'Impact_high',
|
64 |
+
'Impact_insignificant', 'Impact_moderate', 'Dimension of Risk_Cost',
|
65 |
+
'Dimension of Risk_Estimations',
|
66 |
+
'Dimension of Risk_Organizational Environment',
|
67 |
+
'Dimension of Risk_Organizational Requirements',
|
68 |
+
'Dimension of Risk_Planning and Control',
|
69 |
+
'Dimension of Risk_Project Complexity',
|
70 |
+
'Dimension of Risk_Project complexity',
|
71 |
+
'Dimension of Risk_Requirements', 'Dimension of Risk_Schedule',
|
72 |
+
'Dimension of Risk_Software Requirement', 'Dimension of Risk_Team',
|
73 |
+
'Dimension of Risk_User', 'Dimension of Risk_planning and control',
|
74 |
+
'Fix Cost (\% of Project)_0', 'Fix Cost (\% of Project)_1',
|
75 |
+
'Fix Cost (\% of Project)_10', 'Fix Cost (\% of Project)_11',
|
76 |
+
'Fix Cost (\% of Project)_2', 'Fix Cost (\% of Project)_21',
|
77 |
+
'Fix Cost (\% of Project)_3', 'Fix Cost (\% of Project)_4',
|
78 |
+
'Fix Cost (\% of Project)_5', 'Fix Cost (\% of Project)_6',
|
79 |
+
'Fix Cost (\% of Project)_?']
|
80 |
+
df = df.reset_index(drop=True)
|
81 |
+
for col in df.columns:
|
82 |
+
if df[col].dtype == 'object':
|
83 |
+
df[col] = pd.to_numeric(df[col])
|
84 |
+
xgb_model_loaded = pickle.load(open('xgboost_project_risk_prediction.pickle', "rb"))
|
85 |
+
pred = xgb_model_loaded.predict(df[:1])
|
86 |
+
return str(pred[0])
|
87 |
+
|
88 |
+
# Define the Gradio interface with appropriate input components
|
89 |
+
iface = gr.Interface(
|
90 |
+
fn=ml_function,
|
91 |
+
inputs=[
|
92 |
+
gr.inputs.Number(label="Probability"),
|
93 |
+
gr.inputs.Number(label="Affecting No of Modules"),
|
94 |
+
gr.inputs.Number(label="Fixing Duration (Days)"),
|
95 |
+
gr.inputs.Radio(choices=pc, label="Project Category"),
|
96 |
+
gr.inputs.Radio(choices=rc, label="Requirement Category"),
|
97 |
+
gr.inputs.Radio(choices=rtc, label="Risk Target Category"),
|
98 |
+
gr.inputs.Radio(choices=mor, label="Magnitude of Risk"),
|
99 |
+
gr.inputs.Radio(choices=imp, label="Impact"),
|
100 |
+
gr.inputs.Radio(choices=dor, label="Dimension of Risk"),
|
101 |
+
gr.inputs.Slider(minimum=0, maximum=10,step=1, label="Fix Cost (% of Project)")
|
102 |
+
],
|
103 |
+
outputs=[
|
104 |
+
gr.outputs.Label(label="Risk Level")
|
105 |
+
]
|
106 |
+
)
|
107 |
+
|
108 |
+
# Run the Gradio app
|
109 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
numpy
|
3 |
+
scikit-learn
|
4 |
+
shap
|
5 |
+
xgboost
|
6 |
+
matplotlib
|
xgboost_project_risk_prediction.pickle
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e97474ad21ba60cb48b016a30737a3ca065d8f367abd27c02e9220b5be8d9cc5
|
3 |
+
size 213223
|