{"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 # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n\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\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":"2021-12-20T09:04:16.749016Z","iopub.execute_input":"2021-12-20T09:04:16.749325Z","iopub.status.idle":"2021-12-20T09:04:24.467128Z","shell.execute_reply.started":"2021-12-20T09:04:16.749294Z","shell.execute_reply":"2021-12-20T09:04:24.466221Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"code","source":"print(file_list[2])\n\n\nprint(pd.read_csv(file_list[0]))\nprint(pd.read_csv(file_list[2]).isna().sum())","metadata":{"execution":{"iopub.status.busy":"2021-12-20T09:04:24.468710Z","iopub.execute_input":"2021-12-20T09:04:24.468926Z","iopub.status.idle":"2021-12-20T09:04:24.611797Z","shell.execute_reply.started":"2021-12-20T09:04:24.468901Z","shell.execute_reply":"2021-12-20T09:04:24.610841Z"},"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":"2021-12-20T09:04:24.613201Z","iopub.execute_input":"2021-12-20T09:04:24.613501Z","iopub.status.idle":"2021-12-20T09:04:24.749122Z","shell.execute_reply.started":"2021-12-20T09:04:24.613462Z","shell.execute_reply":"2021-12-20T09:04:24.748112Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"60001 данных - значений сенсоров","metadata":{}},{"cell_type":"code","source":"print(len(file_list_train))","metadata":{"execution":{"iopub.status.busy":"2021-12-20T09:04:24.750615Z","iopub.execute_input":"2021-12-20T09:04:24.751133Z","iopub.status.idle":"2021-12-20T09:04:24.757974Z","shell.execute_reply.started":"2021-12-20T09:04:24.751090Z","shell.execute_reply":"2021-12-20T09:04:24.756582Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(len(file_list_test))","metadata":{"execution":{"iopub.status.busy":"2021-12-20T09:04:24.761508Z","iopub.execute_input":"2021-12-20T09:04:24.762538Z","iopub.status.idle":"2021-12-20T09:04:24.768084Z","shell.execute_reply.started":"2021-12-20T09:04:24.762490Z","shell.execute_reply":"2021-12-20T09:04:24.767486Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"files_test = [file.split('/')[-1].split('.')[-2] for file in file_list_test]\nfiles_train = [file.split('/')[-1].split('.')[-2] for file in file_list_train]","metadata":{"execution":{"iopub.status.busy":"2021-12-20T09:04:24.768938Z","iopub.execute_input":"2021-12-20T09:04:24.769506Z","iopub.status.idle":"2021-12-20T09:04:24.787776Z","shell.execute_reply.started":"2021-12-20T09:04:24.769478Z","shell.execute_reply":"2021-12-20T09:04:24.787113Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(files_train[0:10])\nprint(files_test[0:10])","metadata":{"execution":{"iopub.status.busy":"2021-12-20T09:04:24.788911Z","iopub.execute_input":"2021-12-20T09:04:24.789405Z","iopub.status.idle":"2021-12-20T09:04:24.803875Z","shell.execute_reply.started":"2021-12-20T09:04:24.789372Z","shell.execute_reply":"2021-12-20T09:04:24.802916Z"},"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":"2021-12-20T09:04:24.805629Z","iopub.execute_input":"2021-12-20T09:04:24.806898Z","iopub.status.idle":"2021-12-20T09:04:24.819325Z","shell.execute_reply.started":"2021-12-20T09:04:24.806854Z","shell.execute_reply":"2021-12-20T09:04:24.818251Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = pd.read_csv(PATH+'train.csv')","metadata":{"execution":{"iopub.status.busy":"2021-12-20T09:04:24.820668Z","iopub.execute_input":"2021-12-20T09:04:24.821509Z","iopub.status.idle":"2021-12-20T09:04:24.839629Z","shell.execute_reply.started":"2021-12-20T09:04:24.821471Z","shell.execute_reply":"2021-12-20T09:04:24.838930Z"},"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":"2021-12-20T09:04:24.840744Z","iopub.execute_input":"2021-12-20T09:04:24.840966Z","iopub.status.idle":"2021-12-20T09:04:25.445607Z","shell.execute_reply.started":"2021-12-20T09:04:24.840939Z","shell.execute_reply":"2021-12-20T09:04:25.444958Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train['time_to_eruption'].describe()","metadata":{"execution":{"iopub.status.busy":"2021-12-20T09:04:25.446647Z","iopub.execute_input":"2021-12-20T09:04:25.447549Z","iopub.status.idle":"2021-12-20T09:04:25.458964Z","shell.execute_reply.started":"2021-12-20T09:04:25.447490Z","shell.execute_reply":"2021-12-20T09:04:25.458165Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_segment_id = pd.read_csv(PATH+'test/473253715.csv')\n\ndf_segment_id.plot(figsize=(20,20),\n                  subplots=True,\n                  layout=(10,1),\n                  rot=0,\n                  lw=1,\n                  title='sergemnt id #473253715')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-12-20T09:04:25.460097Z","iopub.execute_input":"2021-12-20T09:04:25.460308Z","iopub.status.idle":"2021-12-20T09:04:28.209425Z","shell.execute_reply.started":"2021-12-20T09:04:25.460283Z","shell.execute_reply":"2021-12-20T09:04:28.208342Z"},"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')\n\ndf_segment_id_max = pd.read_csv(PATH+'train/'+str(segment_id_max)+'.csv')","metadata":{"execution":{"iopub.status.busy":"2021-12-20T09:04:28.210730Z","iopub.execute_input":"2021-12-20T09:04:28.211005Z","iopub.status.idle":"2021-12-20T09:04:28.446639Z","shell.execute_reply.started":"2021-12-20T09:04:28.210970Z","shell.execute_reply":"2021-12-20T09:04:28.445604Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_segment_id_min.plot(figsize=(20,20),\n                  subplots=True,\n                  layout=(10,1),\n                  rot=0,\n                  lw=1,\n                  title='sergemnt id min')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-12-20T09:04:28.449480Z","iopub.execute_input":"2021-12-20T09:04:28.449743Z","iopub.status.idle":"2021-12-20T09:04:30.841983Z","shell.execute_reply.started":"2021-12-20T09:04:28.449707Z","shell.execute_reply":"2021-12-20T09:04:30.841104Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_segment_id_max.plot(figsize=(20,20),\n                  subplots=True,\n                  layout=(10,1),\n                  rot=0,\n                  lw=1,\n                  title='sergemnt id max')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-12-20T09:04:30.843712Z","iopub.execute_input":"2021-12-20T09:04:30.844280Z","iopub.status.idle":"2021-12-20T09:04:33.627501Z","shell.execute_reply.started":"2021-12-20T09:04:30.844224Z","shell.execute_reply":"2021-12-20T09:04:33.626613Z"},"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\n#подготовка всевозможных данных к обучению","metadata":{"execution":{"iopub.status.busy":"2021-12-20T09:04:33.629097Z","iopub.execute_input":"2021-12-20T09:04:33.629581Z","iopub.status.idle":"2021-12-20T09:04:33.647759Z","shell.execute_reply.started":"2021-12-20T09:04:33.629543Z","shell.execute_reply":"2021-12-20T09:04:33.646470Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"res = pd.read_csv(file_list_test[0])\nlen(res.columns)","metadata":{"execution":{"iopub.status.busy":"2021-12-20T09:04:33.649462Z","iopub.execute_input":"2021-12-20T09:04:33.649988Z","iopub.status.idle":"2021-12-20T09:04:33.735320Z","shell.execute_reply.started":"2021-12-20T09:04:33.649945Z","shell.execute_reply":"2021-12-20T09:04:33.734318Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sensors = dict()\nfor i in res.columns:\n    sensors[f\"{i.replace('sensor_', '')}\"] =  0","metadata":{"execution":{"iopub.status.busy":"2021-12-20T09:04:33.737975Z","iopub.execute_input":"2021-12-20T09:04:33.739844Z","iopub.status.idle":"2021-12-20T09:04:33.747368Z","shell.execute_reply.started":"2021-12-20T09:04:33.739732Z","shell.execute_reply":"2021-12-20T09:04:33.745905Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for i in file_list_test:\n    tmp = pd.read_csv(i)\n    for j in sensors.keys():\n        if tmp[f\"{'sensor_'+j}\"].max() > 0:\n            sensors[f\"{j}\"] += 1 \n\nplt.figure(figsize=(20,5))\nplt.bar(sensors.keys(), sensors.values())","metadata":{"execution":{"iopub.status.busy":"2021-12-20T09:04:33.749484Z","iopub.execute_input":"2021-12-20T09:04:33.750226Z","iopub.status.idle":"2021-12-20T09:11:52.669174Z","shell.execute_reply.started":"2021-12-20T09:04:33.750175Z","shell.execute_reply":"2021-12-20T09:11:52.668003Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\ntrain_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)\n#генерация датафреймов для тестовых данных и тренировочных","metadata":{"execution":{"iopub.status.busy":"2021-12-20T09:11:52.671294Z","iopub.execute_input":"2021-12-20T09:11:52.672457Z","iopub.status.idle":"2021-12-20T09:50:59.894470Z","shell.execute_reply.started":"2021-12-20T09:11:52.672407Z","shell.execute_reply":"2021-12-20T09:50:59.893548Z"},"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":"2021-12-20T09:50:59.896596Z","iopub.execute_input":"2021-12-20T09:50:59.896879Z","iopub.status.idle":"2021-12-20T09:51:00.004591Z","shell.execute_reply.started":"2021-12-20T09:50:59.896847Z","shell.execute_reply":"2021-12-20T09:51:00.003551Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(train_set.head(3))","metadata":{"execution":{"iopub.status.busy":"2021-12-20T09:51:00.005998Z","iopub.execute_input":"2021-12-20T09:51:00.006273Z","iopub.status.idle":"2021-12-20T09:51:00.128518Z","shell.execute_reply.started":"2021-12-20T09:51:00.006240Z","shell.execute_reply":"2021-12-20T09:51:00.127315Z"},"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":"2021-12-20T09:51:00.130130Z","iopub.execute_input":"2021-12-20T09:51:00.130584Z","iopub.status.idle":"2021-12-20T09:51:01.258370Z","shell.execute_reply.started":"2021-12-20T09:51:00.130540Z","shell.execute_reply":"2021-12-20T09:51:01.257415Z"},"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":"2021-12-20T09:51:01.259599Z","iopub.execute_input":"2021-12-20T09:51:01.260058Z","iopub.status.idle":"2021-12-20T10:28:58.192560Z","shell.execute_reply.started":"2021-12-20T09:51:01.260012Z","shell.execute_reply":"2021-12-20T10:28:58.191499Z"},"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":"2021-12-20T10:28:58.194684Z","iopub.execute_input":"2021-12-20T10:28:58.195015Z","iopub.status.idle":"2021-12-20T10:28:58.246924Z","shell.execute_reply.started":"2021-12-20T10:28:58.194973Z","shell.execute_reply":"2021-12-20T10:28:58.245495Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(test_set.head(3))","metadata":{"execution":{"iopub.status.busy":"2021-12-20T10:28:58.248523Z","iopub.execute_input":"2021-12-20T10:28:58.248805Z","iopub.status.idle":"2021-12-20T10:28:58.267015Z","shell.execute_reply.started":"2021-12-20T10:28:58.248776Z","shell.execute_reply":"2021-12-20T10:28:58.266179Z"},"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":"2021-12-20T10:28:58.268266Z","iopub.execute_input":"2021-12-20T10:28:58.269147Z","iopub.status.idle":"2021-12-20T10:28:58.319818Z","shell.execute_reply.started":"2021-12-20T10:28:58.269097Z","shell.execute_reply":"2021-12-20T10:28:58.318999Z"},"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":"2021-12-20T10:28:58.322137Z","iopub.execute_input":"2021-12-20T10:28:58.323438Z","iopub.status.idle":"2021-12-20T10:28:58.343559Z","shell.execute_reply.started":"2021-12-20T10:28:58.323384Z","shell.execute_reply":"2021-12-20T10:28:58.342462Z"},"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":"2021-12-20T10:28:58.344684Z","iopub.execute_input":"2021-12-20T10:28:58.345118Z","iopub.status.idle":"2021-12-20T10:28:58.353804Z","shell.execute_reply.started":"2021-12-20T10:28:58.345078Z","shell.execute_reply":"2021-12-20T10:28:58.353164Z"},"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":"2021-12-20T10:28:58.355021Z","iopub.execute_input":"2021-12-20T10:28:58.355392Z","iopub.status.idle":"2021-12-20T10:29:52.061627Z","shell.execute_reply.started":"2021-12-20T10:28:58.355364Z","shell.execute_reply":"2021-12-20T10:29:52.060501Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred = model.predict(X_valid)","metadata":{"execution":{"iopub.status.busy":"2021-12-20T10:29:52.063329Z","iopub.execute_input":"2021-12-20T10:29:52.063657Z","iopub.status.idle":"2021-12-20T10:29:52.110833Z","shell.execute_reply.started":"2021-12-20T10:29:52.063615Z","shell.execute_reply":"2021-12-20T10:29:52.109661Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import r2_score #Проводим оценку точности модели. Результат показал, что регрессия не есть линейной\n\nconf_mat = r2_score(y_valid, y_pred)\nprint(conf_mat)","metadata":{"execution":{"iopub.status.busy":"2021-12-20T10:29:52.112212Z","iopub.execute_input":"2021-12-20T10:29:52.112434Z","iopub.status.idle":"2021-12-20T10:29:52.119216Z","shell.execute_reply.started":"2021-12-20T10:29:52.112409Z","shell.execute_reply":"2021-12-20T10:29:52.118513Z"},"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":"2021-12-20T10:29:52.120322Z","iopub.execute_input":"2021-12-20T10:29:52.120690Z","iopub.status.idle":"2021-12-20T10:29:52.395963Z","shell.execute_reply.started":"2021-12-20T10:29:52.120645Z","shell.execute_reply":"2021-12-20T10:29:52.395042Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Оценка точности модели","metadata":{}},{"cell_type":"markdown","source":"график рассеивания","metadata":{}},{"cell_type":"code","source":"prediction = model.predict(test_set.drop(columns=['segment_id']))","metadata":{"execution":{"iopub.status.busy":"2021-12-20T10:29:52.397434Z","iopub.execute_input":"2021-12-20T10:29:52.397684Z","iopub.status.idle":"2021-12-20T10:29:52.544330Z","shell.execute_reply.started":"2021-12-20T10:29:52.397654Z","shell.execute_reply":"2021-12-20T10:29:52.543020Z"},"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":"2021-12-20T10:29:52.545774Z","iopub.execute_input":"2021-12-20T10:29:52.546024Z","iopub.status.idle":"2021-12-20T10:29:52.575695Z","shell.execute_reply.started":"2021-12-20T10:29:52.545995Z","shell.execute_reply":"2021-12-20T10:29:52.574709Z"},"trusted":true},"execution_count":null,"outputs":[]}]}