{"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":"markdown","source":"# Import the necessary packages ","metadata":{}},{"cell_type":"code","source":"import pandas as pd\nimport json","metadata":{"execution":{"iopub.status.busy":"2023-05-17T16:25:33.989148Z","iopub.execute_input":"2023-05-17T16:25:33.989586Z","iopub.status.idle":"2023-05-17T16:25:33.994937Z","shell.execute_reply.started":"2023-05-17T16:25:33.989554Z","shell.execute_reply":"2023-05-17T16:25:33.993686Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Reading the training landmarks","metadata":{}},{"cell_type":"code","source":"path_dir = \"/kaggle/input/asl-fingerspelling/\"","metadata":{"execution":{"iopub.status.busy":"2023-05-17T15:12:34.871955Z","iopub.execute_input":"2023-05-17T15:12:34.872645Z","iopub.status.idle":"2023-05-17T15:12:34.877797Z","shell.execute_reply.started":"2023-05-17T15:12:34.872609Z","shell.execute_reply":"2023-05-17T15:12:34.87637Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"supplemental_metadata = pd.read_csv(path_dir + \"/supplemental_metadata.csv\")","metadata":{"execution":{"iopub.status.busy":"2023-05-17T15:27:13.192104Z","iopub.execute_input":"2023-05-17T15:27:13.192782Z","iopub.status.idle":"2023-05-17T15:27:13.331728Z","shell.execute_reply.started":"2023-05-17T15:27:13.192737Z","shell.execute_reply":"2023-05-17T15:27:13.330733Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# 1 - let's take one sample\nsample = supplemental_metadata.head(1)\nsample_path = sample[\"path\"][0]\nsample_file_id = sample[\"file_id\"][0]\nsample_sequence_id = sample[\"sequence_id\"][0]\nsample_participant_id = sample[\"participant_id\"][0]\nsample_phrase = sample[\"phrase\"][0]","metadata":{"execution":{"iopub.status.busy":"2023-05-17T15:53:45.467986Z","iopub.execute_input":"2023-05-17T15:53:45.468401Z","iopub.status.idle":"2023-05-17T15:53:45.476895Z","shell.execute_reply.started":"2023-05-17T15:53:45.468371Z","shell.execute_reply":"2023-05-17T15:53:45.475244Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# 2 - let's see landmark all info about this sample\nlandmark_sample = pd.read_parquet(path_dir + sample_path)\nprint(\"the name of the file that has the land marks for this sample:\" ,sample_file_id)\nprint(\"Number of frames:\" ,landmark_sample.loc[sample_sequence_id].shape[0])\nprint(\"participant_id:\" ,sample_participant_id)\nprint(\"sample phrase:\" ,sample_phrase)","metadata":{"execution":{"iopub.status.busy":"2023-05-17T16:23:11.602724Z","iopub.execute_input":"2023-05-17T16:23:11.604017Z","iopub.status.idle":"2023-05-17T16:23:14.269688Z","shell.execute_reply.started":"2023-05-17T16:23:11.603971Z","shell.execute_reply":"2023-05-17T16:23:14.268127Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# 3 - the data for this sample itself\nsample_landmark_info = landmark_sample.loc[sample_sequence_id].filter(regex=\"hand|frame\")","metadata":{"execution":{"iopub.status.busy":"2023-05-17T16:45:44.301504Z","iopub.execute_input":"2023-05-17T16:45:44.302018Z","iopub.status.idle":"2023-05-17T16:45:44.311905Z","shell.execute_reply.started":"2023-05-17T16:45:44.301986Z","shell.execute_reply":"2023-05-17T16:45:44.310718Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# 4 -  take just the useful info\nsample_hands_info = sample_landmark_info.filter(regex=\"hand|frame\").copy()\nsample_hands_info = sample_hands_info.dropna(axis=1,how=\"all\")\nsample_hands_info[\"group_no\"] = sample_hands_info.filter(regex=\"hand\").isna().all(axis=1).cumsum()\n# we made the thresh = 20 to make sure that we have at least just one hand in each frame\nsample_hands_info = sample_hands_info.dropna(axis=0,thresh=20)\nsample_hands_info.head()","metadata":{"execution":{"iopub.status.busy":"2023-05-17T16:58:23.410031Z","iopub.execute_input":"2023-05-17T16:58:23.410787Z","iopub.status.idle":"2023-05-17T16:58:23.456319Z","shell.execute_reply.started":"2023-05-17T16:58:23.410751Z","shell.execute_reply":"2023-05-17T16:58:23.454864Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Targets","metadata":{}},{"cell_type":"code","source":"f = open('/kaggle/input/asl-fingerspelling/character_to_prediction_index.json')\ntarget_dict = json.load(f)","metadata":{"execution":{"iopub.status.busy":"2023-05-17T16:26:42.846131Z","iopub.execute_input":"2023-05-17T16:26:42.846983Z","iopub.status.idle":"2023-05-17T16:26:42.855626Z","shell.execute_reply.started":"2023-05-17T16:26:42.846948Z","shell.execute_reply":"2023-05-17T16:26:42.854053Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# it is calssification task with 58 classes\ntarget_dict","metadata":{"execution":{"iopub.status.busy":"2023-05-17T16:27:35.255067Z","iopub.execute_input":"2023-05-17T16:27:35.256506Z","iopub.status.idle":"2023-05-17T16:27:35.267087Z","shell.execute_reply.started":"2023-05-17T16:27:35.256465Z","shell.execute_reply":"2023-05-17T16:27:35.265716Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}