{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport seaborn as sns\nimport matplotlib.pyplot as plt","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2021-08-30T14:45:50.351809Z","iopub.execute_input":"2021-08-30T14:45:50.352162Z","iopub.status.idle":"2021-08-30T14:45:50.789248Z","shell.execute_reply.started":"2021-08-30T14:45:50.352085Z","shell.execute_reply":"2021-08-30T14:45:50.788270Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = pd.read_csv('../input/beyond-analysis/train.csv')\ntest = pd.read_csv('../input/beyond-analysis/test.csv')\nsample_submission = pd.read_csv('../input/beyond-analysis/sample_submission_random.csv')","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:45:50.791495Z","iopub.execute_input":"2021-08-30T14:45:50.791955Z","iopub.status.idle":"2021-08-30T14:45:57.571426Z","shell.execute_reply.started":"2021-08-30T14:45:50.791902Z","shell.execute_reply":"2021-08-30T14:45:57.570476Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Data fields","metadata":{}},{"cell_type":"raw","source":"UNIQUE_IDENTIFIER - Unique ID of a customer\nSEQUENCE_NO - Sequence number of the entries for each customer\nSTATUS_CHECK - Customer sanity check\nCATEGORY_1 - Customer segment 1\nCATEGORY_2 - Customer segment 2\nACTIVE_YN - Activity status\nENTRY - Entry chips needed\nREVENUE - Revenue\nWINNINGS_1 - Total chips won\nWINNINGS_2 - Other chips won (subset of WINNINGS_1)\nDISCOUNT - Discount offered\nDEPOSIT - Chips purchased\nDEPOSIT_NUMBER - Deposit number\nDEPOSIT_2 - Other deposit (subset of DEPOSIT)\nWITHDRAW - Withdraw\nWITHDRAW_NUMBER - Withdraw number\nDEPOSIT_TRAILS - Deposit attempt\nENTRY_NUMBER - Contests participated\nWINNINGS_NUMBER - Contests won\nPRACTICE_ENTRY - Fun contests' entry chips\nPRACTICE_WINNINGS - Fun contests chips won\nPRACTICE_ENTRY_NUMBER - Fun contests participated\nPRACTICE_WINNINGS_NUMBER - Fun contests won","metadata":{"execution":{"iopub.status.busy":"2021-08-29T14:56:48.363567Z","iopub.execute_input":"2021-08-29T14:56:48.363908Z","iopub.status.idle":"2021-08-29T14:56:48.36873Z","shell.execute_reply.started":"2021-08-29T14:56:48.363883Z","shell.execute_reply":"2021-08-29T14:56:48.367419Z"}}},{"cell_type":"code","source":"train.head().T","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:45:57.573530Z","iopub.execute_input":"2021-08-30T14:45:57.573968Z","iopub.status.idle":"2021-08-30T14:45:57.599941Z","shell.execute_reply.started":"2021-08-30T14:45:57.573920Z","shell.execute_reply":"2021-08-30T14:45:57.598804Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.drop([\"UNIQUE_IDENTIFIER\",\"SEQUENCE_NO\",\"ENTRY_NUMBER\"],axis=1,inplace=True)","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:45:57.601447Z","iopub.execute_input":"2021-08-30T14:45:57.601807Z","iopub.status.idle":"2021-08-30T14:45:57.715571Z","shell.execute_reply.started":"2021-08-30T14:45:57.601775Z","shell.execute_reply":"2021-08-30T14:45:57.714206Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#train1=train\n#train2=train","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:45:57.716944Z","iopub.execute_input":"2021-08-30T14:45:57.717279Z","iopub.status.idle":"2021-08-30T14:45:57.723932Z","shell.execute_reply.started":"2021-08-30T14:45:57.717233Z","shell.execute_reply":"2021-08-30T14:45:57.721946Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.drop(\"Y2\",axis=1).corr()","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:45:57.727422Z","iopub.execute_input":"2021-08-30T14:45:57.727760Z","iopub.status.idle":"2021-08-30T14:45:59.237918Z","shell.execute_reply.started":"2021-08-30T14:45:57.727710Z","shell.execute_reply":"2021-08-30T14:45:59.236891Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train1=train.drop([\"ACTIVE_YN\",\"WINNINGS_2\",\"PRACTICE_ENTRY\",\"PRACTICE_WINNINGS\",\"PRACTICE_ENTRY_NUMBER\",\"PRACTICE_WINNINGS_NUMBER\",\"Y2\"],axis=1)","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:45:59.239120Z","iopub.execute_input":"2021-08-30T14:45:59.239421Z","iopub.status.idle":"2021-08-30T14:45:59.303458Z","shell.execute_reply.started":"2021-08-30T14:45:59.239387Z","shell.execute_reply":"2021-08-30T14:45:59.302430Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.drop(\"Y1\",axis=1).corr()","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:45:59.306081Z","iopub.execute_input":"2021-08-30T14:45:59.306393Z","iopub.status.idle":"2021-08-30T14:46:00.808434Z","shell.execute_reply.started":"2021-08-30T14:45:59.306362Z","shell.execute_reply":"2021-08-30T14:46:00.807321Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train2=train.drop([\"DISCOUNT\",\"DEPOSIT_2\",\"PRACTICE_ENTRY\",\"PRACTICE_WINNINGS\",\"PRACTICE_ENTRY_NUMBER\",\"PRACTICE_WINNINGS_NUMBER\",\"Y1\"],axis=1)","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:46:00.810330Z","iopub.execute_input":"2021-08-30T14:46:00.810663Z","iopub.status.idle":"2021-08-30T14:46:00.873173Z","shell.execute_reply.started":"2021-08-30T14:46:00.810630Z","shell.execute_reply":"2021-08-30T14:46:00.871973Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train['CATEGORY_2'].unique()","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:46:00.874535Z","iopub.execute_input":"2021-08-30T14:46:00.874847Z","iopub.status.idle":"2021-08-30T14:46:00.968551Z","shell.execute_reply.started":"2021-08-30T14:46:00.874816Z","shell.execute_reply":"2021-08-30T14:46:00.967392Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.preprocessing import LabelEncoder\n\nLE = LabelEncoder()\ntrain1['CATEGORY_1'] = LE.fit_transform(train1['CATEGORY_1'])\ntrain1['CATEGORY_2'] = LE.fit_transform(train1['CATEGORY_2'])\n\ntrain2['CATEGORY_1'] = LE.fit_transform(train2['CATEGORY_1'])\ntrain2['CATEGORY_2'] = LE.fit_transform(train2['CATEGORY_2'])","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:46:00.970071Z","iopub.execute_input":"2021-08-30T14:46:00.970427Z","iopub.status.idle":"2021-08-30T14:46:02.577982Z","shell.execute_reply.started":"2021-08-30T14:46:00.970378Z","shell.execute_reply":"2021-08-30T14:46:02.576967Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test.head().T","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:46:02.579504Z","iopub.execute_input":"2021-08-30T14:46:02.580217Z","iopub.status.idle":"2021-08-30T14:46:02.599739Z","shell.execute_reply.started":"2021-08-30T14:46:02.580164Z","shell.execute_reply":"2021-08-30T14:46:02.598650Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_submission.head()","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:46:02.602624Z","iopub.execute_input":"2021-08-30T14:46:02.602995Z","iopub.status.idle":"2021-08-30T14:46:02.622572Z","shell.execute_reply.started":"2021-08-30T14:46:02.602947Z","shell.execute_reply":"2021-08-30T14:46:02.621287Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.info()","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:46:02.624050Z","iopub.execute_input":"2021-08-30T14:46:02.624380Z","iopub.status.idle":"2021-08-30T14:46:02.952154Z","shell.execute_reply.started":"2021-08-30T14:46:02.624333Z","shell.execute_reply":"2021-08-30T14:46:02.950974Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train1_data = train1.drop('Y1', axis = 1)","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:46:02.953639Z","iopub.execute_input":"2021-08-30T14:46:02.954000Z","iopub.status.idle":"2021-08-30T14:46:03.023720Z","shell.execute_reply.started":"2021-08-30T14:46:02.953967Z","shell.execute_reply":"2021-08-30T14:46:03.022522Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data_labels = train[\"Y1\"]","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:46:03.025286Z","iopub.execute_input":"2021-08-30T14:46:03.025637Z","iopub.status.idle":"2021-08-30T14:46:03.030097Z","shell.execute_reply.started":"2021-08-30T14:46:03.025604Z","shell.execute_reply":"2021-08-30T14:46:03.028922Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split\nX_train, X_test, y_train, y_test = train_test_split(train1_data, train_data_labels, random_state = 0, test_size = 0.20)","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:46:03.032265Z","iopub.execute_input":"2021-08-30T14:46:03.032812Z","iopub.status.idle":"2021-08-30T14:46:03.455315Z","shell.execute_reply.started":"2021-08-30T14:46:03.032757Z","shell.execute_reply":"2021-08-30T14:46:03.454044Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import xgboost as xg\nxgb_r = xg.XGBRegressor(objective ='reg:squarederror',booster=\"dart\",\n                  n_estimators = 47, seed = 130)\nxgb_r.fit(X_train,y_train)\nxgb_r.score(X_test,y_test)","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:46:03.457061Z","iopub.execute_input":"2021-08-30T14:46:03.457566Z","iopub.status.idle":"2021-08-30T14:47:02.565053Z","shell.execute_reply.started":"2021-08-30T14:46:03.457486Z","shell.execute_reply":"2021-08-30T14:47:02.563958Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train2_data = train2.drop('Y2', axis = 1)","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:47:02.568209Z","iopub.execute_input":"2021-08-30T14:47:02.568724Z","iopub.status.idle":"2021-08-30T14:47:02.661816Z","shell.execute_reply.started":"2021-08-30T14:47:02.568680Z","shell.execute_reply":"2021-08-30T14:47:02.660629Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data_labels = train[\"Y2\"]","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:47:02.663226Z","iopub.execute_input":"2021-08-30T14:47:02.663645Z","iopub.status.idle":"2021-08-30T14:47:02.668068Z","shell.execute_reply.started":"2021-08-30T14:47:02.663600Z","shell.execute_reply":"2021-08-30T14:47:02.666817Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train, X_test, y_train, y_test = train_test_split(train2_data, train_data_labels, random_state = 0, test_size = 0.20)","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:47:02.669305Z","iopub.execute_input":"2021-08-30T14:47:02.669613Z","iopub.status.idle":"2021-08-30T14:47:03.053081Z","shell.execute_reply.started":"2021-08-30T14:47:02.669583Z","shell.execute_reply":"2021-08-30T14:47:03.051884Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import xgboost as xg\nxgb_r1 = xg.XGBRegressor(objective ='reg:squarederror',booster=\"dart\",\n                  n_estimators = 47, seed = 130)\nxgb_r1.fit(X_train,y_train)\nxgb_r1.score(X_test,y_test)","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:47:03.054548Z","iopub.execute_input":"2021-08-30T14:47:03.054878Z","iopub.status.idle":"2021-08-30T14:48:03.767847Z","shell.execute_reply.started":"2021-08-30T14:47:03.054845Z","shell.execute_reply":"2021-08-30T14:48:03.766950Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test1=test.drop([\"UNIQUE_IDENTIFIER\",\"SEQUENCE_NO\",\"ENTRY_NUMBER\",\"ACTIVE_YN\",\"WINNINGS_2\",\"PRACTICE_ENTRY\",\"PRACTICE_WINNINGS\",\"PRACTICE_ENTRY_NUMBER\",\"PRACTICE_WINNINGS_NUMBER\"],axis=1)","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:48:03.771604Z","iopub.execute_input":"2021-08-30T14:48:03.772668Z","iopub.status.idle":"2021-08-30T14:48:03.827714Z","shell.execute_reply.started":"2021-08-30T14:48:03.772618Z","shell.execute_reply":"2021-08-30T14:48:03.826538Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test2=test.drop([\"UNIQUE_IDENTIFIER\",\"SEQUENCE_NO\",\"ENTRY_NUMBER\",\"DISCOUNT\",\"DEPOSIT_2\",\"PRACTICE_ENTRY\",\"PRACTICE_WINNINGS\",\"PRACTICE_ENTRY_NUMBER\",\"PRACTICE_WINNINGS_NUMBER\"],axis=1)","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:48:03.829260Z","iopub.execute_input":"2021-08-30T14:48:03.829619Z","iopub.status.idle":"2021-08-30T14:48:03.880364Z","shell.execute_reply.started":"2021-08-30T14:48:03.829582Z","shell.execute_reply":"2021-08-30T14:48:03.879261Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.preprocessing import LabelEncoder\n\nLE = LabelEncoder()\ntest1['CATEGORY_1'] = LE.fit_transform(test1['CATEGORY_1'])\ntest1['CATEGORY_2'] = LE.fit_transform(test1['CATEGORY_2'])\n\ntest2['CATEGORY_1'] = LE.fit_transform(test2['CATEGORY_1'])\ntest2['CATEGORY_2'] = LE.fit_transform(test2['CATEGORY_2'])","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:48:03.881731Z","iopub.execute_input":"2021-08-30T14:48:03.882104Z","iopub.status.idle":"2021-08-30T14:48:05.107295Z","shell.execute_reply.started":"2021-08-30T14:48:03.882066Z","shell.execute_reply":"2021-08-30T14:48:05.106257Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y1=xgb_r.predict(test1)\ny2=xgb_r1.predict(test2)","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:48:05.112061Z","iopub.execute_input":"2021-08-30T14:48:05.112414Z","iopub.status.idle":"2021-08-30T14:48:13.592262Z","shell.execute_reply.started":"2021-08-30T14:48:05.112375Z","shell.execute_reply":"2021-08-30T14:48:13.591341Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train1.head().T","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:48:13.597542Z","iopub.execute_input":"2021-08-30T14:48:13.599571Z","iopub.status.idle":"2021-08-30T14:48:13.618454Z","shell.execute_reply.started":"2021-08-30T14:48:13.599525Z","shell.execute_reply":"2021-08-30T14:48:13.617673Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test1.shape","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:48:13.619432Z","iopub.execute_input":"2021-08-30T14:48:13.619805Z","iopub.status.idle":"2021-08-30T14:48:13.624529Z","shell.execute_reply.started":"2021-08-30T14:48:13.619777Z","shell.execute_reply":"2021-08-30T14:48:13.623767Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x = pd.DataFrame(y1,columns = ['Y1'])","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:48:13.625500Z","iopub.execute_input":"2021-08-30T14:48:13.625874Z","iopub.status.idle":"2021-08-30T14:48:13.637658Z","shell.execute_reply.started":"2021-08-30T14:48:13.625846Z","shell.execute_reply":"2021-08-30T14:48:13.636442Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x[\"Y2\"]=y2","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:48:13.638974Z","iopub.execute_input":"2021-08-30T14:48:13.639501Z","iopub.status.idle":"2021-08-30T14:48:13.653297Z","shell.execute_reply.started":"2021-08-30T14:48:13.639466Z","shell.execute_reply":"2021-08-30T14:48:13.652336Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:48:13.654682Z","iopub.execute_input":"2021-08-30T14:48:13.655210Z","iopub.status.idle":"2021-08-30T14:48:13.675306Z","shell.execute_reply.started":"2021-08-30T14:48:13.655175Z","shell.execute_reply":"2021-08-30T14:48:13.673972Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:48:13.676712Z","iopub.execute_input":"2021-08-30T14:48:13.677016Z","iopub.status.idle":"2021-08-30T14:48:13.972593Z","shell.execute_reply.started":"2021-08-30T14:48:13.676986Z","shell.execute_reply":"2021-08-30T14:48:13.971699Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"idx = 0\nx.insert(loc = idx, value = test['UNIQUE_IDENTIFIER'],column =  \"UNIQUE_IDENTIFIER\")","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:48:13.973875Z","iopub.execute_input":"2021-08-30T14:48:13.974169Z","iopub.status.idle":"2021-08-30T14:48:13.980697Z","shell.execute_reply.started":"2021-08-30T14:48:13.974140Z","shell.execute_reply":"2021-08-30T14:48:13.979588Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:48:13.982097Z","iopub.execute_input":"2021-08-30T14:48:13.982396Z","iopub.status.idle":"2021-08-30T14:48:14.003080Z","shell.execute_reply.started":"2021-08-30T14:48:13.982366Z","shell.execute_reply":"2021-08-30T14:48:14.001873Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x = x.drop_duplicates(subset = \"UNIQUE_IDENTIFIER\")","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:48:14.004468Z","iopub.execute_input":"2021-08-30T14:48:14.004803Z","iopub.status.idle":"2021-08-30T14:48:14.056800Z","shell.execute_reply.started":"2021-08-30T14:48:14.004773Z","shell.execute_reply":"2021-08-30T14:48:14.055730Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:48:14.058401Z","iopub.execute_input":"2021-08-30T14:48:14.058825Z","iopub.status.idle":"2021-08-30T14:48:14.077527Z","shell.execute_reply.started":"2021-08-30T14:48:14.058779Z","shell.execute_reply":"2021-08-30T14:48:14.076127Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x.to_csv(\"final_submission.csv\", index=False)","metadata":{"execution":{"iopub.status.busy":"2021-08-30T14:48:14.078912Z","iopub.execute_input":"2021-08-30T14:48:14.079363Z","iopub.status.idle":"2021-08-30T14:48:14.380100Z","shell.execute_reply.started":"2021-08-30T14:48:14.079304Z","shell.execute_reply":"2021-08-30T14:48:14.378685Z"},"trusted":true},"execution_count":null,"outputs":[]}]}