-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGradientBoosting.py
More file actions
65 lines (30 loc) · 922 Bytes
/
GradientBoosting.py
File metadata and controls
65 lines (30 loc) · 922 Bytes
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
# coding: utf-8
# In[12]:
import pandas as pd
import numpy as np
from sklearn.ensemble import GradientBoostingClassifier
from sklearn.grid_search import GridSearchCV
from sklearn.cross_validation import cross_val_score
# In[2]:
with open('datapath.txt') as f:
datapath=f.readlines()[0].rstrip()
# In[3]:
train=pd.read_csv(datapath+'/train.csv')
# In[4]:
predictors=train.columns.drop('label')
# In[6]:
gbc=GradientBoostingClassifier()
# In[8]:
parameters={}
# In[13]:
parameters['n_estimators']=np.linspace(50,200,num=4,dtype=np.int)
parameters['max_features']=np.linspace(0.1,1.0,num=4)
parameters['min_samples_split']=np.linspace(2,10,num=4,dtype=np.int)
parameters['min_weight_fraction_leaf']=np.linspace(0.0,0.4,num=3)
# In[14]:
get_ipython().magic('pinfo GridSearchCV')
# In[15]:
model=GridSearchCV(gbc,parameters)
# In[17]:
model.fit(train[predictors],train['label'])
# In[ ]: