Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.