{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.12.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceType":"competition","sourceId":130287,"databundleVersionId":15633993,"isSourceIdPinned":false}],"dockerImageVersionId":31286,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"!pip install numpy pandas matplotlib scikit-learn opencv-python","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2026-02-26T10:21:51.928384Z","iopub.execute_input":"2026-02-26T10:21:51.928696Z","iopub.status.idle":"2026-02-26T10:21:57.684238Z","shell.execute_reply.started":"2026-02-26T10:21:51.928666Z","shell.execute_reply":"2026-02-26T10:21:57.683054Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Import Library","metadata":{}},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport cv2\nimport os\n\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.preprocessing import LabelEncoder\nfrom sklearn.ensemble import RandomForestRegressor\nfrom sklearn.multioutput import MultiOutputRegressor\nfrom sklearn.metrics import mean_squared_error","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-02-26T10:22:36.261371Z","iopub.execute_input":"2026-02-26T10:22:36.261695Z","iopub.status.idle":"2026-02-26T10:22:38.386998Z","shell.execute_reply.started":"2026-02-26T10:22:36.261660Z","shell.execute_reply":"2026-02-26T10:22:38.386164Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Load Dataset ","metadata":{}},{"cell_type":"code","source":"base = os.listdir(\"/kaggle/input\")[0]\ndata_path = f\"/kaggle/input/{base}/\"\n\nprint(\"Dataset path:\", data_path)\nprint(\"Folder contents:\", os.listdir(data_path))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-02-26T10:26:15.884768Z","iopub.execute_input":"2026-02-26T10:26:15.885502Z","iopub.status.idle":"2026-02-26T10:26:15.894682Z","shell.execute_reply.started":"2026-02-26T10:26:15.885468Z","shell.execute_reply":"2026-02-26T10:26:15.893841Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"try:\n    train_df = pd.read_csv(data_path + \"train.csv\")\nexcept:\n    try:\n        train_df = pd.read_csv(data_path + \"train/train.csv\")\n    except:\n        subfolder = os.listdir(data_path)[0]\n        train_df = pd.read_csv(f\"{data_path}{subfolder}/train.csv\")\n\nprint(\"CSV Loaded Successfully\")\ntrain_df.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-02-26T10:26:40.205720Z","iopub.execute_input":"2026-02-26T10:26:40.206643Z","iopub.status.idle":"2026-02-26T10:26:41.667742Z","shell.execute_reply.started":"2026-02-26T10:26:40.206603Z","shell.execute_reply":"2026-02-26T10:26:41.667038Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"folders = os.listdir(data_path)\n\nmotion_path = None\nfor f in folders:\n    if \"motion\" in f.lower() or \"npy\" in f.lower():\n        motion_path = data_path + f + \"/\"\n        \nprint(\"Motion Path:\", motion_path)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-02-26T10:27:05.053140Z","iopub.execute_input":"2026-02-26T10:27:05.053490Z","iopub.status.idle":"2026-02-26T10:27:05.065340Z","shell.execute_reply.started":"2026-02-26T10:27:05.053462Z","shell.execute_reply":"2026-02-26T10:27:05.064477Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def load_motion(file_name):\n    try:\n        return np.load(motion_path + file_name).flatten()\n    except:\n        return np.zeros(1000)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-02-26T10:27:24.731810Z","iopub.execute_input":"2026-02-26T10:27:24.732510Z","iopub.status.idle":"2026-02-26T10:27:24.737134Z","shell.execute_reply.started":"2026-02-26T10:27:24.732475Z","shell.execute_reply":"2026-02-26T10:27:24.736121Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(\"Columns:\", train_df.columns)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-02-26T10:32:04.255829Z","iopub.execute_input":"2026-02-26T10:32:04.256240Z","iopub.status.idle":"2026-02-26T10:32:04.262043Z","shell.execute_reply.started":"2026-02-26T10:32:04.256207Z","shell.execute_reply":"2026-02-26T10:32:04.260781Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_df = train_df.dropna()\ntrain_df = train_df.reset_index(drop=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-02-26T10:38:47.149477Z","iopub.execute_input":"2026-02-26T10:38:47.149800Z","iopub.status.idle":"2026-02-26T10:38:47.171262Z","shell.execute_reply.started":"2026-02-26T10:38:47.149774Z","shell.execute_reply":"2026-02-26T10:38:47.170289Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def extract_motion_stats(file_name):\n    try:\n        motion = np.load(motion_path + file_name)\n        \n        return [\n            np.mean(motion),\n            np.std(motion),\n            np.max(motion),\n            np.min(motion)\n        ]\n    \n    except:\n        return [0,0,0,0]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-02-26T10:39:05.328612Z","iopub.execute_input":"2026-02-26T10:39:05.328940Z","iopub.status.idle":"2026-02-26T10:39:05.334763Z","shell.execute_reply.started":"2026-02-26T10:39:05.328912Z","shell.execute_reply":"2026-02-26T10:39:05.333668Z"}},"outputs":[],"execution_count":null}]}