Module Expr Str ImportFrom alias Import alias identifier ImportFrom alias ImportFrom alias Import alias identifier ImportFrom alias Import alias identifier Assign NameStore Num FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr NameLoad keyword Str keyword Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad keyword Str keyword Str Assign NameStore Call AttributeLoad Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Str attr NameLoad Expr Call AttributeLoad NameLoad attr Str keyword Num keyword NameLoad Expr Call AttributeLoad NameLoad attr Str keyword Num keyword NameLoad Expr Call AttributeLoad NameLoad attr Str keyword Num keyword NameLoad Expr Call AttributeLoad NameLoad attr Str keyword Num keyword NameLoad Assign NameStore NameLoad Assign NameStore NameLoad Assign NameStore Call AttributeLoad NameLoad attr ListLoad NameLoad NameLoad Assign NameStore ListComp NameLoad comprehension NameStore AttributeLoad NameLoad attr For NameStore Call NameLoad SubscriptLoad AttributeLoad NameLoad attr Index Num body Print SubscriptLoad NameLoad Index NameLoad Call NameLoad Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index NameLoad Assign NameStore Call AttributeLoad Call AttributeLoad SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index NameLoad attr attr Expr Call AttributeLoad SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index NameLoad attr NameLoad keyword NameLoad Expr Call AttributeLoad SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index NameLoad attr NameLoad keyword NameLoad Assign NameStore Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr NameLoad Assign NameStore Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr NameLoad Print AttributeLoad NameLoad attr Print AttributeLoad NameLoad attr Return TupleLoad NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str With Call NameLoad NameLoad Str NameStore body Expr Call AttributeLoad NameLoad attr Str For TupleStore NameStore NameStore Call NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad BinOpAdd NameLoad Num NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults NameLoad body Assign NameStore ListComp Num comprehension NameStore Call NameLoad Num SubscriptLoad AttributeLoad NameLoad attr Index Num For NameStore Call NameLoad Num NameLoad body If NameLoad body Expr Call AttributeLoad NameLoad attr keyword BinOpAdd NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Assign NameStore SubscriptLoad Call AttributeLoad NameLoad attr NameLoad ExtSlice Slice Index Num For NameStore Call NameLoad Num SubscriptLoad AttributeLoad NameLoad attr Index Num body AugAssignAdd SubscriptStore NameLoad Index NameLoad SubscriptLoad NameLoad Index NameLoad For NameStore Call NameLoad Num Call NameLoad NameLoad body AugAssignDiv SubscriptStore NameLoad Index NameLoad Call NameLoad NameLoad Return Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Call AttributeLoad NameLoad attr NameLoad NameLoad decorator_list FunctionDef arguments args defaults body Expr Str Assign NameStore Str Assign NameStore Call AttributeLoad NameLoad attr keyword Num keyword Num keyword Num keyword Num keyword Num keyword Num keyword Num keyword Num keyword Str keyword Num Print Str Assign TupleStore NameStore NameStore NameStore Call NameLoad Str Str Assign NameStore ListComp Num comprehension NameStore Call NameLoad Num SubscriptLoad AttributeLoad NameLoad attr Index Num Assign NameStore Num Assign NameStore Num Assign NameStore Num Assign NameStore Call NameLoad NameLoad keyword NameLoad keyword NameLoad keyword NameLoad Assign NameStore Num For TupleStore NameStore NameStore NameLoad body Assign TupleStore NameStore NameStore TupleLoad SubscriptLoad NameLoad Index NameLoad SubscriptLoad NameLoad Index NameLoad Assign TupleStore NameStore NameStore TupleLoad SubscriptLoad Call AttributeLoad NameLoad attr NameLoad Index NameLoad SubscriptLoad Call AttributeLoad NameLoad attr NameLoad Index NameLoad Assign NameStore Call NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad keyword NameLoad Assign NameStore Call NameLoad NameLoad NameLoad Print BinOpMod Str TupleLoad BinOpAdd NameLoad Num NameLoad NameLoad AugAssignAdd NameStore NameLoad Assign NameStore Num For NameStore NameLoad body Assign SubscriptStore NameLoad Index NameLoad SubscriptLoad NameLoad Index NameLoad AugAssignAdd NameStore Num AugAssignAdd NameStore Num AugAssignDiv NameStore NameLoad Print BinOpMod Str NameLoad Print Str Expr Call NameLoad Call AttributeLoad NameLoad attr NameLoad BinOpAdd NameLoad Str Assign NameStore Call NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad keyword NameLoad Expr Call NameLoad Call AttributeLoad NameLoad attr NameLoad BinOpAdd NameLoad Str decorator_list If CompareEq NameLoad Str body Expr Call NameLoad
N/A N/A  Amazon Access Challenge Code for ensemble

