beihai commited on
Commit
fbc7bb2
·
1 Parent(s): 2efe8b0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -54
app.py CHANGED
@@ -3,54 +3,29 @@ from definitions import *
3
  st.set_option('deprecation.showPyplotGlobalUse', False)
4
  st.sidebar.subheader("请选择模型参数:sunglasses:")
5
 
6
- num_leaves = st.sidebar.slider(label = 'num_leaves', min_value = 4.0,
7
- max_value = 16.0 ,
8
- value = 10.0,
9
- step = 0.1)
10
 
11
- max_depth = st.sidebar.slider(label = 'max_depth', min_value = 8,
12
  max_value = 15,
13
- value = 10,
14
  step = 1)
15
 
16
  min_data_in_leaf = st.sidebar.slider(label = 'min_data_in_leaf', min_value = 8,
17
- max_value = 15,
18
- value = 10,
19
  step = 1)
20
 
21
  feature_fraction = st.sidebar.slider(label = 'feature_fraction', min_value = 0.0,
22
  max_value = 1.0 ,
23
- value = 0.3,
24
- step = 0.1)
25
-
26
- lambda_l1 = st.sidebar.slider(label = 'lambda_l1', min_value = 0.000,
27
- max_value = 1.000 ,
28
- value = 0.500,
29
- step = 0.001)
30
-
31
- lambda_l2 = st.sidebar.slider(label = 'lambda_l2', min_value = 1,
32
- max_value = 72,
33
- value = 36,
34
- step = 1)
35
-
36
- min_split_gain = st.sidebar.slider(label = 'min_split_gain', min_value = 6,
37
- max_value = 289 ,
38
- value = 144,
39
- step = 1)
40
-
41
- top_rate = st.sidebar.slider(label = 'top_rate', min_value = 0.0,
42
- max_value = 1.0 ,
43
- value = 0.3,
44
- step = 0.1)
45
-
46
- other_rate = st.sidebar.slider(label = 'other_rate', min_value = 0.0,
47
- max_value = 1.0 ,
48
- value = 0.3,
49
  step = 0.1)
50
 
51
  min_data_per_group = st.sidebar.slider(label = 'min_data_per_group', min_value = 6,
52
  max_value = 289 ,
53
- value = 32,
54
  step = 1)
55
 
