{"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 numpy as np\nimport pandas as pd\nimport os\n\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nplt.style.use('seaborn-white')\n%matplotlib inline\n\nfrom sklearn.model_selection import train_test_split, GridSearchCV\nimport lightgbm as lgbm\nfrom lightgbm import LGBMRegressor\nfrom xgboost import XGBRegressor\nfrom tqdm import tqdm\n\nfile_list = []\nfile_list_train = []\nfile_list_test = []\n\n\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        file_list.append(os.path.join(dirname, filename))\n        \nPATH = '/kaggle/input/predict-volcanic-eruptions-ingv-oe/'\n\nfor dirname, _, filenames in os.walk('/kaggle/input/predict-volcanic-eruptions-ingv-oe/train'):\n    for filename in filenames:\n        file_list_train.append(os.path.join(dirname, filename))\n        \nfor dirname, _, filenames in os.walk('/kaggle/input/predict-volcanic-eruptions-ingv-oe/test'):\n    for filename in filenames:\n        file_list_test.append(os.path.join(dirname, filename))","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-12-04T11:48:03.441534Z","iopub.execute_input":"2022-12-04T11:48:03.442431Z","iopub.status.idle":"2022-12-04T11:48:17.783703Z","shell.execute_reply.started":"2022-12-04T11:48:03.442361Z","shell.execute_reply":"2022-12-04T11:48:17.783028Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(file_list[0])\n\n\nprint(pd.read_csv(file_list[0]))\nprint(pd.read_csv(file_list[0]).isna().sum())","metadata":{"execution":{"iopub.status.busy":"2022-12-04T11:48:17.787290Z","iopub.execute_input":"2022-12-04T11:48:17.787561Z","iopub.status.idle":"2022-12-04T11:48:17.820982Z","shell.execute_reply.started":"2022-12-04T11:48:17.787538Z","shell.execute_reply":"2022-12-04T11:48:17.820124Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(file_list_train[0])\nprint(pd.read_csv(file_list_train[0]))","metadata":{"execution":{"iopub.status.busy":"2022-12-04T11:48:17.822403Z","iopub.execute_input":"2022-12-04T11:48:17.822712Z","iopub.status.idle":"2022-12-04T11:48:17.967873Z","shell.execute_reply.started":"2022-12-04T11:48:17.822679Z","shell.execute_reply":"2022-12-04T11:48:17.967028Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(file_list[1])\nprint(pd.read_csv(file_list[1]))","metadata":{"execution":{"iopub.status.busy":"2022-12-04T11:48:17.970232Z","iopub.execute_input":"2022-12-04T11:48:17.970553Z","iopub.status.idle":"2022-12-04T11:48:17.986013Z","shell.execute_reply.started":"2022-12-04T11:48:17.970527Z","shell.execute_reply":"2022-12-04T11:48:17.984864Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(file_list_test[0])\nprint(pd.read_csv(file_list_test[0]))","metadata":{"execution":{"iopub.status.busy":"2022-12-04T11:48:17.987440Z","iopub.execute_input":"2022-12-04T11:48:17.987763Z","iopub.status.idle":"2022-12-04T11:48:18.111493Z","shell.execute_reply.started":"2022-12-04T11:48:17.987740Z","shell.execute_reply":"2022-12-04T11:48:18.109998Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(len(file_list_test)) \nkeys = list(pd.read_csv(file_list_test[0]).keys()) \nprint(keys)\nnanC = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\nfor index in range(len(file_list_test)):\n    if(index % 200 == 0): \n        print(index)\n    df = pd.read_csv(file_list_test[index]) \n    for key in df.keys():\n        if df[key].isna().sum() == len(pd.read_csv(file_list_train[0])):            \n            nanC[keys.index(key)] += 1\n\nprint(nanC)\ndata={'sensors': keys, 'count': nanC}\nNaNDF = pd.DataFrame(data)\nprint(NaNDF)","metadata":{"execution":{"iopub.status.busy":"2022-12-04T11:48:18.112959Z","iopub.execute_input":"2022-12-04T11:48:18.113455Z","iopub.status.idle":"2022-12-04T12:29:30.769149Z","shell.execute_reply.started":"2022-12-04T11:48:18.113422Z","shell.execute_reply":"2022-12-04T12:29:30.767045Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"NaNDF.plot(figsize =(20, 20), x=\"sensors\", y=\"count\", kind=\"bar\",  rot=5, fontsize=14 )","metadata":{"execution":{"iopub.status.busy":"2022-12-04T12:29:30.771790Z","iopub.execute_input":"2022-12-04T12:29:30.772432Z","iopub.status.idle":"2022-12-04T12:29:31.131450Z","shell.execute_reply.started":"2022-12-04T12:29:30.772402Z","shell.execute_reply":"2022-12-04T12:29:31.129817Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(len(file_list_test))","metadata":{"execution":{"iopub.status.busy":"2022-12-04T12:29:31.132758Z","iopub.execute_input":"2022-12-04T12:29:31.133036Z","iopub.status.idle":"2022-12-04T12:29:31.139608Z","shell.execute_reply.started":"2022-12-04T12:29:31.133011Z","shell.execute_reply":"2022-12-04T12:29:31.138373Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(len(file_list_train))","metadata":{"execution":{"iopub.status.busy":"2022-12-04T12:29:31.141414Z","iopub.execute_input":"2022-12-04T12:29:31.141733Z","iopub.status.idle":"2022-12-04T12:29:31.152332Z","shell.execute_reply.started":"2022-12-04T12:29:31.141709Z","shell.execute_reply":"2022-12-04T12:29:31.150656Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"files_train = [file.split('/')[-1].split('.')[-2] for file in file_list_train]\nfiles_test = [file.split('/')[-1].split('.')[-2] for file in file_list_test]","metadata":{"execution":{"iopub.status.busy":"2022-12-04T12:29:31.157352Z","iopub.execute_input":"2022-12-04T12:29:31.157654Z","iopub.status.idle":"2022-12-04T12:29:31.172108Z","shell.execute_reply.started":"2022-12-04T12:29:31.157630Z","shell.execute_reply":"2022-12-04T12:29:31.171060Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(files_train[0:10])","metadata":{"execution":{"iopub.status.busy":"2022-12-04T12:29:31.173338Z","iopub.execute_input":"2022-12-04T12:29:31.173625Z","iopub.status.idle":"2022-12-04T12:29:31.191656Z","shell.execute_reply.started":"2022-12-04T12:29:31.173593Z","shell.execute_reply":"2022-12-04T12:29:31.190505Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(files_test[0:10])","metadata":{"execution":{"iopub.status.busy":"2022-12-04T12:29:31.193421Z","iopub.execute_input":"2022-12-04T12:29:31.193709Z","iopub.status.idle":"2022-12-04T12:29:31.203398Z","shell.execute_reply.started":"2022-12-04T12:29:31.193686Z","shell.execute_reply":"2022-12-04T12:29:31.202669Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_set = set(files_test)\ntrain_set = set(files_train)\ninter = test_set.intersection(train_set)\n\nprint(inter)","metadata":{"execution":{"iopub.status.busy":"2022-12-04T12:29:31.204657Z","iopub.execute_input":"2022-12-04T12:29:31.204945Z","iopub.status.idle":"2022-12-04T12:29:31.216410Z","shell.execute_reply.started":"2022-12-04T12:29:31.204921Z","shell.execute_reply":"2022-12-04T12:29:31.215136Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = pd.read_csv(PATH+'train.csv')","metadata":{"execution":{"iopub.status.busy":"2022-12-04T12:29:31.218029Z","iopub.execute_input":"2022-12-04T12:29:31.218412Z","iopub.status.idle":"2022-12-04T12:29:31.236795Z","shell.execute_reply.started":"2022-12-04T12:29:31.218388Z","shell.execute_reply":"2022-12-04T12:29:31.235687Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.distplot(train['time_to_eruption'],\n            hist=True,\n            kde=True,\n            bins=100,\n            color='blue',\n            hist_kws={'edgecolor':'black'})","metadata":{"execution":{"iopub.status.busy":"2022-12-04T12:29:31.240350Z","iopub.execute_input":"2022-12-04T12:29:31.240621Z","iopub.status.idle":"2022-12-04T12:29:31.592090Z","shell.execute_reply.started":"2022-12-04T12:29:31.240599Z","shell.execute_reply":"2022-12-04T12:29:31.590868Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train['time_to_eruption'].describe()","metadata":{"execution":{"iopub.status.busy":"2022-12-04T12:29:31.593556Z","iopub.execute_input":"2022-12-04T12:29:31.593832Z","iopub.status.idle":"2022-12-04T12:29:31.611088Z","shell.execute_reply.started":"2022-12-04T12:29:31.593809Z","shell.execute_reply":"2022-12-04T12:29:31.609191Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_segment_id = pd.read_csv(PATH+'train/800654756.csv')\n\ndf_segment_id.plot(figsize=(20,20),\n                  subplots=True,\n                  layout=(10,1),\n                  rot=0,\n                  lw=1,\n                  title='sergment_id #800654756')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-12-04T12:29:31.612388Z","iopub.execute_input":"2022-12-04T12:29:31.612622Z","iopub.status.idle":"2022-12-04T12:29:33.911526Z","shell.execute_reply.started":"2022-12-04T12:29:31.612600Z","shell.execute_reply":"2022-12-04T12:29:33.910671Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"display(train.sort_values('time_to_eruption', axis=0, ascending=True).iloc[[0,-1],:])\n\nsegment_id_min = 601524801\nsegment_id_max = 1923243961\n\ndf_segment_id_min = pd.read_csv(PATH+'train/'+str(segment_id_min)+'.csv')\ndf_segment_id_max = pd.read_csv(PATH+'train/'+str(segment_id_max)+'.csv')","metadata":{"execution":{"iopub.status.busy":"2022-12-04T12:29:33.912640Z","iopub.execute_input":"2022-12-04T12:29:33.913770Z","iopub.status.idle":"2022-12-04T12:29:34.175198Z","shell.execute_reply.started":"2022-12-04T12:29:33.913739Z","shell.execute_reply":"2022-12-04T12:29:34.173328Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_segment_id_min.plot(figsize=(20,20), subplots=True, layout=(10,1), rot=0, lw=1, title='segment_id #601524801 (min)')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-12-04T12:29:34.176952Z","iopub.execute_input":"2022-12-04T12:29:34.177381Z","iopub.status.idle":"2022-12-04T12:29:36.318469Z","shell.execute_reply.started":"2022-12-04T12:29:34.177346Z","shell.execute_reply":"2022-12-04T12:29:36.317357Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_segment_id_max.plot(figsize=(20,20), subplots=True, layout=(10,1), rot=0, lw=1, title='segment_id #1923243961 (max)')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-12-04T12:29:36.320068Z","iopub.execute_input":"2022-12-04T12:29:36.320403Z","iopub.status.idle":"2022-12-04T12:29:38.612103Z","shell.execute_reply.started":"2022-12-04T12:29:36.320374Z","shell.execute_reply":"2022-12-04T12:29:38.611356Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def build_features(signal, ts, sensor_id):\n    X = pd.DataFrame()\n    f = np.fft.fft(signal)\n    f_real = np.real(f)\n    X.loc[ts, f'{sensor_id}_sum'] = signal.sum()\n    X.loc[ts, f'{sensor_id}_mean'] = signal.mean()\n    X.loc[ts, f'{sensor_id}_std'] = signal.std()\n    X.loc[ts, f'{sensor_id}_var'] = signal.var()\n    X.loc[ts, f'{sensor_id}_max'] = signal.max()\n    X.loc[ts, f'{sensor_id}_min'] = signal.min()\n    X.loc[ts, f'{sensor_id}_skew'] = signal.skew()\n    X.loc[ts, f'{sensor_id}_mad'] = signal.mad()\n    X.loc[ts, f'{sensor_id}_kurtosis'] = signal.kurtosis()\n    X.loc[ts, f'{sensor_id}_quantile99'] = np.quantile(signal, 0.99)\n    X.loc[ts, f'{sensor_id}_quantile95'] = np.quantile(signal, 0.95)\n    X.loc[ts, f'{sensor_id}_quantile85'] = np.quantile(signal, 0.85)\n    X.loc[ts, f'{sensor_id}_quantile75'] = np.quantile(signal, 0.75)\n    X.loc[ts, f'{sensor_id}_quantile55'] = np.quantile(signal, 0.55)\n    X.loc[ts, f'{sensor_id}_quantile45'] = np.quantile(signal, 0.45)\n    X.loc[ts, f'{sensor_id}_quantile25'] = np.quantile(signal, 0.25)\n    X.loc[ts, f'{sensor_id}_quantile15'] = np.quantile(signal, 0.15)\n    X.loc[ts, f'{sensor_id}_quantile05'] = np.quantile(signal, 0.05)\n    X.loc[ts, f'{sensor_id}_quantile01'] = np.quantile(signal, 0.01)\n    X.loc[ts, f'{sensor_id}_fft_real_mean'] = f_real.mean()\n    X.loc[ts, f'{sensor_id}_fft_real_std'] = f_real.std()\n    X.loc[ts, f'{sensor_id}_fft_real_max'] = f_real.max()\n    X.loc[ts, f'{sensor_id}_fft_real_min'] = f_real.min()\n    \n    return X","metadata":{"execution":{"iopub.status.busy":"2022-12-04T12:29:38.613145Z","iopub.execute_input":"2022-12-04T12:29:38.614032Z","iopub.status.idle":"2022-12-04T12:29:38.625961Z","shell.execute_reply.started":"2022-12-04T12:29:38.614003Z","shell.execute_reply":"2022-12-04T12:29:38.625141Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_set = list()\nseg = 0\n\nfor seg, segment_id in enumerate(train.segment_id):\n    signals = pd.read_csv(PATH+'train/'+str(segment_id)+'.csv')\n    train_row = []\n    \n    if seg%200 == 0:\n        print('Processing segment_id={}'.format(seg))\n        \n    for sensor in range(0, 10):\n        sensor_id = f'sensor_{sensor+1}'\n        train_row.append(build_features(signals[sensor_id].fillna(0), segment_id, sensor_id))\n        \n    train_row = pd.concat(train_row, axis=1)\n    train_set.append(train_row)\n    seg+=1\n    \ntrain_set = pd.concat(train_set)","metadata":{"execution":{"iopub.status.busy":"2022-12-04T12:29:38.627296Z","iopub.execute_input":"2022-12-04T12:29:38.627726Z","iopub.status.idle":"2022-12-04T13:03:27.768948Z","shell.execute_reply.started":"2022-12-04T12:29:38.627691Z","shell.execute_reply":"2022-12-04T13:03:27.767932Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_set = train_set.reset_index()\ntrain_set = train_set.rename(columns={'index':  'segment_id'})\n\ntrain_set = pd.merge(train_set, train, on='segment_id')","metadata":{"execution":{"iopub.status.busy":"2022-12-04T13:03:27.770427Z","iopub.execute_input":"2022-12-04T13:03:27.770745Z","iopub.status.idle":"2022-12-04T13:03:27.803638Z","shell.execute_reply.started":"2022-12-04T13:03:27.770715Z","shell.execute_reply":"2022-12-04T13:03:27.802613Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(train_set.head(3))","metadata":{"execution":{"iopub.status.busy":"2022-12-04T13:03:27.804787Z","iopub.execute_input":"2022-12-04T13:03:27.806166Z","iopub.status.idle":"2022-12-04T13:03:27.820147Z","shell.execute_reply.started":"2022-12-04T13:03:27.806071Z","shell.execute_reply":"2022-12-04T13:03:27.819416Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_files = []\nfor dirname, _, filenames in os.walk(PATH+'test/'):\n    for filename in filenames:\n        test_files.append(filename[:-4])\n        \ntest = pd.DataFrame(test_files, columns=['segment_id'])","metadata":{"execution":{"iopub.status.busy":"2022-12-04T13:03:27.821200Z","iopub.execute_input":"2022-12-04T13:03:27.821665Z","iopub.status.idle":"2022-12-04T13:03:29.639837Z","shell.execute_reply.started":"2022-12-04T13:03:27.821640Z","shell.execute_reply":"2022-12-04T13:03:29.639051Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_set = list()\nseg = 0\n\nfor seg, segment_id in enumerate(test.segment_id):\n    signals = pd.read_csv(PATH+'test/'+str(segment_id)+'.csv')\n    test_row = []\n    \n    if seg%200 == 0:\n        print('Processing segment_id={}'.format(seg))\n        \n    for sensor in range(0, 10):\n        sensor_id = f'sensor_{sensor+1}'\n        test_row.append(build_features(signals[sensor_id].fillna(0), segment_id, sensor_id))\n        \n    test_row = pd.concat(test_row, axis=1)\n    test_set.append(test_row)\n    seg+=1\n    \ntest_set = pd.concat(test_set)","metadata":{"execution":{"iopub.status.busy":"2022-12-04T13:03:29.641074Z","iopub.execute_input":"2022-12-04T13:03:29.641532Z","iopub.status.idle":"2022-12-04T13:36:18.460979Z","shell.execute_reply.started":"2022-12-04T13:03:29.641505Z","shell.execute_reply":"2022-12-04T13:36:18.459543Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_set = test_set.reset_index()\ntest_set = test_set.rename(columns={'index':  'segment_id'})\n\ntest_set = pd.merge(test_set, test, on='segment_id')","metadata":{"execution":{"iopub.status.busy":"2022-12-04T13:36:18.463251Z","iopub.execute_input":"2022-12-04T13:36:18.463625Z","iopub.status.idle":"2022-12-04T13:36:18.492726Z","shell.execute_reply.started":"2022-12-04T13:36:18.463600Z","shell.execute_reply":"2022-12-04T13:36:18.491686Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(test_set.head(3))","metadata":{"execution":{"iopub.status.busy":"2022-12-04T13:36:18.498386Z","iopub.execute_input":"2022-12-04T13:36:18.498721Z","iopub.status.idle":"2022-12-04T13:36:18.514343Z","shell.execute_reply.started":"2022-12-04T13:36:18.498696Z","shell.execute_reply":"2022-12-04T13:36:18.512923Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X = train_set.drop(['segment_id', 'time_to_eruption'], axis=1)\ny = train_set['time_to_eruption']\n\nX_train, X_valid, y_train, y_valid = train_test_split(X, y, \n                                                      test_size=0.2,\n                                                      random_state=42)","metadata":{"execution":{"iopub.status.busy":"2022-12-04T13:36:18.515806Z","iopub.execute_input":"2022-12-04T13:36:18.516987Z","iopub.status.idle":"2022-12-04T13:36:18.537733Z","shell.execute_reply.started":"2022-12-04T13:36:18.516947Z","shell.execute_reply":"2022-12-04T13:36:18.536306Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(X_train.head(3))\nprint('np.shape(X_train) = ', np.shape(X_train))","metadata":{"execution":{"iopub.status.busy":"2022-12-04T13:36:18.539397Z","iopub.execute_input":"2022-12-04T13:36:18.539807Z","iopub.status.idle":"2022-12-04T13:36:18.555700Z","shell.execute_reply.started":"2022-12-04T13:36:18.539782Z","shell.execute_reply":"2022-12-04T13:36:18.553831Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(y_train.head(3))\nprint('np.shape(y_train) = ', np.shape(y_train))","metadata":{"execution":{"iopub.status.busy":"2022-12-04T13:36:18.559354Z","iopub.execute_input":"2022-12-04T13:36:18.559642Z","iopub.status.idle":"2022-12-04T13:36:18.571008Z","shell.execute_reply.started":"2022-12-04T13:36:18.559620Z","shell.execute_reply":"2022-12-04T13:36:18.569557Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.ensemble import RandomForestRegressor\n\nmodel = RandomForestRegressor(max_depth=20, random_state=0)\nmodel.fit(X_train, y_train)","metadata":{"execution":{"iopub.status.busy":"2022-12-04T13:36:18.572917Z","iopub.execute_input":"2022-12-04T13:36:18.573273Z","iopub.status.idle":"2022-12-04T13:37:07.327613Z","shell.execute_reply.started":"2022-12-04T13:36:18.573245Z","shell.execute_reply":"2022-12-04T13:37:07.326767Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred = model.predict(X_valid)","metadata":{"execution":{"iopub.status.busy":"2022-12-04T13:37:07.329998Z","iopub.execute_input":"2022-12-04T13:37:07.330391Z","iopub.status.idle":"2022-12-04T13:37:07.371169Z","shell.execute_reply.started":"2022-12-04T13:37:07.330365Z","shell.execute_reply":"2022-12-04T13:37:07.369574Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import mean_squared_error\n\nmse = mean_squared_error(y_valid, y_pred)\nfig = plt.figure()\nmulreg = fig.add_subplot(1, 1, 1)\nmulreg.scatter(y_valid, y_pred, color='r')\nmulreg.set_title('Nonlinear Regression')","metadata":{"execution":{"iopub.status.busy":"2022-12-04T13:37:07.372916Z","iopub.execute_input":"2022-12-04T13:37:07.373272Z","iopub.status.idle":"2022-12-04T13:37:07.550209Z","shell.execute_reply.started":"2022-12-04T13:37:07.373248Z","shell.execute_reply":"2022-12-04T13:37:07.548182Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"prediction = model.predict(test_set.drop(columns=['segment_id']))","metadata":{"execution":{"iopub.status.busy":"2022-12-04T13:37:07.551631Z","iopub.execute_input":"2022-12-04T13:37:07.551910Z","iopub.status.idle":"2022-12-04T13:37:07.652677Z","shell.execute_reply.started":"2022-12-04T13:37:07.551887Z","shell.execute_reply":"2022-12-04T13:37:07.651538Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission = pd.DataFrame()  \nsubmission['segment_id'] = test_set['segment_id']\nsubmission['time_to_eruption'] = prediction\nsubmission.to_csv('submission.csv', header=True, index=False)","metadata":{"execution":{"iopub.status.busy":"2022-12-04T13:37:07.655067Z","iopub.execute_input":"2022-12-04T13:37:07.655882Z","iopub.status.idle":"2022-12-04T13:37:07.677902Z","shell.execute_reply.started":"2022-12-04T13:37:07.655826Z","shell.execute_reply":"2022-12-04T13:37:07.676860Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"keys = list(pd.read_csv(file_list_test[0]).keys()) \nprint(keys)\nnanC = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\nfor index in range(len(file_list_test)):\n    df = pd.read_csv(file_list_test[index]) \n    for key in df.keys():\n        if df[key].isna().sum() == len(pd.read_csv(file_list_train[0])):      \n            nanC[keys.index(key)] += 1\n\nprint(nanC)\ndata={'sensors': keys, 'count': nanC}\nNaNDF = pd.DataFrame(data)\nprint(NaNDF)","metadata":{"execution":{"iopub.status.busy":"2022-12-04T13:37:07.678738Z","iopub.execute_input":"2022-12-04T13:37:07.678975Z","iopub.status.idle":"2022-12-04T14:18:05.875248Z","shell.execute_reply.started":"2022-12-04T13:37:07.678953Z","shell.execute_reply":"2022-12-04T14:18:05.873384Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"NaNDF.plot(figsize =(20, 20), x=\"sensors\", y=\"count\", kind=\"bar\",  rot=5, fontsize=14 )","metadata":{"execution":{"iopub.status.busy":"2022-12-04T14:18:05.876830Z","iopub.execute_input":"2022-12-04T14:18:05.877127Z","iopub.status.idle":"2022-12-04T14:18:06.148875Z","shell.execute_reply.started":"2022-12-04T14:18:05.877103Z","shell.execute_reply":"2022-12-04T14:18:06.148235Z"},"trusted":true},"execution_count":null,"outputs":[]}]}