-
Notifications
You must be signed in to change notification settings - Fork 81
/
ctrip_test_all_data_v31_lgb_feature.py
684 lines (543 loc) · 39.9 KB
/
ctrip_test_all_data_v31_lgb_feature.py
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
#encoding=utf8
import pandas as pd
import lightgbm as lgb
import numpy as np
from com_uitl import *
# 每个basicid价格的中位数
def df_median(df):
add = pd.DataFrame(df.groupby(["orderid", "basicroomid"]).price_deduct.median()).reset_index()
add.columns = ["orderid", "basicroomid", "basicroomid_price_deduct_median"]
df = df.merge(add, on=["orderid", "basicroomid"], how="left")
return df
# 每个basicid价格的最小值
def df_min(df):
add = pd.DataFrame(df.groupby(["orderid", "basicroomid"]).price_deduct.min()).reset_index()
add.columns = ["orderid", "basicroomid", "basicroomid_price_deduct_min"]
df = df.merge(add, on=["orderid", "basicroomid"], how="left")
return df
# 每个orderid价格的最小值
def df_min_orderid(df):
add = pd.DataFrame(df.groupby(["orderid"]).price_deduct.min()).reset_index()
add.columns = ["orderid", "orderid_price_deduct_min"]
df = df.merge(add, on=["orderid"], how="left")
return df
#排序特征
def df_rank_mean(df):
add = pd.DataFrame(df.groupby(["basicroomid"]).orderid_price_deduct_min_rank.mean()).reset_index()
add.columns = ["basicroomid","orderid_price_deduct_min_rank_mean"]
df = df.merge(add, on=["basicroomid"], how="left")
return df
def df_roomrank_mean(df):
add = pd.DataFrame(df.groupby(["roomid"]).basicroomid_price_rank.mean()).reset_index()
add.columns = ["roomid","basicroomid_price_rank_mean"]
df = df.merge(add, on=["roomid"], how="left")
return df
#添加转化率特征
leak=pd.read_csv("try/leak.csv")
#提取basicroomid的转化率
feature_df=leak[["orderid","basicroomid","orderlabel"]].copy()
feature_df.sort_values("orderlabel")
feature_df=feature_df.drop_duplicates(["orderid","basicroomid"],keep="last")
basicroom_mean=pd.DataFrame(feature_df.groupby("basicroomid").orderlabel.mean()).reset_index()
basicroom_mean.columns=["basicroomid","basicroomid_mean"]
basicroom_sum=pd.DataFrame(feature_df.groupby("basicroomid").orderlabel.sum()).reset_index()
basicroom_sum.columns=["basicroomid","basicroomid_sum"]
del leak
#basic的trick
trick_1=pd.read_csv("feature_3days_train.csv").append(pd.read_csv("feature_3days_test.csv"))
trick_2=trick_1.copy()
trick_3=trick_1.copy()
trick_1.columns=["hotelid","basicroomid","orderdate","trick_1"]
trick_2.columns=["hotelid","basicroomid","orderdate","trick_2"]
trick_3.columns=["hotelid","basicroomid","orderdate","trick_3"]
trick_1["orderdate"]=trick_1["orderdate"]-1
trick_2["orderdate"]=trick_2["orderdate"]-2
trick_3["orderdate"]=trick_3["orderdate"]-3
#room的trick
trick_room=pd.read_csv("feature_room_30days_ordnumratio_train.csv").append(pd.read_csv("feature_room_30days_ordnumratio_test.csv"))
trick_room.columns=["hotelid","roomid","orderdate","trick_room"]
trick_room["orderdate"]=trick_room["orderdate"]-1
#basic七天的的trick
trick_basic_7d=pd.read_csv("feature_basic_7days_train.csv").append(pd.read_csv("feature_basic_7days_test.csv"))
trick_basic_7d.columns=["hotelid","basicroomid","orderdate","trick_basic_7d"]
trick_basic_7d["orderdate"]=trick_basic_7d["orderdate"]-1
#basic30天的trick
trick_basic_30d=pd.read_csv("feature_basic_30days_train.csv").append(pd.read_csv("feature_basic_30days_test.csv"))
trick_basic_30d_fill=trick_basic_30d.copy()
trick_basic_30d.columns=["hotelid","basicroomid","orderdate","trick_basic_30d"]
trick_basic_30d["orderdate"]=trick_basic_30d["orderdate"]-1
#trick_basic_realratio
trick_basic_realratio=pd.read_csv("feature_basic_30days_realratio_train.csv").append(pd.read_csv("feature_basic_30days_realratio_test.csv"))
trick_basic_realratio.columns=["basicroomid","orderdate","trick_basic_30days_realratio"]
trick_basic_realratio["orderdate"]=trick_basic_realratio["orderdate"]-1
#trick_room_realratio
trick_room_realratio=pd.read_csv("feature_room_30days_realratio_train.csv").append(pd.read_csv("feature_room_30days_realratio_test.csv"))
trick_room_realratio.columns=["roomid","orderdate","trick_room_30days_realratio"]
trick_room_realratio["orderdate"]=trick_room_realratio["orderdate"]-1
#构造特征
#for j in range(10):
for j in [0,2,4,6,8]:
#for j in [1,3,5,7,9]:
print j
all=pd.read_csv("try/offline_%s.csv"%j)
#20170620添加特征
for i in ["basic_week_ordernum_ratio", "basic_recent3_ordernum_ratio", "basic_comment_ratio",
"basic_30days_ordnumratio", "basic_30days_realratio"]:
all = merge_max(all, ["orderid"], i, "%s_max" % i)
for i in ["room_30days_ordnumratio", "room_30days_realratio"]:
all = merge_max(all, ["orderid", "basicroomid"], i, "%s_max" % i)
all["user_roomservice_8_345ratio"]=all["user_roomservice_5_345ratio"]
del all["user_roomservice_5_345ratio"]
all["user_roomservice_8_2ratio"]=1-all["user_roomservice_8_345ratio"]-all["user_roomservice_8_1ratio"]
all["user_roomservice_4_1ratio_3month"] = 1 - all["user_roomservice_4_0ratio_3month"] - all["user_roomservice_4_2ratio_3month"] - all["user_roomservice_4_3ratio_3month"] - all["user_roomservice_4_4ratio_3month"] - all["user_roomservice_4_5ratio_3month"]
all["user_roomservice_4_1ratio_1month"] = 1 - all["user_roomservice_4_0ratio_1month"] - all["user_roomservice_4_2ratio_1month"] - all["user_roomservice_4_3ratio_1month"] - all["user_roomservice_4_4ratio_1month"] - all["user_roomservice_4_5ratio_1month"]
all["user_roomservice_4_1ratio_1week"] = 1 - all["user_roomservice_4_0ratio_1week"] - all["user_roomservice_4_2ratio_1week"] - all["user_roomservice_4_3ratio_1week"] - all["user_roomservice_4_4ratio_1week"] - all["user_roomservice_4_5ratio_1week"]
all["user_roomservice_2_0ratio"]=1-all["user_roomservice_2_1ratio"]
all["user_roomservice_3_0ratio"]=1-all["user_roomservice_3_123ratio"]
all["user_roomservice_5_0ratio"]=1-all["user_roomservice_5_1ratio"]
all["user_roomservice_7_1ratio"]=1-all["user_roomservice_7_0ratio"]
all["user_roomservice_2_max"] = np.argmax(all[["user_roomservice_2_%sratio" % i for i in range(2)]].values, axis=1)
all["user_roomservice_3_max"] = np.argmax(all[["user_roomservice_3_%sratio" % i for i in [0,123]]].values, axis=1)
all["user_roomservice_5_max"] = np.argmax(all[["user_roomservice_5_%sratio" % i for i in range(2)]].values, axis=1)
all["user_roomservice_7_max"] = np.argmax(all[["user_roomservice_7_%sratio" % i for i in range(2)]].values, axis=1)
all["user_roomservice_4_max"]=np.argmax(all[["user_roomservice_4_%sratio"%i for i in range(6)]].values,axis=1)
all["user_roomservice_6_max"]=np.argmax(all[["user_roomservice_6_%sratio"%i for i in range(3)]].values,axis=1)
all["user_roomservice_8_max"]=np.argmax(all[["user_roomservice_8_%sratio"%i for i in [1,2,345]]].values,axis=1)
all["user_roomservice_4_max_1week"]=np.argmax(all[["user_roomservice_4_%sratio_1month"%i for i in range(6)]].values,axis=1)
all["user_roomservice_4_max_1month"]=np.argmax(all[["user_roomservice_4_%sratio_1month"%i for i in range(6)]].values,axis=1)
all["user_roomservice_4_max_3month"]=np.argmax(all[["user_roomservice_4_%sratio_3month"%i for i in range(6)]].values,axis=1)
all["roomservice_8"]=all["roomservice_8"].apply(lambda x:2 if x>2 else x-1)
all["roomservice_3"]=all["roomservice_3"].apply(lambda x:1 if x>0 else 0)
for i in range(2,9):
all["service_equal_%s"%i] = map(lambda x, y: 1 if x == y else 0, all["roomservice_%s"%i], all["user_roomservice_%s_max"%i])
del all["user_roomservice_2_0ratio"]
del all["user_roomservice_3_0ratio"]
del all["user_roomservice_5_0ratio"]
del all["user_roomservice_7_1ratio"]
all["roomid_ori"] = all["roomid"]
all["roomid"] = map(lambda x, y: int(str(x)[:-len(str(y))]), all["roomid"], all["rank"])
all = all.merge(basicroom_mean, on="basicroomid", how="left").fillna(0)
all = all.merge(basicroom_sum, on="basicroomid", how="left").fillna(0)
all=df_median(all)
all=df_min(all)
all=df_min_orderid(all)
all["basicroomid_price_rank"] = all['price_deduct'].groupby([all['orderid'], all['basicroomid']]).rank()
all["orderid_price_deduct_min_rank"] = all['orderid_price_deduct_min'].groupby(all['orderid']).rank()
all = df_rank_mean(all)
all = df_roomrank_mean(all)
#添加新特征20170527
#平均值
all=merge_mean(all,["basicroomid"],"basic_week_ordernum_ratio","basic_week_ordernum_ratio_mean")
all=merge_mean(all,["basicroomid"],"basic_recent3_ordernum_ratio","basic_recent3_ordernum_ratio_mean")
all=merge_mean(all,["basicroomid"],"basic_comment_ratio","basic_comment_ratio_mean")
all=merge_mean(all,["basicroomid"],"basic_30days_ordnumratio","basic_30days_ordnumratio_mean")
all=merge_mean(all,["basicroomid"],"basic_30days_realratio","basic_30days_realratio_mean")
all=merge_mean(all,["roomid"],"room_30days_ordnumratio","room_30days_ordnumratio_mean")
all=merge_mean(all,["roomid"],"room_30days_realratio","room_30days_realratio_mean")
all["city_num"]=all["user_ordernum"]/all["user_citynum"]
all["area_price"]=all["user_avgprice"]/all["user_avgroomarea"]
all["price_max_min_rt"]=all["user_maxprice"]/all["user_minprice"]
all["basicroomid_price_deduct_min_minprice_rt"]=all["basicroomid_price_deduct_min"]/all["user_minprice"]
all["price_dif"]=all["basicroomid_price_deduct_min"]-all["price_deduct"]
all["price_dif_hotel"]=all["basicroomid_price_deduct_min"]-all["hotel_minprice_lastord"]
all["price_dif_basic"]=all["basicroomid_price_deduct_min"]-all["basic_minprice_lastord"]
all["price_dif_rt"]=all["basicroomid_price_deduct_min"]/all["price_deduct"]
all["price_dif_hotel_rt"]=all["basicroomid_price_deduct_min"]/all["hotel_minprice_lastord"]
all["price_dif_basic_rt"]=all["basicroomid_price_deduct_min"]/all["basic_minprice_lastord"]
all["price_dif_hotel"]=all["orderid_price_deduct_min"]-all["price_deduct"]
all["price_dif_hotel_hotel"]=all["orderid_price_deduct_min"]-all["hotel_minprice_lastord"]
all["price_dif_basic_hotel"]=all["orderid_price_deduct_min"]-all["basic_minprice_lastord"]
all["price_dif_hotel_rt"]=all["orderid_price_deduct_min"]/all["price_deduct"]
all["price_dif_hotel_hotel_rt"]=all["orderid_price_deduct_min"]/all["hotel_minprice_lastord"]
all["price_dif_basic_hotel_rt"]=all["orderid_price_deduct_min"]/all["basic_minprice_lastord"]
#all["order_basic_minprice_dif"]=all["basicroomid_price_deduct_min"]-all["orderid_price_deduct_min"]
all["order_basic_minprice_rt"]=all["basicroomid_price_deduct_min"]/all["orderid_price_deduct_min"]
#all["hotel_basic_minprice_lastord_rt"]=all["basic_minprice_lastord"]/all["hotel_minprice_lastord"]
#上次订购的价格和当时最低价的比
all["hotel_last_price_min_rt"]=all["price_last_lastord"]/all["hotel_minprice_lastord"]
all["basic_last_price_min_rt"]=all["price_last_lastord"]/all["basic_minprice_lastord"]
all["hotel_last_price_min_dif"]=all["price_last_lastord"]-all["hotel_minprice_lastord"]
all["basic_last_price_min_dif"]=all["price_last_lastord"]-all["basic_minprice_lastord"]
all["price_tail1"]=all["price_deduct"]%10
all["price_tail1"]=map(lambda x:1 if x==4 or x==7 else 0,all["price_tail1"])
#all["price_tail2"]=all["price_deduct"]%100
all["basic_equal"]=map(lambda x,y:1 if x==y else 0,all["basicroomid"],all["basicroomid_lastord"])
#del all["basicroomid_lastord"]
all["room_equal"]=map(lambda x,y:1 if x==y else 0,all["roomid"],all["roomid_lastord"])
#del all["roomid_lastord"]
all["hotel_equal"]=map(lambda x,y:1 if x==y else 0,all["hotelid"],all["hotelid_lastord"])
#del all["hotelid_lastord"]
all["rank_equal"]=map(lambda x,y:1 if x==y else 0,all["rank"],all["rank_lastord"])
#价格高低
all["price_dx"] = map(lambda x, y: x-y, all["price_deduct"], all["price_last_lastord"])
all["return_dx"] = map(lambda x, y: x-y, all["returnvalue"], all["return_lastord"])
all["price_ori"] = map(lambda x, y:x+y, all["price_deduct"], all["returnvalue"])
for i in [2,3,4,5,6,8]:
all["service_equal_%s"%i] = map(lambda x, y: 1 if x == y else 0, all["roomservice_%s"%i], all["roomservice_%s_lastord"%i])
del all["roomservice_%s_lastord"%i]
for i in [2,3,4,5,6]:
all["roomtag_equal_%s"%i] = map(lambda x, y: 1 if x == y else 0, all["roomtag_%s"%i], all["roomtag_%s_lastord"%i])
del all["roomtag_%s_lastord"%i]
for i in [1,2,3,4,5,6,7,8,9,10,11]:
all["ordertype_%s_num"%i] = map(lambda x, y:x*y, all["ordertype_%s_ratio"%i], all["user_ordernum"])
del all["ordertype_%s_ratio"%i]
#所有的
for c in ["orderbehavior_1_ratio","orderbehavior_2_ratio","orderbehavior_6_ratio","orderbehavior_7_ratio",
#"user_roomservice_4_0ratio","user_roomservice_4_1ratio","user_roomservice_4_2ratio","user_roomservice_4_3ratio","user_roomservice_4_4ratio","user_roomservice_4_5ratio","user_roomservice_3_123ratio","user_roomservice_6_2ratio","user_roomservice_6_1ratio","user_roomservice_6_0ratio","user_roomservice_5_1ratio","user_roomservice_7_0ratio","user_roomservice_2_1ratio","user_roomservice_8_1ratio","user_roomservice_5_345ratio"
]:
all[c]=map(lambda x,y:x*y,all[c],all["user_ordernum"])
#一周的
for c in ["orderbehavior_3_ratio_1week","orderbehavior_4_ratio_1week","orderbehavior_5_ratio_1week",
#"user_roomservice_3_123ratio_1week","user_roomservice_7_1ratio_1week","user_roomservice_7_0ratio_1week","user_roomservice_4_5ratio_1week","user_roomservice_4_4ratio_1week","user_roomservice_4_2ratio_1week","user_roomservice_4_3ratio_1week","user_roomservice_4_0ratio_1week"
]:
all[c] = map(lambda x,y: x * y, all[c], all["user_ordnum_1week"])
#一个月的
for c in ["orderbehavior_3_ratio_1month","orderbehavior_4_ratio_1month","orderbehavior_5_ratio_1month",
#"user_roomservice_3_123ratio_1month", "user_roomservice_7_1ratio_1month", "user_roomservice_7_0ratio_1month","user_roomservice_4_5ratio_1month", "user_roomservice_4_4ratio_1month", "user_roomservice_4_2ratio_1month","user_roomservice_4_3ratio_1month", "user_roomservice_4_0ratio_1month"
]:
all[c] = map(lambda x,y: x * y, all[c], all["user_ordnum_1month"])
#三个月的
for c in ["orderbehavior_3_ratio_3month","orderbehavior_4_ratio_3month","orderbehavior_5_ratio_3month",
#"user_roomservice_3_123ratio_3month", "user_roomservice_7_1ratio_3month", "user_roomservice_7_0ratio_3month","user_roomservice_4_5ratio_3month", "user_roomservice_4_4ratio_3month", "user_roomservice_4_2ratio_3month","user_roomservice_4_3ratio_3month", "user_roomservice_4_0ratio_3month"
]:
all[c] = map(lambda x,y: x * y, all[c], all["user_ordnum_3month"])
all["price_star"]=all["price_deduct"]/(all["star"]-1)
all["price_minarea"]=all["price_deduct"]/(all["basic_minarea"]-1)
all["star_dif"]=all["user_avgstar"]-all["star"]
all["price_ave_dif_rt"]=all["price_deduct"]/all["user_avgdealprice"]
all["price_ave_star_dif"]=all["price_deduct"]/all["user_avgprice_star"]
all["price_h_w_rt"]=all["user_avgdealpriceholiday"]/all["user_avgdealpriceworkday"]
all["price_ave_dif"] = all["price_deduct"] - all["user_avgdealprice"]
all["user_roomservice_4_32_rt"]=all["user_roomservice_4_3ratio"]/all["user_roomservice_4_2ratio"]
all["user_roomservice_4_43_rt"]=all["user_roomservice_4_4ratio"]/all["user_roomservice_4_3ratio"]
print all.shape
if j==0 or j==1:
train=all
else:
train=train.append(all)
#算法测试
train_y=train["orderlabel"].values
del train["orderlabel"]
print train.shape
#lgb算法
train = lgb.Dataset(train, label=train_y)
params = {
'boosting_type': 'gbdt',
'objective': 'binary',
'metric': 'binary_logloss',
'min_child_weight': 1.5,
'num_leaves': 2 ** 5,
'lambda_l2': 10,
'subsample': 0.7,
'colsample_bytree': 0.7,
'colsample_bylevel': 0.7,
'learning_rate': 0.05,
'tree_method': 'exact',
'seed': 2017,
'nthread': 12,
'silent': True,
}
num_round = 1300
model = lgb.train(params, train, num_round,
)
for j in range(10):
print j
all=pd.read_csv("try/online_%s.csv"%j)
#20170620添加特征
for i in ["basic_week_ordernum_ratio", "basic_recent3_ordernum_ratio", "basic_comment_ratio",
"basic_30days_ordnumratio", "basic_30days_realratio"]:
all = merge_max(all, ["orderid"], i, "%s_max" % i)
for i in ["room_30days_ordnumratio", "room_30days_realratio"]:
all = merge_max(all, ["orderid", "basicroomid"], i, "%s_max" % i)
all["user_roomservice_8_345ratio"]=all["user_roomservice_5_345ratio"]
del all["user_roomservice_5_345ratio"]
all["user_roomservice_8_2ratio"]=1-all["user_roomservice_8_345ratio"]-all["user_roomservice_8_1ratio"]
all["user_roomservice_4_1ratio_3month"] = 1 - all["user_roomservice_4_0ratio_3month"] - all["user_roomservice_4_2ratio_3month"] - all["user_roomservice_4_3ratio_3month"] - all["user_roomservice_4_4ratio_3month"] - all["user_roomservice_4_5ratio_3month"]
all["user_roomservice_4_1ratio_1month"] = 1 - all["user_roomservice_4_0ratio_1month"] - all["user_roomservice_4_2ratio_1month"] - all["user_roomservice_4_3ratio_1month"] - all["user_roomservice_4_4ratio_1month"] - all["user_roomservice_4_5ratio_1month"]
all["user_roomservice_4_1ratio_1week"] = 1 - all["user_roomservice_4_0ratio_1week"] - all["user_roomservice_4_2ratio_1week"] - all["user_roomservice_4_3ratio_1week"] - all["user_roomservice_4_4ratio_1week"] - all["user_roomservice_4_5ratio_1week"]
all["user_roomservice_2_0ratio"]=1-all["user_roomservice_2_1ratio"]
all["user_roomservice_3_0ratio"]=1-all["user_roomservice_3_123ratio"]
all["user_roomservice_5_0ratio"]=1-all["user_roomservice_5_1ratio"]
all["user_roomservice_7_1ratio"]=1-all["user_roomservice_7_0ratio"]
all["user_roomservice_2_max"] = np.argmax(all[["user_roomservice_2_%sratio" % i for i in range(2)]].values, axis=1)
all["user_roomservice_3_max"] = np.argmax(all[["user_roomservice_3_%sratio" % i for i in [0,123]]].values, axis=1)
all["user_roomservice_5_max"] = np.argmax(all[["user_roomservice_5_%sratio" % i for i in range(2)]].values, axis=1)
all["user_roomservice_7_max"] = np.argmax(all[["user_roomservice_7_%sratio" % i for i in range(2)]].values, axis=1)
all["user_roomservice_4_max"]=np.argmax(all[["user_roomservice_4_%sratio"%i for i in range(6)]].values,axis=1)
all["user_roomservice_6_max"]=np.argmax(all[["user_roomservice_6_%sratio"%i for i in range(3)]].values,axis=1)
all["user_roomservice_8_max"]=np.argmax(all[["user_roomservice_8_%sratio"%i for i in [1,2,345]]].values,axis=1)
all["user_roomservice_4_max_1week"]=np.argmax(all[["user_roomservice_4_%sratio_1month"%i for i in range(6)]].values,axis=1)
all["user_roomservice_4_max_1month"]=np.argmax(all[["user_roomservice_4_%sratio_1month"%i for i in range(6)]].values,axis=1)
all["user_roomservice_4_max_3month"]=np.argmax(all[["user_roomservice_4_%sratio_3month"%i for i in range(6)]].values,axis=1)
all["roomservice_8"]=all["roomservice_8"].apply(lambda x:2 if x>2 else x-1)
all["roomservice_3"]=all["roomservice_3"].apply(lambda x:1 if x>0 else 0)
for i in range(2,9):
all["service_equal_%s"%i] = map(lambda x, y: 1 if x == y else 0, all["roomservice_%s"%i], all["user_roomservice_%s_max"%i])
del all["user_roomservice_2_0ratio"]
del all["user_roomservice_3_0ratio"]
del all["user_roomservice_5_0ratio"]
del all["user_roomservice_7_1ratio"]
all["roomid_ori"] = all["roomid"]
all["roomid"] = map(lambda x, y: int(str(x)[:-len(str(y))]), all["roomid"], all["rank"])
all = all.merge(basicroom_mean, on="basicroomid", how="left").fillna(0)
all = all.merge(basicroom_sum, on="basicroomid", how="left").fillna(0)
all=df_median(all)
all=df_min(all)
all=df_min_orderid(all)
all["basicroomid_price_rank"] = all['price_deduct'].groupby([all['orderid'], all['basicroomid']]).rank()
all["orderid_price_deduct_min_rank"] = all['orderid_price_deduct_min'].groupby(all['orderid']).rank()
all = df_rank_mean(all)
all = df_roomrank_mean(all)
#添加新特征20170527
#平均值
all=merge_mean(all,["basicroomid"],"basic_week_ordernum_ratio","basic_week_ordernum_ratio_mean")
all=merge_mean(all,["basicroomid"],"basic_recent3_ordernum_ratio","basic_recent3_ordernum_ratio_mean")
all=merge_mean(all,["basicroomid"],"basic_comment_ratio","basic_comment_ratio_mean")
all=merge_mean(all,["basicroomid"],"basic_30days_ordnumratio","basic_30days_ordnumratio_mean")
all=merge_mean(all,["basicroomid"],"basic_30days_realratio","basic_30days_realratio_mean")
all=merge_mean(all,["roomid"],"room_30days_ordnumratio","room_30days_ordnumratio_mean")
all=merge_mean(all,["roomid"],"room_30days_realratio","room_30days_realratio_mean")
all["city_num"]=all["user_ordernum"]/all["user_citynum"]
all["area_price"]=all["user_avgprice"]/all["user_avgroomarea"]
all["price_max_min_rt"]=all["user_maxprice"]/all["user_minprice"]
all["basicroomid_price_deduct_min_minprice_rt"]=all["basicroomid_price_deduct_min"]/all["user_minprice"]
all["price_dif"]=all["basicroomid_price_deduct_min"]-all["price_deduct"]
all["price_dif_hotel"]=all["basicroomid_price_deduct_min"]-all["hotel_minprice_lastord"]
all["price_dif_basic"]=all["basicroomid_price_deduct_min"]-all["basic_minprice_lastord"]
all["price_dif_rt"]=all["basicroomid_price_deduct_min"]/all["price_deduct"]
all["price_dif_hotel_rt"]=all["basicroomid_price_deduct_min"]/all["hotel_minprice_lastord"]
all["price_dif_basic_rt"]=all["basicroomid_price_deduct_min"]/all["basic_minprice_lastord"]
all["price_dif_hotel"]=all["orderid_price_deduct_min"]-all["price_deduct"]
all["price_dif_hotel_hotel"]=all["orderid_price_deduct_min"]-all["hotel_minprice_lastord"]
all["price_dif_basic_hotel"]=all["orderid_price_deduct_min"]-all["basic_minprice_lastord"]
all["price_dif_hotel_rt"]=all["orderid_price_deduct_min"]/all["price_deduct"]
all["price_dif_hotel_hotel_rt"]=all["orderid_price_deduct_min"]/all["hotel_minprice_lastord"]
all["price_dif_basic_hotel_rt"]=all["orderid_price_deduct_min"]/all["basic_minprice_lastord"]
#all["order_basic_minprice_dif"]=all["basicroomid_price_deduct_min"]-all["orderid_price_deduct_min"]
all["order_basic_minprice_rt"]=all["basicroomid_price_deduct_min"]/all["orderid_price_deduct_min"]
#all["hotel_basic_minprice_lastord_rt"]=all["basic_minprice_lastord"]/all["hotel_minprice_lastord"]
#上次订购的价格和当时最低价的比
all["hotel_last_price_min_rt"]=all["price_last_lastord"]/all["hotel_minprice_lastord"]
all["basic_last_price_min_rt"]=all["price_last_lastord"]/all["basic_minprice_lastord"]
all["hotel_last_price_min_dif"]=all["price_last_lastord"]-all["hotel_minprice_lastord"]
all["basic_last_price_min_dif"]=all["price_last_lastord"]-all["basic_minprice_lastord"]
all["price_tail1"]=all["price_deduct"]%10
all["price_tail1"]=map(lambda x:1 if x==4 or x==7 else 0,all["price_tail1"])
#all["price_tail2"]=all["price_deduct"]%100
all["basic_equal"]=map(lambda x,y:1 if x==y else 0,all["basicroomid"],all["basicroomid_lastord"])
#del all["basicroomid_lastord"]
all["room_equal"]=map(lambda x,y:1 if x==y else 0,all["roomid"],all["roomid_lastord"])
#del all["roomid_lastord"]
all["hotel_equal"]=map(lambda x,y:1 if x==y else 0,all["hotelid"],all["hotelid_lastord"])
#del all["hotelid_lastord"]
all["rank_equal"]=map(lambda x,y:1 if x==y else 0,all["rank"],all["rank_lastord"])
#价格高低
all["price_dx"] = map(lambda x, y: x-y, all["price_deduct"], all["price_last_lastord"])
all["return_dx"] = map(lambda x, y: x-y, all["returnvalue"], all["return_lastord"])
all["price_ori"] = map(lambda x, y:x+y, all["price_deduct"], all["returnvalue"])
for i in [2,3,4,5,6,8]:
all["service_equal_%s"%i] = map(lambda x, y: 1 if x == y else 0, all["roomservice_%s"%i], all["roomservice_%s_lastord"%i])
del all["roomservice_%s_lastord"%i]
for i in [2,3,4,5,6]:
all["roomtag_equal_%s"%i] = map(lambda x, y: 1 if x == y else 0, all["roomtag_%s"%i], all["roomtag_%s_lastord"%i])
del all["roomtag_%s_lastord"%i]
for i in [1,2,3,4,5,6,7,8,9,10,11]:
all["ordertype_%s_num"%i] = map(lambda x, y:x*y, all["ordertype_%s_ratio"%i], all["user_ordernum"])
del all["ordertype_%s_ratio"%i]
#所有的
for c in ["orderbehavior_1_ratio","orderbehavior_2_ratio","orderbehavior_6_ratio","orderbehavior_7_ratio",
#"user_roomservice_4_0ratio","user_roomservice_4_1ratio","user_roomservice_4_2ratio","user_roomservice_4_3ratio","user_roomservice_4_4ratio","user_roomservice_4_5ratio","user_roomservice_3_123ratio","user_roomservice_6_2ratio","user_roomservice_6_1ratio","user_roomservice_6_0ratio","user_roomservice_5_1ratio","user_roomservice_7_0ratio","user_roomservice_2_1ratio","user_roomservice_8_1ratio","user_roomservice_5_345ratio"
]:
all[c]=map(lambda x,y:x*y,all[c],all["user_ordernum"])
#一周的
for c in ["orderbehavior_3_ratio_1week","orderbehavior_4_ratio_1week","orderbehavior_5_ratio_1week",
#"user_roomservice_3_123ratio_1week","user_roomservice_7_1ratio_1week","user_roomservice_7_0ratio_1week","user_roomservice_4_5ratio_1week","user_roomservice_4_4ratio_1week","user_roomservice_4_2ratio_1week","user_roomservice_4_3ratio_1week","user_roomservice_4_0ratio_1week"
]:
all[c] = map(lambda x,y: x * y, all[c], all["user_ordnum_1week"])
#一个月的
for c in ["orderbehavior_3_ratio_1month","orderbehavior_4_ratio_1month","orderbehavior_5_ratio_1month",
#"user_roomservice_3_123ratio_1month", "user_roomservice_7_1ratio_1month", "user_roomservice_7_0ratio_1month","user_roomservice_4_5ratio_1month", "user_roomservice_4_4ratio_1month", "user_roomservice_4_2ratio_1month","user_roomservice_4_3ratio_1month", "user_roomservice_4_0ratio_1month"
]:
all[c] = map(lambda x,y: x * y, all[c], all["user_ordnum_1month"])
#三个月的
for c in ["orderbehavior_3_ratio_3month","orderbehavior_4_ratio_3month","orderbehavior_5_ratio_3month",
#"user_roomservice_3_123ratio_3month", "user_roomservice_7_1ratio_3month", "user_roomservice_7_0ratio_3month","user_roomservice_4_5ratio_3month", "user_roomservice_4_4ratio_3month", "user_roomservice_4_2ratio_3month","user_roomservice_4_3ratio_3month", "user_roomservice_4_0ratio_3month"
]:
all[c] = map(lambda x,y: x * y, all[c], all["user_ordnum_3month"])
all["price_star"]=all["price_deduct"]/(all["star"]-1)
all["price_minarea"]=all["price_deduct"]/(all["basic_minarea"]-1)
all["star_dif"]=all["user_avgstar"]-all["star"]
all["price_ave_dif_rt"]=all["price_deduct"]/all["user_avgdealprice"]
all["price_ave_star_dif"]=all["price_deduct"]/all["user_avgprice_star"]
all["price_h_w_rt"]=all["user_avgdealpriceholiday"]/all["user_avgdealpriceworkday"]
all["price_ave_dif"] = all["price_deduct"] - all["user_avgdealprice"]
all["user_roomservice_4_32_rt"]=all["user_roomservice_4_3ratio"]/all["user_roomservice_4_2ratio"]
all["user_roomservice_4_43_rt"]=all["user_roomservice_4_4ratio"]/all["user_roomservice_4_3ratio"]
print all.shape
online = model.predict(all.values)
online = pd.DataFrame(online)
online.columns = ["prob"]
online["orderid"] = all["orderid"].values
online["basicroomid"] = all["basicroomid"].values
online["predict_roomid"] = all["roomid_ori"].values
online["roomid"] = all["roomid"].values
if j==0:
result=online
else:
result=result.append(online)
result.to_csv("all_result_v31_24680_test_feature.csv",index=None)
del result["basicroomid"]
del result["roomid"]
result = result.sort_values("prob")
del result["prob"]
result = result.drop_duplicates("orderid", keep="last")
result["orderid"]=result["orderid"].apply(lambda x:"ORDER_"+str(x))
result["predict_roomid"]=result["predict_roomid"].apply(lambda x:"ROOM_"+str(x))
result.to_csv("sub_v31_24680.csv",index=None)
for j in [1,3,5,7,9]:
print j
all=pd.read_csv("try/offline_%s.csv"%j)
del all["orderlabel"]
#20170620添加特征
for i in ["basic_week_ordernum_ratio", "basic_recent3_ordernum_ratio", "basic_comment_ratio",
"basic_30days_ordnumratio", "basic_30days_realratio"]:
all = merge_max(all, ["orderid"], i, "%s_max" % i)
for i in ["room_30days_ordnumratio", "room_30days_realratio"]:
all = merge_max(all, ["orderid", "basicroomid"], i, "%s_max" % i)
all["user_roomservice_8_345ratio"]=all["user_roomservice_5_345ratio"]
del all["user_roomservice_5_345ratio"]
all["user_roomservice_8_2ratio"]=1-all["user_roomservice_8_345ratio"]-all["user_roomservice_8_1ratio"]
all["user_roomservice_4_1ratio_3month"] = 1 - all["user_roomservice_4_0ratio_3month"] - all["user_roomservice_4_2ratio_3month"] - all["user_roomservice_4_3ratio_3month"] - all["user_roomservice_4_4ratio_3month"] - all["user_roomservice_4_5ratio_3month"]
all["user_roomservice_4_1ratio_1month"] = 1 - all["user_roomservice_4_0ratio_1month"] - all["user_roomservice_4_2ratio_1month"] - all["user_roomservice_4_3ratio_1month"] - all["user_roomservice_4_4ratio_1month"] - all["user_roomservice_4_5ratio_1month"]
all["user_roomservice_4_1ratio_1week"] = 1 - all["user_roomservice_4_0ratio_1week"] - all["user_roomservice_4_2ratio_1week"] - all["user_roomservice_4_3ratio_1week"] - all["user_roomservice_4_4ratio_1week"] - all["user_roomservice_4_5ratio_1week"]
all["user_roomservice_2_0ratio"]=1-all["user_roomservice_2_1ratio"]
all["user_roomservice_3_0ratio"]=1-all["user_roomservice_3_123ratio"]
all["user_roomservice_5_0ratio"]=1-all["user_roomservice_5_1ratio"]
all["user_roomservice_7_1ratio"]=1-all["user_roomservice_7_0ratio"]
all["user_roomservice_2_max"] = np.argmax(all[["user_roomservice_2_%sratio" % i for i in range(2)]].values, axis=1)
all["user_roomservice_3_max"] = np.argmax(all[["user_roomservice_3_%sratio" % i for i in [0,123]]].values, axis=1)
all["user_roomservice_5_max"] = np.argmax(all[["user_roomservice_5_%sratio" % i for i in range(2)]].values, axis=1)
all["user_roomservice_7_max"] = np.argmax(all[["user_roomservice_7_%sratio" % i for i in range(2)]].values, axis=1)
all["user_roomservice_4_max"]=np.argmax(all[["user_roomservice_4_%sratio"%i for i in range(6)]].values,axis=1)
all["user_roomservice_6_max"]=np.argmax(all[["user_roomservice_6_%sratio"%i for i in range(3)]].values,axis=1)
all["user_roomservice_8_max"]=np.argmax(all[["user_roomservice_8_%sratio"%i for i in [1,2,345]]].values,axis=1)
all["user_roomservice_4_max_1week"]=np.argmax(all[["user_roomservice_4_%sratio_1month"%i for i in range(6)]].values,axis=1)
all["user_roomservice_4_max_1month"]=np.argmax(all[["user_roomservice_4_%sratio_1month"%i for i in range(6)]].values,axis=1)
all["user_roomservice_4_max_3month"]=np.argmax(all[["user_roomservice_4_%sratio_3month"%i for i in range(6)]].values,axis=1)
all["roomservice_8"]=all["roomservice_8"].apply(lambda x:2 if x>2 else x-1)
all["roomservice_3"]=all["roomservice_3"].apply(lambda x:1 if x>0 else 0)
for i in range(2,9):
all["service_equal_%s"%i] = map(lambda x, y: 1 if x == y else 0, all["roomservice_%s"%i], all["user_roomservice_%s_max"%i])
del all["user_roomservice_2_0ratio"]
del all["user_roomservice_3_0ratio"]
del all["user_roomservice_5_0ratio"]
del all["user_roomservice_7_1ratio"]
all["roomid_ori"] = all["roomid"]
all["roomid"] = map(lambda x, y: int(str(x)[:-len(str(y))]), all["roomid"], all["rank"])
all = all.merge(basicroom_mean, on="basicroomid", how="left").fillna(0)
all = all.merge(basicroom_sum, on="basicroomid", how="left").fillna(0)
all=df_median(all)
all=df_min(all)
all=df_min_orderid(all)
all["basicroomid_price_rank"] = all['price_deduct'].groupby([all['orderid'], all['basicroomid']]).rank()
all["orderid_price_deduct_min_rank"] = all['orderid_price_deduct_min'].groupby(all['orderid']).rank()
all = df_rank_mean(all)
all = df_roomrank_mean(all)
#添加新特征20170527
#平均值
all=merge_mean(all,["basicroomid"],"basic_week_ordernum_ratio","basic_week_ordernum_ratio_mean")
all=merge_mean(all,["basicroomid"],"basic_recent3_ordernum_ratio","basic_recent3_ordernum_ratio_mean")
all=merge_mean(all,["basicroomid"],"basic_comment_ratio","basic_comment_ratio_mean")
all=merge_mean(all,["basicroomid"],"basic_30days_ordnumratio","basic_30days_ordnumratio_mean")
all=merge_mean(all,["basicroomid"],"basic_30days_realratio","basic_30days_realratio_mean")
all=merge_mean(all,["roomid"],"room_30days_ordnumratio","room_30days_ordnumratio_mean")
all=merge_mean(all,["roomid"],"room_30days_realratio","room_30days_realratio_mean")
all["city_num"]=all["user_ordernum"]/all["user_citynum"]
all["area_price"]=all["user_avgprice"]/all["user_avgroomarea"]
all["price_max_min_rt"]=all["user_maxprice"]/all["user_minprice"]
all["basicroomid_price_deduct_min_minprice_rt"]=all["basicroomid_price_deduct_min"]/all["user_minprice"]
all["price_dif"]=all["basicroomid_price_deduct_min"]-all["price_deduct"]
all["price_dif_hotel"]=all["basicroomid_price_deduct_min"]-all["hotel_minprice_lastord"]
all["price_dif_basic"]=all["basicroomid_price_deduct_min"]-all["basic_minprice_lastord"]
all["price_dif_rt"]=all["basicroomid_price_deduct_min"]/all["price_deduct"]
all["price_dif_hotel_rt"]=all["basicroomid_price_deduct_min"]/all["hotel_minprice_lastord"]
all["price_dif_basic_rt"]=all["basicroomid_price_deduct_min"]/all["basic_minprice_lastord"]
all["price_dif_hotel"]=all["orderid_price_deduct_min"]-all["price_deduct"]
all["price_dif_hotel_hotel"]=all["orderid_price_deduct_min"]-all["hotel_minprice_lastord"]
all["price_dif_basic_hotel"]=all["orderid_price_deduct_min"]-all["basic_minprice_lastord"]
all["price_dif_hotel_rt"]=all["orderid_price_deduct_min"]/all["price_deduct"]
all["price_dif_hotel_hotel_rt"]=all["orderid_price_deduct_min"]/all["hotel_minprice_lastord"]
all["price_dif_basic_hotel_rt"]=all["orderid_price_deduct_min"]/all["basic_minprice_lastord"]
#all["order_basic_minprice_dif"]=all["basicroomid_price_deduct_min"]-all["orderid_price_deduct_min"]
all["order_basic_minprice_rt"]=all["basicroomid_price_deduct_min"]/all["orderid_price_deduct_min"]
#all["hotel_basic_minprice_lastord_rt"]=all["basic_minprice_lastord"]/all["hotel_minprice_lastord"]
#上次订购的价格和当时最低价的比
all["hotel_last_price_min_rt"]=all["price_last_lastord"]/all["hotel_minprice_lastord"]
all["basic_last_price_min_rt"]=all["price_last_lastord"]/all["basic_minprice_lastord"]
all["hotel_last_price_min_dif"]=all["price_last_lastord"]-all["hotel_minprice_lastord"]
all["basic_last_price_min_dif"]=all["price_last_lastord"]-all["basic_minprice_lastord"]
all["price_tail1"]=all["price_deduct"]%10
all["price_tail1"]=map(lambda x:1 if x==4 or x==7 else 0,all["price_tail1"])
#all["price_tail2"]=all["price_deduct"]%100
all["basic_equal"]=map(lambda x,y:1 if x==y else 0,all["basicroomid"],all["basicroomid_lastord"])
#del all["basicroomid_lastord"]
all["room_equal"]=map(lambda x,y:1 if x==y else 0,all["roomid"],all["roomid_lastord"])
#del all["roomid_lastord"]
all["hotel_equal"]=map(lambda x,y:1 if x==y else 0,all["hotelid"],all["hotelid_lastord"])
#del all["hotelid_lastord"]
all["rank_equal"]=map(lambda x,y:1 if x==y else 0,all["rank"],all["rank_lastord"])
#价格高低
all["price_dx"] = map(lambda x, y: x-y, all["price_deduct"], all["price_last_lastord"])
all["return_dx"] = map(lambda x, y: x-y, all["returnvalue"], all["return_lastord"])
all["price_ori"] = map(lambda x, y:x+y, all["price_deduct"], all["returnvalue"])
for i in [2,3,4,5,6,8]:
all["service_equal_%s"%i] = map(lambda x, y: 1 if x == y else 0, all["roomservice_%s"%i], all["roomservice_%s_lastord"%i])
del all["roomservice_%s_lastord"%i]
for i in [2,3,4,5,6]:
all["roomtag_equal_%s"%i] = map(lambda x, y: 1 if x == y else 0, all["roomtag_%s"%i], all["roomtag_%s_lastord"%i])
del all["roomtag_%s_lastord"%i]
for i in [1,2,3,4,5,6,7,8,9,10,11]:
all["ordertype_%s_num"%i] = map(lambda x, y:x*y, all["ordertype_%s_ratio"%i], all["user_ordernum"])
del all["ordertype_%s_ratio"%i]
#所有的
for c in ["orderbehavior_1_ratio","orderbehavior_2_ratio","orderbehavior_6_ratio","orderbehavior_7_ratio",
#"user_roomservice_4_0ratio","user_roomservice_4_1ratio","user_roomservice_4_2ratio","user_roomservice_4_3ratio","user_roomservice_4_4ratio","user_roomservice_4_5ratio","user_roomservice_3_123ratio","user_roomservice_6_2ratio","user_roomservice_6_1ratio","user_roomservice_6_0ratio","user_roomservice_5_1ratio","user_roomservice_7_0ratio","user_roomservice_2_1ratio","user_roomservice_8_1ratio","user_roomservice_5_345ratio"
]:
all[c]=map(lambda x,y:x*y,all[c],all["user_ordernum"])
#一周的
for c in ["orderbehavior_3_ratio_1week","orderbehavior_4_ratio_1week","orderbehavior_5_ratio_1week",
#"user_roomservice_3_123ratio_1week","user_roomservice_7_1ratio_1week","user_roomservice_7_0ratio_1week","user_roomservice_4_5ratio_1week","user_roomservice_4_4ratio_1week","user_roomservice_4_2ratio_1week","user_roomservice_4_3ratio_1week","user_roomservice_4_0ratio_1week"
]:
all[c] = map(lambda x,y: x * y, all[c], all["user_ordnum_1week"])
#一个月的
for c in ["orderbehavior_3_ratio_1month","orderbehavior_4_ratio_1month","orderbehavior_5_ratio_1month",
#"user_roomservice_3_123ratio_1month", "user_roomservice_7_1ratio_1month", "user_roomservice_7_0ratio_1month","user_roomservice_4_5ratio_1month", "user_roomservice_4_4ratio_1month", "user_roomservice_4_2ratio_1month","user_roomservice_4_3ratio_1month", "user_roomservice_4_0ratio_1month"
]:
all[c] = map(lambda x,y: x * y, all[c], all["user_ordnum_1month"])
#三个月的
for c in ["orderbehavior_3_ratio_3month","orderbehavior_4_ratio_3month","orderbehavior_5_ratio_3month",
#"user_roomservice_3_123ratio_3month", "user_roomservice_7_1ratio_3month", "user_roomservice_7_0ratio_3month","user_roomservice_4_5ratio_3month", "user_roomservice_4_4ratio_3month", "user_roomservice_4_2ratio_3month","user_roomservice_4_3ratio_3month", "user_roomservice_4_0ratio_3month"
]:
all[c] = map(lambda x,y: x * y, all[c], all["user_ordnum_3month"])
all["price_star"]=all["price_deduct"]/(all["star"]-1)
all["price_minarea"]=all["price_deduct"]/(all["basic_minarea"]-1)
all["star_dif"]=all["user_avgstar"]-all["star"]
all["price_ave_dif_rt"]=all["price_deduct"]/all["user_avgdealprice"]
all["price_ave_star_dif"]=all["price_deduct"]/all["user_avgprice_star"]
all["price_h_w_rt"]=all["user_avgdealpriceholiday"]/all["user_avgdealpriceworkday"]
all["price_ave_dif"] = all["price_deduct"] - all["user_avgdealprice"]
all["user_roomservice_4_32_rt"]=all["user_roomservice_4_3ratio"]/all["user_roomservice_4_2ratio"]
all["user_roomservice_4_43_rt"]=all["user_roomservice_4_4ratio"]/all["user_roomservice_4_3ratio"]
print all.shape
online = model.predict(all.values)
online = pd.DataFrame(online)
online.columns = ["prob"]
online["orderid"] = all["orderid"].values
online["basicroomid"] = all["basicroomid"].values
online["predict_roomid"] = all["roomid_ori"].values
online["roomid"] = all["roomid"].values
if j==0 or j==1:
result=online
else:
result=result.append(online)
result.to_csv("all_result_v31_24680_train_feature.csv",index=None)