-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoriginal_pridect.py
More file actions
198 lines (166 loc) · 5.31 KB
/
original_pridect.py
File metadata and controls
198 lines (166 loc) · 5.31 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
import tensorflow as tf
import pandas as pd
import sys
import numpy as np
from joblib import load
from sklearn.metrics import roc_auc_score, accuracy_score
from sklearn.model_selection import train_test_split
import xgboost as xgb
from sklearn.svm import SVC
feature_list = [
'月统筹金额_MAX',
'ALL_SUM',
'月药品金额_MAX',
'本次审批金额_SUM',
'月就诊次数_MAX',
'起付标准以上自负比例金额_SUM',
'月药品金额_AVG',
'月统筹金额_AVG',
'非账户支付金额_SUM',
'顺序号_NN',
'个人账户金额_SUM',
'可用账户报销金额_SUM',
'统筹支付金额_SUM',
'月就诊次数_AVG',
'药品费发生金额_SUM'
]
def dnn_pridect():
model = tf.keras.models.load_model('DNN')
#test = pd.read_csv('test_set.csv')
data = pd.read_csv('train_set.csv')
test = pd.read_csv('test_set.csv')
label_col = 'RES'
df = (data - data.min()) / (data.max() - data.min())
x = df.drop(labels=label_col, axis=1)
y = df['RES']
train_x = x
train_y = y
test = pd.read_csv('test_set.csv')
df2 = (test - test.min()) / (test.max() - test.min())
x2 = df2.drop(labels=label_col, axis=1)
y2 = df2['RES']
test_x = x2[feature_list]
test_y = y2
y_proba = model.predict(test_x)
y_pred = np.where(y_proba > 0.5, 1, 0)
#auc = roc_auc_score(test_y, y_proba)
auc= accuracy_score(test_y, y_pred)
return y_pred,auc
def cnn_pridect():
model = tf.keras.models.load_model('CNN')
#test = pd.read_csv('test_set.csv')
data = pd.read_csv('train_set.csv')
test = pd.read_csv('test_set.csv')
label_col = 'RES'
df = (data - data.min()) / (data.max() - data.min())
x = df.drop(labels=label_col, axis=1)
y = df['RES']
train_x = x
train_y = y
test = pd.read_csv('test_set.csv')
df2 = (test - test.min()) / (test.max() - test.min())
x2 = df2.drop(labels=label_col, axis=1)
y2 = df2['RES']
test_x = x2[feature_list]
test_y = y2
y_proba = model.predict(test_x)
y_pred = np.where(y_proba > 0.5, 1, 0)
#auc = roc_auc_score(test_y, y_proba)
auc= accuracy_score(test_y, y_pred)
return y_pred,auc
def rnn_pridect():
model = tf.keras.models.load_model('RNN')
#test = pd.read_csv('test_set.csv')
data = pd.read_csv('train_set.csv')
test = pd.read_csv('test_set.csv')
label_col = 'RES'
df = (data - data.min()) / (data.max() - data.min())
x = df.drop(labels=label_col, axis=1)
y = df['RES']
train_x = x
train_y = y
test = pd.read_csv('test_set.csv')
df2 = (test - test.min()) / (test.max() - test.min())
x2 = df2.drop(labels=label_col, axis=1)
y2 = df2['RES']
test_x = x2[feature_list]
test_y = y2
y_proba = model.predict(test_x)
y_pred = np.where(y_proba > 0.5, 1, 0)
#auc = roc_auc_score(test_y, y_proba)
auc= accuracy_score(test_y, y_pred)
return y_pred,auc
def xgb_pridect():
#model = tf.keras.models.load_model('DNN')
model = xgb.XGBClassifier()
model.load_model("XGB.json")
#test = pd.read_csv('test_set.csv')
df = pd.read_csv('train_set.csv')
test = pd.read_csv('test_set.csv')
label_col = 'RES'
#df = (data - data.min()) / (data.max() - data.min())
x = df.drop(labels=label_col, axis=1)
y = df['RES']
train_x = x
train_y = y
test = pd.read_csv('test_set.csv')
df2 = (test - test.min()) / (test.max() - test.min())
x2 = df2.drop(labels=label_col, axis=1)
y2 = df2['RES']
test_x = x2[feature_list]
test_y = y2
y_proba = model.predict(test_x)
y_pred = np.where(y_proba > 0.5, 1, 0)
auc= accuracy_score(test_y, y_pred)
return y_pred,auc
def svm_pridect():
#model = tf.keras.models.load_model('DNN')
#model = xgb.XGBClassifier()
model = SVC()
model=load('SCV.joblib')
#model.load_model("SVC.joblib")
#test = pd.read_csv('test_set.csv')
df = pd.read_csv('train_set.csv')
test = pd.read_csv('test_set.csv')
label_col = 'RES'
#df = (data - data.min()) / (data.max() - data.min())
x = df.drop(labels=label_col, axis=1)
y = df['RES']
train_x = x
train_y = y
test = pd.read_csv('test_set.csv')
df2 = (test - test.min()) / (test.max() - test.min())
x2 = df2.drop(labels=label_col, axis=1)
y2 = df2['RES']
test_x = x2[feature_list]
test_y = y2
y_proba = model.predict(test_x)
y_pred = np.where(y_proba > 0.5, 1, 0)
auc= accuracy_score(test_y, y_pred)
return y_pred,auc
def RF_pridect():
#model = tf.keras.models.load_model('DNN')
#model = xgb.XGBClassifier()
model = SVC()
model=load('RF.joblib')
#model.load_model("SVC.joblib")
#test = pd.read_csv('test_set.csv')
df = pd.read_csv('train_set.csv')
test = pd.read_csv('test_set.csv')
label_col = 'RES'
#df = (data - data.min()) / (data.max() - data.min())
x = df.drop(labels=label_col, axis=1)
y = df['RES']
train_x = x
train_y = y
test = pd.read_csv('test_set.csv')
df2 = (test - test.min()) / (test.max() - test.min())
x2 = df2.drop(labels=label_col, axis=1)
y2 = df2['RES']
test_x = x2[feature_list]
test_y = y2
y_proba = model.predict(test_x)
y_pred = np.where(y_proba > 0.5, 1, 0)
auc= accuracy_score(test_y, y_pred)
return y_pred,auc
# 输出预测结果,或者按需进一步处理