Marios Michaildis script for Amazon .

Uses counts as features  and xgboost

based on Paul Duan's Script.
 


 __future__ division N/A numpy np sklearn preprocessing sklearn.metrics roc_auc_score N/A XGBoostClassifier xg sklearn.cross_validation StratifiedKFold N/A pandas pd N/A SEED 42 load_datacount N/A N/A tr te N/A N/A N/A train N/A N/A pd read_csv tr sep , quotechar " N/A test N/A N/A pd read_csv te sep , quotechar " N/A label N/A N/A N/A N/A np array N/A train N/A ACTION astype float N/A N/A N/A train drop ACTION axis 1 inplace True N/A N/A N/A test drop id axis 1 inplace True N/A N/A N/A test drop ROLE_CODE axis 1 inplace True N/A N/A N/A train drop ROLE_CODE axis 1 inplace True N/A train_s train N/A test_s test N/A result N/A N/A pd concat N/A test_s train_s N/A headers N/A f N/A f N/A result columns N/A i N/A range N/A N/A train_s shape N/A 1 N/A N/A N/A headers N/A i N/A len N/A N/A np unique N/A result N/A N/A headers N/A i N/A cnt N/A N/A N/A N/A N/A result N/A N/A headers N/A i value_counts to_dict N/A N/A N/A N/A train_s N/A N/A headers N/A i replace cnt inplace True N/A N/A N/A N/A test_s N/A N/A headers N/A i replace cnt inplace True N/A train N/A N/A N/A N/A np array train_s astype float N/A test N/A N/A N/A N/A np array test_s astype float N/A N/A train shape N/A N/A test shape N/A N/A label train test N/A save_results N/A N/A predictions filename N/A N/A N/A Given a vector of predictions, save results in CSV format. N/A N/A open filename w f N/A N/A N/A N/A f write id,ACTION
 N/A N/A i pred N/A enumerate predictions N/A N/A N/A N/A f write N/A %d,%f
 N/A N/A i 1 pred N/A bagged_set N/A N/A X_t y_c model seed estimators xt update_seed N/A True N/A N/A baggedpred N/A 0.0 N/A d N/A range 0 N/A N/A xt shape N/A 0 N/A n N/A range 0 estimators N/A N/A update_seed N/A N/A N/A N/A model set_params random_state N/A seed n N/A N/A N/A model fit X_t y_c N/A preds N/A N/A N/A model predict_proba xt N/A N/A N/A 1 N/A j N/A range 0 N/A N/A xt shape N/A 0 N/A N/A N/A baggedpred N/A j N/A preds N/A j N/A j N/A range 0 N/A len baggedpred N/A N/A N/A baggedpred N/A j N/A float estimators N/A N/A N/A np array baggedpred N/A printfilcsve N/A N/A X filename N/A N/A N/A N/A N/A np savetxt filename X N/A main N/A N/A N/A N/A N/A 
    Fit models and make predictions.
    We'll use one-hot encoding to transform our categorical features
    into binary features.
    y and X will be numpy array objects.
     N/A filename main_xgboos_count N/A model N/A N/A xg XGBoostClassifier num_round 1000 nthread 25 eta 0.02 gamma 1 max_depth 20 min_child_weight 0.1 subsample 0.9 colsample_bytree 0.5 objective binary:logistic seed 1 N/A loading data N/A N/A y X X_test N/A load_datacount train.csv test.csv N/A train_stacker N/A 0.0 N/A k N/A range 0 N/A N/A X shape N/A 0 N/A mean_auc 0.0 N/A bagging 20 N/A n 5 N/A kfolder N/A StratifiedKFold y n_folds n shuffle True random_state SEED N/A i 0 N/A N/A train_index test_index kfolder N/A N/A N/A X_train X_cv N/A N/A X N/A train_index N/A X N/A test_index N/A N/A y_train y_cv N/A N/A N/A N/A np array y N/A train_index N/A N/A N/A np array y N/A test_index N/A preds N/A bagged_set X_train y_train model SEED bagging X_cv update_seed True N/A roc_auc N/A roc_auc_score y_cv preds N/A N/A AUC (fold %d/%d): %f N/A N/A i 1 n roc_auc N/A mean_auc roc_auc N/A no 0 N/A real_index test_index N/A N/A N/A train_stacker N/A real_index N/A preds N/A no N/A no 1 N/A i 1 N/A mean_auc n N/A N/A  Average AUC: %f mean_auc N/A  printing train datasets  N/A N/A printfilcsve N/A N/A np array train_stacker N/A filename .train.csv N/A preds N/A bagged_set X y model SEED bagging X_test update_seed True N/A N/A printfilcsve N/A N/A np array preds N/A filename .test.csv N/A N/A N/A __name__ __main__ N/A N/A N/A main