Created
August 23, 2017 17:29
-
-
Save Jian-Qiao/eb277070bf57870864da0ff2444c7d63 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xgboost as xgb | |
train.index=train['product_uid'] | |
Trans_Search_Term=Trans_Search_Term[0:len(train)] | |
Trans_Search_Term.index=train['product_uid'] | |
Trans_Search_Term['relevance']=train['relevance'] | |
train_vec=pd.merge(Trans_Description,Trans_Search_Term,left_index=True,right_index=True) | |
Relevance=train_vec['relevance'] | |
train_vec=train_vec.drop(['relevance'],axis=1) | |
param={} | |
param['eta']=0.01 | |
param['max_depth']=6 | |
param['silent']=1 | |
param['eval_metric']='rmse' | |
param['min_child_weight']=3 | |
param['subsample']=0.7 | |
param['colsample_bytree']=0.7 | |
num_rounds=50000 | |
train_vec=train_vec.reset_index().drop('product_uid',axis=1) | |
Relevance=Relevance.reset_index().drop('product_uid',axis=1) | |
start_ = time.time() | |
x_train, x_validation, y_train, y_validation=model_selection.train_test_split(train_vec,Relevance,test_size=0.3) | |
xgtrain = xgb.DMatrix(x_train, label= y_train) | |
xgvalidation=xgb.DMatrix(x_validation,label=y_validation) | |
clf = xgb.train(param, xgtrain, num_rounds,evals=[ (xgtrain,'train'),(xgvalidation,'eval')], | |
early_stopping_rounds=100, verbose_eval =100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment