{"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","execution":{"iopub.status.busy":"2022-10-10T14:26:57.432925Z","iopub.execute_input":"2022-10-10T14:26:57.433411Z","iopub.status.idle":"2022-10-10T14:26:57.474193Z","shell.execute_reply.started":"2022-10-10T14:26:57.433302Z","shell.execute_reply":"2022-10-10T14:26:57.472838Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"from  sklearn.linear_model import LinearRegression","metadata":{}},{"cell_type":"code","source":"from sklearn.linear_model import LinearRegression","metadata":{"execution":{"iopub.status.busy":"2022-10-10T14:28:22.362671Z","iopub.execute_input":"2022-10-10T14:28:22.363190Z","iopub.status.idle":"2022-10-10T14:28:23.042660Z","shell.execute_reply.started":"2022-10-10T14:28:22.363151Z","shell.execute_reply":"2022-10-10T14:28:23.041342Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_dt = pd.read_csv(\"/kaggle/input/departure-delay3/data/x_test.csv\")\ntrain_dt = pd.read_csv(\"/kaggle/input/departure-delay3/data/x_train.csv\")\ntarget = pd.read_csv(\"/kaggle/input/departure-delay3/data/y_train.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-10-10T14:30:05.081585Z","iopub.execute_input":"2022-10-10T14:30:05.082134Z","iopub.status.idle":"2022-10-10T14:30:13.981884Z","shell.execute_reply.started":"2022-10-10T14:30:05.082086Z","shell.execute_reply":"2022-10-10T14:30:13.980809Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"target = target.drop(['id'], axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-10-10T14:37:59.593618Z","iopub.execute_input":"2022-10-10T14:37:59.594048Z","iopub.status.idle":"2022-10-10T14:37:59.607215Z","shell.execute_reply.started":"2022-10-10T14:37:59.594012Z","shell.execute_reply":"2022-10-10T14:37:59.605842Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"target","metadata":{"execution":{"iopub.status.busy":"2022-10-10T14:38:08.406597Z","iopub.execute_input":"2022-10-10T14:38:08.407084Z","iopub.status.idle":"2022-10-10T14:38:08.420521Z","shell.execute_reply.started":"2022-10-10T14:38:08.407046Z","shell.execute_reply":"2022-10-10T14:38:08.419410Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_dt.info()","metadata":{"execution":{"iopub.status.busy":"2022-10-10T14:30:54.006778Z","iopub.execute_input":"2022-10-10T14:30:54.007633Z","iopub.status.idle":"2022-10-10T14:30:54.184366Z","shell.execute_reply.started":"2022-10-10T14:30:54.007575Z","shell.execute_reply":"2022-10-10T14:30:54.183000Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_dt = train_dt.drop(['UniqueCarrier', 'TailNum', 'Origin', 'Dest', 'CancellationCode'], axis=1)\ntest_dt = test_dt.drop(['UniqueCarrier', 'TailNum', 'Origin', 'Dest', 'CancellationCode'], axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-10-10T14:34:23.379747Z","iopub.execute_input":"2022-10-10T14:34:23.380165Z","iopub.status.idle":"2022-10-10T14:34:23.486642Z","shell.execute_reply.started":"2022-10-10T14:34:23.380131Z","shell.execute_reply":"2022-10-10T14:34:23.485535Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_dt.fillna(0, inplace=True)\ntrain_dt.fillna(0, inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-10-10T14:35:01.132536Z","iopub.execute_input":"2022-10-10T14:35:01.132987Z","iopub.status.idle":"2022-10-10T14:35:01.227221Z","shell.execute_reply.started":"2022-10-10T14:35:01.132952Z","shell.execute_reply":"2022-10-10T14:35:01.226158Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"lrg = LinearRegression().fit(train_dt, target)","metadata":{"execution":{"iopub.status.busy":"2022-10-10T14:38:18.558611Z","iopub.execute_input":"2022-10-10T14:38:18.559083Z","iopub.status.idle":"2022-10-10T14:38:19.755310Z","shell.execute_reply.started":"2022-10-10T14:38:18.559044Z","shell.execute_reply":"2022-10-10T14:38:19.753838Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predict = lrg.predict(test_dt)","metadata":{"execution":{"iopub.status.busy":"2022-10-10T14:38:20.468169Z","iopub.execute_input":"2022-10-10T14:38:20.469091Z","iopub.status.idle":"2022-10-10T14:38:20.534151Z","shell.execute_reply.started":"2022-10-10T14:38:20.469047Z","shell.execute_reply":"2022-10-10T14:38:20.532473Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predict","metadata":{"execution":{"iopub.status.busy":"2022-10-10T14:38:20.861985Z","iopub.execute_input":"2022-10-10T14:38:20.862432Z","iopub.status.idle":"2022-10-10T14:38:20.870406Z","shell.execute_reply.started":"2022-10-10T14:38:20.862371Z","shell.execute_reply":"2022-10-10T14:38:20.869187Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.Series(predict.flatten(), name='DelayTime').to_csv('submission.csv', index_label='id', header=True)","metadata":{"execution":{"iopub.status.busy":"2022-10-10T14:40:27.044984Z","iopub.execute_input":"2022-10-10T14:40:27.046087Z","iopub.status.idle":"2022-10-10T14:40:28.478099Z","shell.execute_reply.started":"2022-10-10T14:40:27.046032Z","shell.execute_reply":"2022-10-10T14:40:28.476897Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}