-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprepare_stacking.py
73 lines (35 loc) · 1.11 KB
/
prepare_stacking.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
# coding: utf-8
# In[ ]:
import datetime
from sklearn.feature_selection import chi2, SelectPercentile
from sklearn.preprocessing import OneHotEncoder, LabelEncoder
from sklearn.model_selection import StratifiedKFold
from sklearn.feature_extraction.text import CountVectorizer
from scipy import sparse
import lightgbm as lgb
import warnings
import time
import pandas as pd
import numpy as np
import os
# In[ ]:
train = pd.read_hdf('../data/train_data2.hdf', key='xunfei')
test = pd.read_hdf('../data/test_data2.hdf', key='xunfei')
data = pd.concat([train, test], axis=0, ignore_index=True)
# In[ ]:
subs=pd.read_csv('../subs/10151.csv')
oof=pd.read_hdf('../oof/10151.csv')
# In[ ]:
oof['predicted_score']=oof['oof'].values
del oof['oof']
# In[ ]:
oof_subs=oof.append(subs).reset_index(drop=True)
# In[ ]:
train_stack=pd.read_csv('../data/stacking_train.csv')
test_stack=pd.read_csv('../data/stacking_pred.csv')
# In[ ]:
stack=train_stack.append(test_stack).reset_index(drop=True)
# In[ ]:
stack=stack.merge(oof_subs,on='instance_id',how='left')
# In[ ]:
stack.to_csv('../data/stacking.csv',index=None)