56
  max_cat_threshold = st.sidebar.slider(label = 'max_cat_threshold', min_value = 6,
@@ -58,21 +33,15 @@ max_cat_threshold = st.sidebar.slider(label = 'max_cat_threshold', min_value = 6
58
  value = 32,
59
  step = 1)
60
 
61
- learning_rate = st.sidebar.slider(label = 'learning_rate', min_value = 8.0,
62
- max_value = 15.0,
63
- value = 10.5,
64
- step = 0.1)
65
 
66
  num_leaves = st.sidebar.slider(label = 'num_leaves', min_value = 6,
67
  max_value = 289 ,
68
  value = 31,
69
  step = 1)
70
-
71
- min_gain_to_split = st.sidebar.slider(label = 'min_gain_to_split', min_value = 0.0,
72
- max_value = 15.0,
73
- value = 0.0,
74
- step = 0.1)
75
-
76
 
77
  max_bin = st.sidebar.slider(label = 'max_bin', min_value = 6,
78
  max_value = 289 ,
@@ -80,8 +49,8 @@ max_bin = st.sidebar.slider(label = 'max_bin', min_value = 6,
80
  step = 1)
81
 
82
  num_iterations = st.sidebar.slider(label = 'num_iterations', min_value = 8,
83
- max_value = 15,
84
- value = 10,
85
  step = 1)
86
 
87
  st.title('LightGBM-parameter-tuning-with-streamlit')
@@ -103,11 +72,9 @@ lgb_eval = lgb.Dataset(X_test, y_test, reference=lgb_train)
103
  params = {'num_leaves': num_leaves, 'max_depth': max_depth,
104
  'min_data_in_leaf': min_data_in_leaf,
105
  'feature_fraction': feature_fraction,
106
- 'lambda_l1': lambda_l1, 'lambda_l2': lambda_l2,
107
- 'min_split_gain': min_split_gain, 'top_rate': top_rate,
108
- 'other_rate': other_rate, 'min_data_per_group': min_data_per_group,
109
  'max_cat_threshold': max_cat_threshold,
110
- 'learning_rate':learning_rate,'num_leaves':num_leaves,'min_gain_to_split':min_gain_to_split,
111
  'max_bin':max_bin,'num_iterations':num_iterations
112
  }
113
 
@@ -118,11 +85,8 @@ probs = gbm.predict(X_test, num_iteration=gbm.best_iteration) # 输出的是概
118
  fpr, tpr, thresholds = roc_curve(y_test, probs)
119
  st.write('------------------------------------')
120
  st.write('Confusion Matrix:')
121
-
122
  st.write(confusion_matrix(y_test, np.where(probs > 0.5, 1, 0)))
123
 
124
-
125
-
126
  st.write('------------------------------------')
127
  st.write('Classification Report:')
128
  report = classification_report(y_test, np.where(probs > 0.5, 1, 0), output_dict=True)
 
3
  st.set_option('deprecation.showPyplotGlobalUse', False)
4
  st.sidebar.subheader("请选择模型参数:sunglasses:")
5
 
6
+ num_leaves = st.sidebar.slider(label = 'num_leaves', min_value = 4,
7
+ max_value = 200 ,
8
+ value = 31,
9
+ step = 1)
10
 
11
+ max_depth = st.sidebar.slider(label = 'max_depth', min_value = -1,
12
  max_value = 15,
13
+ value = -1,
14
  step = 1)
15
 
16
  min_data_in_leaf = st.sidebar.slider(label = 'min_data_in_leaf', min_value = 8,
17
+ max_value = 55,
18
+ value = 20,
19
  step = 1)
20
 
21
  feature_fraction = st.sidebar.slider(label = 'feature_fraction', min_value = 0.0,
22
  max_value = 1.0 ,
23
+ value = 0.8,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  step = 0.1)
25
 
26
  min_data_per_group = st.sidebar.slider(label = 'min_data_per_group', min_value = 6,
27
  max_value = 289 ,
28
+ value = 100,
29
  step = 1)
30
 
31
  max_cat_threshold = st.sidebar.slider(label = 'max_cat_threshold', min_value = 6,
 
33
  value = 32,
34
  step = 1)
35
 
36
+ learning_rate = st.sidebar.slider(label = 'learning_rate', min_value = 0.0,
37
+ max_value = 1.00,
38
+ value = 0.05,
39
+ step = 0.01)
40
 
41
  num_leaves = st.sidebar.slider(label = 'num_leaves', min_value = 6,
42
  max_value = 289 ,
43
  value = 31,
44
  step = 1)
 
 
 
 
 
 
45
 
46
  max_bin = st.sidebar.slider(label = 'max_bin', min_value = 6,
47
  max_value = 289 ,
 
49
  step = 1)
50
 
51
  num_iterations = st.sidebar.slider(label = 'num_iterations', min_value = 8,
52
+ max_value = 289,
53
+ value = 100,
54
  step = 1)
55
 
56
  st.title('LightGBM-parameter-tuning-with-streamlit')
 
72
  params = {'num_leaves': num_leaves, 'max_depth': max_depth,
73
  'min_data_in_leaf': min_data_in_leaf,
74
  'feature_fraction': feature_fraction,
75
+ 'min_data_per_group': min_data_per_group,
 
 
76
  'max_cat_threshold': max_cat_threshold,
77
+ 'learning_rate':learning_rate,'num_leaves':num_leaves,
78
  'max_bin':max_bin,'num_iterations':num_iterations
79
  }
80
 
 
85
  fpr, tpr, thresholds = roc_curve(y_test, probs)
86
  st.write('------------------------------------')
87
  st.write('Confusion Matrix:')
 
88
  st.write(confusion_matrix(y_test, np.where(probs > 0.5, 1, 0)))
89
 
 
 
90
  st.write('------------------------------------')
91
  st.write('Classification Report:')
92
  report = classification_report(y_test, np.where(probs > 0.5, 1, 0), output_dict=True)