{"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\nfrom tqdm import tqdm\n\n\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport pickle","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-02-24T16:41:30.431465Z","iopub.execute_input":"2023-02-24T16:41:30.431833Z","iopub.status.idle":"2023-02-24T16:41:30.438413Z","shell.execute_reply.started":"2023-02-24T16:41:30.431799Z","shell.execute_reply":"2023-02-24T16:41:30.437294Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ddf = pd.read_parquet(\"/kaggle/input/asl-signs/train_landmark_files/28656/1000106739.parquet\")\n","metadata":{"execution":{"iopub.status.busy":"2023-02-24T16:27:05.696666Z","iopub.execute_input":"2023-02-24T16:27:05.699025Z","iopub.status.idle":"2023-02-24T16:27:05.829353Z","shell.execute_reply.started":"2023-02-24T16:27:05.698987Z","shell.execute_reply":"2023-02-24T16:27:05.828347Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ddf_ft = ddf.groupby(['frame','type']).agg({'x':'mean', 'y':'mean'}).reset_index().groupby('type').agg(['mean','max','min','std']).reset_index().fillna(-1)\nddf_ft = pd.concat([ddf_ft['x'].add_suffix('_x'), ddf_ft['y'].add_suffix('_y')], axis = 1)\nddf_ft = np.array(ddf_ft).reshape(1, -1)\nddf_ft","metadata":{"execution":{"iopub.status.busy":"2023-02-24T16:27:25.021844Z","iopub.execute_input":"2023-02-24T16:27:25.022207Z","iopub.status.idle":"2023-02-24T16:27:25.050380Z","shell.execute_reply.started":"2023-02-24T16:27:25.022177Z","shell.execute_reply":"2023-02-24T16:27:25.049328Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.read_csv('../input/asl-signs/train.csv', encoding='utf8')\ndf","metadata":{"execution":{"iopub.status.busy":"2023-02-24T16:27:05.918954Z","iopub.execute_input":"2023-02-24T16:27:05.921603Z","iopub.status.idle":"2023-02-24T16:27:06.249080Z","shell.execute_reply.started":"2023-02-24T16:27:05.921560Z","shell.execute_reply":"2023-02-24T16:27:06.248192Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"samples = 1000","metadata":{"execution":{"iopub.status.busy":"2023-02-24T16:39:38.644560Z","iopub.execute_input":"2023-02-24T16:39:38.645026Z","iopub.status.idle":"2023-02-24T16:39:38.650735Z","shell.execute_reply.started":"2023-02-24T16:39:38.644979Z","shell.execute_reply":"2023-02-24T16:39:38.649466Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ret = []\nfor i in tqdm(range(len(df))):\n    ddf = pd.read_parquet(\"/kaggle/input/asl-signs/\" + df.iloc[i]['path'])\n    ddf_ft = ddf.groupby(['frame','type']).agg({'x':'mean', 'y':'mean'}).reset_index().groupby('type').agg(['mean','max','min','std']).reset_index().fillna(-1)\n    ddf_ft = pd.concat([ddf_ft['x'].add_suffix('_x'), ddf_ft['y'].add_suffix('_y')], axis = 1)\n    ddf_ft = np.array(ddf_ft).reshape(1, -1)[0]\n    ret.append(ddf_ft)","metadata":{"execution":{"iopub.status.busy":"2023-02-24T16:37:54.260621Z","iopub.execute_input":"2023-02-24T16:37:54.260985Z","iopub.status.idle":"2023-02-24T16:38:35.645578Z","shell.execute_reply.started":"2023-02-24T16:37:54.260954Z","shell.execute_reply":"2023-02-24T16:38:35.644657Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X = np.array(ret)\ny = df.iloc[:samples]['sign']\ny","metadata":{"execution":{"iopub.status.busy":"2023-02-24T16:39:53.093362Z","iopub.execute_input":"2023-02-24T16:39:53.093724Z","iopub.status.idle":"2023-02-24T16:39:53.105731Z","shell.execute_reply.started":"2023-02-24T16:39:53.093693Z","shell.execute_reply":"2023-02-24T16:39:53.104755Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"with open('features.pkl','wb') as f:\n    pickle.dump(X, f)","metadata":{"execution":{"iopub.status.busy":"2023-02-24T16:42:09.754949Z","iopub.execute_input":"2023-02-24T16:42:09.755297Z","iopub.status.idle":"2023-02-24T16:42:09.761341Z","shell.execute_reply.started":"2023-02-24T16:42:09.755269Z","shell.execute_reply":"2023-02-24T16:42:09.760282Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"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":[]}]}