{"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"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":35332,"databundleVersionId":3723648,"sourceType":"competition"},{"sourceId":3847094,"sourceType":"datasetVersion","datasetId":2289109},{"sourceId":3847722,"sourceType":"datasetVersion","datasetId":2289389}],"dockerImageVersionId":30197,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import numpy as np \nimport pandas as pd \nfrom sklearn.metrics import accuracy_score\nfrom sklearn.model_selection import train_test_split\nimport xgboost as xgb\nfrom sklearn.ensemble import RandomForestClassifier as rfc\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-07-07T16:09:52.880714Z","iopub.execute_input":"2022-07-07T16:09:52.881898Z","iopub.status.idle":"2022-07-07T16:09:54.550943Z","shell.execute_reply.started":"2022-07-07T16:09:52.881757Z","shell.execute_reply":"2022-07-07T16:09:54.550204Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train = pd.read_csv(\"/kaggle/input/dataset3/edited_file.csv\", header=0) \nlabels = pd.read_csv(\"/kaggle/input/dataset3/labels.csv\", header = 0)","metadata":{"execution":{"iopub.status.busy":"2022-07-07T15:45:41.794988Z","iopub.execute_input":"2022-07-07T15:45:41.795389Z","iopub.status.idle":"2022-07-07T15:45:42.188247Z","shell.execute_reply.started":"2022-07-07T15:45:41.795353Z","shell.execute_reply":"2022-07-07T15:45:42.187529Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train = pd.read_csv(\"/kaggle/input/amex-default-prediction/train_data.csv\", header=0, nrows=20000) \nlabels = pd.read_csv(\"/kaggle/input/amex-default-prediction/train_labels.csv\", header = 0, nrows=20000)","metadata":{"execution":{"iopub.status.busy":"2022-07-07T16:19:28.339889Z","iopub.execute_input":"2022-07-07T16:19:28.34046Z","iopub.status.idle":"2022-07-07T16:19:29.276622Z","shell.execute_reply.started":"2022-07-07T16:19:28.340409Z","shell.execute_reply":"2022-07-07T16:19:29.275432Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train = pd.get_dummies(train[train.columns])","metadata":{"execution":{"iopub.status.busy":"2022-07-07T16:19:31.821103Z","iopub.execute_input":"2022-07-07T16:19:31.821568Z","iopub.status.idle":"2022-07-07T16:19:32.107008Z","shell.execute_reply.started":"2022-07-07T16:19:31.821531Z","shell.execute_reply":"2022-07-07T16:19:32.106102Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"X_train, X_test, y_train, y_test = train_test_split(train, labels, random_state=0, train_size = .75)","metadata":{"execution":{"iopub.status.busy":"2022-07-07T16:19:34.609493Z","iopub.execute_input":"2022-07-07T16:19:34.609968Z","iopub.status.idle":"2022-07-07T16:19:34.992227Z","shell.execute_reply.started":"2022-07-07T16:19:34.609933Z","shell.execute_reply":"2022-07-07T16:19:34.99096Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model = rfc(max_depth = 5)\nmodel.fit(X_train, y_train[\"target\"])","metadata":{"execution":{"iopub.status.busy":"2022-07-07T15:50:14.533474Z","iopub.execute_input":"2022-07-07T15:50:14.534089Z","iopub.status.idle":"2022-07-07T15:50:15.901685Z","shell.execute_reply.started":"2022-07-07T15:50:14.534041Z","shell.execute_reply":"2022-07-07T15:50:15.900755Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model = xgb.XGBClassifier()\nmodel.fit(X_train, y_train[\"target\"])","metadata":{"execution":{"iopub.status.busy":"2022-07-07T16:19:37.786819Z","iopub.execute_input":"2022-07-07T16:19:37.787777Z","iopub.status.idle":"2022-07-07T16:21:04.866236Z","shell.execute_reply.started":"2022-07-07T16:19:37.787733Z","shell.execute_reply":"2022-07-07T16:21:04.865424Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"pred = model.predict(X_test)\naccuracy_score(y_test[\"target\"], pred)","metadata":{"execution":{"iopub.status.busy":"2022-07-07T16:21:15.50497Z","iopub.execute_input":"2022-07-07T16:21:15.505441Z","iopub.status.idle":"2022-07-07T16:21:15.692815Z","shell.execute_reply.started":"2022-07-07T16:21:15.505407Z","shell.execute_reply":"2022-07-07T16:21:15.691567Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"output = pd.DataFrame({'Target': pred})","metadata":{"execution":{"iopub.status.busy":"2022-07-07T16:21:18.13625Z","iopub.execute_input":"2022-07-07T16:21:18.137282Z","iopub.status.idle":"2022-07-07T16:21:18.142713Z","shell.execute_reply.started":"2022-07-07T16:21:18.137224Z","shell.execute_reply":"2022-07-07T16:21:18.141864Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"output.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-07-07T16:21:19.588613Z","iopub.execute_input":"2022-07-07T16:21:19.589569Z","iopub.status.idle":"2022-07-07T16:21:19.598787Z","shell.execute_reply.started":"2022-07-07T16:21:19.589514Z","shell.execute_reply":"2022-07-07T16:21:19.598079Z"},"trusted":true},"outputs":[],"execution_count":null}]}