{"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":"!pip install --quiet tables\n\n#!pip install tables --target=/kaggle/working/mysitepackages","metadata":{"execution":{"iopub.status.busy":"2022-08-24T14:58:04.388881Z","iopub.execute_input":"2022-08-24T14:58:04.389412Z","iopub.status.idle":"2022-08-24T14:58:20.015741Z","shell.execute_reply.started":"2022-08-24T14:58:04.389291Z","shell.execute_reply":"2022-08-24T14:58:20.014027Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#!ls /kaggle","metadata":{"execution":{"iopub.status.busy":"2022-08-24T14:58:20.018875Z","iopub.execute_input":"2022-08-24T14:58:20.019472Z","iopub.status.idle":"2022-08-24T14:58:20.025558Z","shell.execute_reply.started":"2022-08-24T14:58:20.019404Z","shell.execute_reply":"2022-08-24T14:58:20.024625Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from subprocess import check_output\nprint(check_output([\"ls\", \"../input\"]).decode(\"utf8\"))","metadata":{"execution":{"iopub.status.busy":"2022-08-24T14:58:20.026698Z","iopub.execute_input":"2022-08-24T14:58:20.027106Z","iopub.status.idle":"2022-08-24T14:58:20.064427Z","shell.execute_reply.started":"2022-08-24T14:58:20.027074Z","shell.execute_reply":"2022-08-24T14:58:20.062574Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import sys\nsys.path.append('/kaggle/working/mysitepackages')\n","metadata":{"execution":{"iopub.status.busy":"2022-08-24T14:58:20.068417Z","iopub.execute_input":"2022-08-24T14:58:20.069097Z","iopub.status.idle":"2022-08-24T14:58:20.075848Z","shell.execute_reply.started":"2022-08-24T14:58:20.069050Z","shell.execute_reply":"2022-08-24T14:58:20.074691Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-08-24T14:58:20.077036Z","iopub.execute_input":"2022-08-24T14:58:20.077730Z","iopub.status.idle":"2022-08-24T14:58:20.095620Z","shell.execute_reply.started":"2022-08-24T14:58:20.077684Z","shell.execute_reply":"2022-08-24T14:58:20.093871Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.options.display.max_columns = 1000 ","metadata":{"execution":{"iopub.status.busy":"2022-08-24T14:58:20.097449Z","iopub.execute_input":"2022-08-24T14:58:20.097846Z","iopub.status.idle":"2022-08-24T14:58:20.105215Z","shell.execute_reply.started":"2022-08-24T14:58:20.097812Z","shell.execute_reply":"2022-08-24T14:58:20.103517Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.options.display.max_rows = 1000 ","metadata":{"execution":{"iopub.status.busy":"2022-08-24T14:58:20.106998Z","iopub.execute_input":"2022-08-24T14:58:20.107554Z","iopub.status.idle":"2022-08-24T14:58:20.119687Z","shell.execute_reply.started":"2022-08-24T14:58:20.107514Z","shell.execute_reply":"2022-08-24T14:58:20.118517Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_cite_targets = pd.read_hdf('/kaggle/input/open-problems-multimodal/train_cite_targets.h5')\ntrain_cite_targets.shape","metadata":{"execution":{"iopub.status.busy":"2022-08-24T14:58:20.121606Z","iopub.execute_input":"2022-08-24T14:58:20.121964Z","iopub.status.idle":"2022-08-24T14:58:20.978423Z","shell.execute_reply.started":"2022-08-24T14:58:20.121933Z","shell.execute_reply":"2022-08-24T14:58:20.977126Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_multi_targets = pd.read_hdf('/kaggle/input/open-problems-multimodal/train_multi_targets.h5',start=0, stop = 1000)\ntrain_multi_targets.shape","metadata":{"execution":{"iopub.status.busy":"2022-08-24T14:58:20.979960Z","iopub.execute_input":"2022-08-24T14:58:20.980389Z","iopub.status.idle":"2022-08-24T14:58:21.838772Z","shell.execute_reply.started":"2022-08-24T14:58:20.980322Z","shell.execute_reply":"2022-08-24T14:58:21.837524Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def print_factors(x):\n   print(\"The factors of\",x,\"are:\")\n   for i in range(1, x + 1):\n       if x % i == 0:\n           print(i)\nnum = 105948\n#print_factors(num)","metadata":{"execution":{"iopub.status.busy":"2022-08-24T14:58:21.841820Z","iopub.execute_input":"2022-08-24T14:58:21.842166Z","iopub.status.idle":"2022-08-24T14:58:21.852752Z","shell.execute_reply.started":"2022-08-24T14:58:21.842135Z","shell.execute_reply":"2022-08-24T14:58:21.851289Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from tqdm import tqdm","metadata":{"execution":{"iopub.status.busy":"2022-08-24T14:58:21.854317Z","iopub.execute_input":"2022-08-24T14:58:21.855127Z","iopub.status.idle":"2022-08-24T14:58:21.865380Z","shell.execute_reply.started":"2022-08-24T14:58:21.855075Z","shell.execute_reply":"2022-08-24T14:58:21.864278Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"START = 0\ntrain_multi_final = pd.DataFrame()\nfor i in tqdm(range(981, 105948, 981)):\n    STOP = i\n    train_multi_inputs = pd.read_hdf('/kaggle/input/open-problems-multimodal/train_multi_inputs.h5',start=START, stop= STOP)\n    train_multi_new_df = pd.DataFrame()\n    start_inner= 0\n    for k in range(0, 228942, 126):    \n        #print(f\"{start}, {start+9}\")\n        train_multi_new_df = pd.concat([train_multi_new_df, pd.DataFrame({f\"{'col'}{start_inner}\": train_multi_inputs.iloc[:,start_inner:start_inner+9].mean(axis='columns')})], axis=1)\n        start_inner = 10+k\n    #print(train_multi_new_df.shape)\n    if train_multi_final.empty:\n        train_multi_final = train_multi_new_df\n    else:\n        pd.concat([train_multi_final, train_multi_new_df])\n    START = STOP","metadata":{"execution":{"iopub.status.busy":"2022-08-24T14:58:21.867025Z","iopub.execute_input":"2022-08-24T14:58:21.867537Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_multi_final.shape","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_multi_final.head(10)","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_multi_final.to_csv('train_multi_final_mean',index=False)","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"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":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]}]}