{"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\nfrom sklearn import model_selection","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2021-08-13T11:54:59.3029Z","iopub.execute_input":"2021-08-13T11:54:59.303376Z","iopub.status.idle":"2021-08-13T11:55:00.498759Z","shell.execute_reply.started":"2021-08-13T11:54:59.30327Z","shell.execute_reply":"2021-08-13T11:55:00.496927Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.read_csv(\"../input/vinbigdata-chest-xray-abnormalities-detection/train.csv\")","metadata":{"execution":{"iopub.status.busy":"2021-08-13T11:55:00.500984Z","iopub.execute_input":"2021-08-13T11:55:00.5015Z","iopub.status.idle":"2021-08-13T11:55:00.710945Z","shell.execute_reply.started":"2021-08-13T11:55:00.501447Z","shell.execute_reply":"2021-08-13T11:55:00.709728Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.head()","metadata":{"execution":{"iopub.status.busy":"2021-08-13T11:55:06.270243Z","iopub.execute_input":"2021-08-13T11:55:06.27092Z","iopub.status.idle":"2021-08-13T11:55:06.306644Z","shell.execute_reply.started":"2021-08-13T11:55:06.270868Z","shell.execute_reply":"2021-08-13T11:55:06.305321Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[\"kfold\"] = -1\ndf = df.sample(frac=1).reset_index(drop=True)\ny = df.class_id.values","metadata":{"execution":{"iopub.status.busy":"2021-08-13T11:55:08.800092Z","iopub.execute_input":"2021-08-13T11:55:08.800527Z","iopub.status.idle":"2021-08-13T11:55:08.831903Z","shell.execute_reply.started":"2021-08-13T11:55:08.800492Z","shell.execute_reply":"2021-08-13T11:55:08.830724Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"kf = model_selection.GroupKFold(n_splits=5)\n\n# I group by image_id. Should we group by rad_id? 🤔\nfor f, (t_, v_) in enumerate(kf.split(X=df, y=y, groups=df.image_id.values)):\n    df.loc[v_, \"kfold\"] = f","metadata":{"execution":{"iopub.status.busy":"2021-08-13T11:55:18.436237Z","iopub.execute_input":"2021-08-13T11:55:18.43666Z","iopub.status.idle":"2021-08-13T11:55:18.647322Z","shell.execute_reply.started":"2021-08-13T11:55:18.436621Z","shell.execute_reply":"2021-08-13T11:55:18.646302Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.to_csv(\"train_folds.csv\", index=False)\nprint('hopefully my train_fold will help you to build good model.')","metadata":{"execution":{"iopub.status.busy":"2021-08-13T11:56:00.434743Z","iopub.execute_input":"2021-08-13T11:56:00.435108Z","iopub.status.idle":"2021-08-13T11:56:00.975838Z","shell.execute_reply.started":"2021-08-13T11:56:00.435078Z","shell.execute_reply":"2021-08-13T11:56:00.974737Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}