{"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":"# 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","trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport glob\nfrom tqdm import tqdm\n\nimport datetime\n\nimport plotly.express as px\nfrom plotly.subplots import make_subplots\nimport plotly.graph_objs as go\n\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n%matplotlib inline\n\nimport warnings\nwarnings.filterwarnings('ignore')\n","metadata":{"execution":{"iopub.status.busy":"2022-12-13T04:05:26.313492Z","iopub.execute_input":"2022-12-13T04:05:26.313873Z","iopub.status.idle":"2022-12-13T04:05:26.322621Z","shell.execute_reply.started":"2022-12-13T04:05:26.313841Z","shell.execute_reply":"2022-12-13T04:05:26.321454Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_csvs = glob.glob('/kaggle/input/predict-volcanic-eruptions-ingv-oe/train/*')\nprint(len(train_csvs))\ntest_csvs = glob.glob('/kaggle/input/predict-volcanic-eruptions-ingv-oe/test/*')\nprint(len(test_csvs))","metadata":{"execution":{"iopub.status.busy":"2022-12-13T04:06:42.937854Z","iopub.execute_input":"2022-12-13T04:06:42.938785Z","iopub.status.idle":"2022-12-13T04:06:42.975445Z","shell.execute_reply.started":"2022-12-13T04:06:42.938746Z","shell.execute_reply":"2022-12-13T04:06:42.974278Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = pd.read_csv('/kaggle/input/predict-volcanic-eruptions-ingv-oe/train.csv')\ntrain","metadata":{"execution":{"iopub.status.busy":"2022-12-13T04:07:18.584702Z","iopub.execute_input":"2022-12-13T04:07:18.585066Z","iopub.status.idle":"2022-12-13T04:07:18.621869Z","shell.execute_reply.started":"2022-12-13T04:07:18.585036Z","shell.execute_reply":"2022-12-13T04:07:18.620588Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(train)","metadata":{"execution":{"iopub.status.busy":"2022-12-13T04:07:27.030305Z","iopub.execute_input":"2022-12-13T04:07:27.031452Z","iopub.status.idle":"2022-12-13T04:07:27.038455Z","shell.execute_reply.started":"2022-12-13T04:07:27.031408Z","shell.execute_reply":"2022-12-13T04:07:27.037200Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_submission  = pd.read_csv('/kaggle/input/predict-volcanic-eruptions-ingv-oe/sample_submission.csv')\nsample_submission","metadata":{"execution":{"iopub.status.busy":"2022-12-13T04:08:12.344144Z","iopub.execute_input":"2022-12-13T04:08:12.344550Z","iopub.status.idle":"2022-12-13T04:08:12.364796Z","shell.execute_reply.started":"2022-12-13T04:08:12.344520Z","shell.execute_reply":"2022-12-13T04:08:12.363821Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(sample_submission)","metadata":{"execution":{"iopub.status.busy":"2022-12-13T04:08:17.982495Z","iopub.execute_input":"2022-12-13T04:08:17.982911Z","iopub.status.idle":"2022-12-13T04:08:17.990501Z","shell.execute_reply.started":"2022-12-13T04:08:17.982875Z","shell.execute_reply":"2022-12-13T04:08:17.989284Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_csvs[0]","metadata":{"execution":{"iopub.status.busy":"2022-12-13T04:08:49.497444Z","iopub.execute_input":"2022-12-13T04:08:49.498494Z","iopub.status.idle":"2022-12-13T04:08:49.505980Z","shell.execute_reply.started":"2022-12-13T04:08:49.498420Z","shell.execute_reply":"2022-12-13T04:08:49.504682Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sequence = pd.read_csv(train_csvs[0])\nsequence","metadata":{"execution":{"iopub.status.busy":"2022-12-13T04:09:14.930720Z","iopub.execute_input":"2022-12-13T04:09:14.931114Z","iopub.status.idle":"2022-12-13T04:09:15.024605Z","shell.execute_reply.started":"2022-12-13T04:09:14.931084Z","shell.execute_reply":"2022-12-13T04:09:15.023412Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sequence.describe()","metadata":{"execution":{"iopub.status.busy":"2022-12-13T04:09:49.726455Z","iopub.execute_input":"2022-12-13T04:09:49.726997Z","iopub.status.idle":"2022-12-13T04:09:49.810762Z","shell.execute_reply.started":"2022-12-13T04:09:49.726949Z","shell.execute_reply":"2022-12-13T04:09:49.809315Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def show_sensors(df):\n    f,axes = plt.subplots(10,1)\n    f.set_size_inches((16,10))\n    f.tight_layout()\n    plt.subplots_adjust(bottom=-0.4)\n    \n    for i in range(1,11):\n        axes[i-1].plot(df[f'sensor_{i}'].values)\n        axes[i-1].set_title('Sensor_'+str(i))\n        axes[i-1].set_xlabel('time')","metadata":{"execution":{"iopub.status.busy":"2022-12-13T04:22:58.342844Z","iopub.execute_input":"2022-12-13T04:22:58.343376Z","iopub.status.idle":"2022-12-13T04:22:58.352278Z","shell.execute_reply.started":"2022-12-13T04:22:58.343332Z","shell.execute_reply":"2022-12-13T04:22:58.350831Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"show_sensors(sequence)","metadata":{"execution":{"iopub.status.busy":"2022-12-13T04:22:58.535516Z","iopub.execute_input":"2022-12-13T04:22:58.535908Z","iopub.status.idle":"2022-12-13T04:23:00.245329Z","shell.execute_reply.started":"2022-12-13T04:22:58.535879Z","shell.execute_reply":"2022-12-13T04:23:00.243762Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"show_sensors(sequence.fillna(0))","metadata":{"execution":{"iopub.status.busy":"2022-12-13T04:23:12.143414Z","iopub.execute_input":"2022-12-13T04:23:12.143807Z","iopub.status.idle":"2022-12-13T04:23:13.774345Z","shell.execute_reply.started":"2022-12-13T04:23:12.143775Z","shell.execute_reply":"2022-12-13T04:23:13.773046Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train","metadata":{"execution":{"iopub.status.busy":"2022-12-13T04:28:21.823453Z","iopub.execute_input":"2022-12-13T04:28:21.823827Z","iopub.status.idle":"2022-12-13T04:28:21.837219Z","shell.execute_reply.started":"2022-12-13T04:28:21.823799Z","shell.execute_reply":"2022-12-13T04:28:21.835934Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train['time_to_eruption'].apply(lambda x: datetime.timedelta(seconds = x/100))\n# 0.01초마다 샘플링 된값으로 100을 나누어 준다","metadata":{"execution":{"iopub.status.busy":"2022-12-13T04:32:55.337737Z","iopub.execute_input":"2022-12-13T04:32:55.338125Z","iopub.status.idle":"2022-12-13T04:32:55.362744Z","shell.execute_reply.started":"2022-12-13T04:32:55.338092Z","shell.execute_reply":"2022-12-13T04:32:55.361550Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train['hhmmss'] = train['time_to_eruption'].apply(lambda x: datetime.timedelta(seconds = x/100))\ntrain","metadata":{"execution":{"iopub.status.busy":"2022-12-13T04:34:03.220896Z","iopub.execute_input":"2022-12-13T04:34:03.221318Z","iopub.status.idle":"2022-12-13T04:34:03.250101Z","shell.execute_reply.started":"2022-12-13T04:34:03.221282Z","shell.execute_reply":"2022-12-13T04:34:03.248867Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize =(16,8))\nplt.hist(train['hhmmss']/ pd.Timedelta(days =1))\nplt.xlabel('Time between eruptions (days)')\nplt.ylabel('# of eruptions')","metadata":{"execution":{"iopub.status.busy":"2022-12-13T04:36:38.039358Z","iopub.execute_input":"2022-12-13T04:36:38.039771Z","iopub.status.idle":"2022-12-13T04:36:38.250198Z","shell.execute_reply.started":"2022-12-13T04:36:38.039736Z","shell.execute_reply":"2022-12-13T04:36:38.248911Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train['hhmmss']","metadata":{"execution":{"iopub.status.busy":"2022-12-13T04:37:08.582482Z","iopub.execute_input":"2022-12-13T04:37:08.582871Z","iopub.status.idle":"2022-12-13T04:37:08.592984Z","shell.execute_reply.started":"2022-12-13T04:37:08.582840Z","shell.execute_reply":"2022-12-13T04:37:08.591712Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"(train['hhmmss'] / pd.Timedelta(hours = 1)).hist()","metadata":{"execution":{"iopub.status.busy":"2022-12-13T04:37:58.826220Z","iopub.execute_input":"2022-12-13T04:37:58.826618Z","iopub.status.idle":"2022-12-13T04:37:59.072504Z","shell.execute_reply.started":"2022-12-13T04:37:58.826586Z","shell.execute_reply":"2022-12-13T04:37:59.071321Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.histogram(\n    train,\nx = 'time_to_eruption',\nwidth = 800,\nheight = 600,\nnbins = 10,\ntitle = 'Time to eruption distribustion')\n\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-12-13T04:39:29.251917Z","iopub.execute_input":"2022-12-13T04:39:29.252491Z","iopub.status.idle":"2022-12-13T04:39:30.316882Z","shell.execute_reply.started":"2022-12-13T04:39:29.252453Z","shell.execute_reply":"2022-12-13T04:39:30.315433Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}