{"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-06-07T06:37:39.500020Z","iopub.execute_input":"2022-06-07T06:37:39.500432Z","iopub.status.idle":"2022-06-07T06:37:39.507144Z","shell.execute_reply.started":"2022-06-07T06:37:39.500399Z","shell.execute_reply":"2022-06-07T06:37:39.506320Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data = pd.read_csv('/kaggle/input/challenge-datascience-wind-turbine-cs/training_set.csv')","metadata":{"execution":{"iopub.status.busy":"2022-06-07T06:37:39.510298Z","iopub.execute_input":"2022-06-07T06:37:39.510638Z","iopub.status.idle":"2022-06-07T06:37:48.705414Z","shell.execute_reply.started":"2022-06-07T06:37:39.510608Z","shell.execute_reply":"2022-06-07T06:37:48.704541Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.isna().sum().sort_values(ascending=False).head(20)","metadata":{"execution":{"iopub.status.busy":"2022-06-07T06:37:48.706933Z","iopub.execute_input":"2022-06-07T06:37:48.707233Z","iopub.status.idle":"2022-06-07T06:37:48.806613Z","shell.execute_reply.started":"2022-06-07T06:37:48.707208Z","shell.execute_reply":"2022-06-07T06:37:48.805591Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data = data.fillna(data.mean())","metadata":{"execution":{"iopub.status.busy":"2022-06-07T06:37:48.807663Z","iopub.execute_input":"2022-06-07T06:37:48.807984Z","iopub.status.idle":"2022-06-07T06:38:05.342722Z","shell.execute_reply.started":"2022-06-07T06:37:48.807958Z","shell.execute_reply":"2022-06-07T06:38:05.341572Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.isna().sum().sort_values(ascending=False).head(20)","metadata":{"execution":{"iopub.status.busy":"2022-06-07T06:38:05.344102Z","iopub.execute_input":"2022-06-07T06:38:05.344546Z","iopub.status.idle":"2022-06-07T06:38:05.437817Z","shell.execute_reply.started":"2022-06-07T06:38:05.344504Z","shell.execute_reply":"2022-06-07T06:38:05.436781Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split\n\ny = data['TARGET']\nX = data[['Generator_converter_speed', 'Rotor_speed']]\n\nX_train, X_test, y_train, y_test = train_test_split(X, y, \n                                                    test_size=0.20, \n                                                    random_state=42)","metadata":{"execution":{"iopub.status.busy":"2022-06-07T06:38:05.439568Z","iopub.execute_input":"2022-06-07T06:38:05.439935Z","iopub.status.idle":"2022-06-07T06:38:06.030582Z","shell.execute_reply.started":"2022-06-07T06:38:05.439905Z","shell.execute_reply":"2022-06-07T06:38:06.029597Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.linear_model import LinearRegression\n\nreg = LinearRegression()\n\nreg.fit(X_train, y_train)","metadata":{"execution":{"iopub.status.busy":"2022-06-07T06:38:06.031970Z","iopub.execute_input":"2022-06-07T06:38:06.032507Z","iopub.status.idle":"2022-06-07T06:38:06.152026Z","shell.execute_reply.started":"2022-06-07T06:38:06.032451Z","shell.execute_reply":"2022-06-07T06:38:06.151080Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import mean_absolute_error\n\ny_pred = reg.predict(X_test)\nmean_absolute_error(y_test, y_pred)","metadata":{"execution":{"iopub.status.busy":"2022-06-07T06:38:06.153349Z","iopub.execute_input":"2022-06-07T06:38:06.153887Z","iopub.status.idle":"2022-06-07T06:38:06.171141Z","shell.execute_reply.started":"2022-06-07T06:38:06.153845Z","shell.execute_reply":"2022-06-07T06:38:06.169885Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test = pd.read_csv('/kaggle/input/challenge-datascience-wind-turbine-cs/test_set.csv')","metadata":{"execution":{"iopub.status.busy":"2022-06-07T06:52:35.152653Z","iopub.execute_input":"2022-06-07T06:52:35.153057Z","iopub.status.idle":"2022-06-07T06:52:37.063612Z","shell.execute_reply.started":"2022-06-07T06:52:35.153027Z","shell.execute_reply":"2022-06-07T06:52:37.062688Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ids = test['ID']","metadata":{"execution":{"iopub.status.busy":"2022-06-07T06:53:03.619320Z","iopub.execute_input":"2022-06-07T06:53:03.620360Z","iopub.status.idle":"2022-06-07T06:53:03.624338Z","shell.execute_reply.started":"2022-06-07T06:53:03.620312Z","shell.execute_reply":"2022-06-07T06:53:03.623579Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test = test.fillna(data.mean())","metadata":{"execution":{"iopub.status.busy":"2022-06-07T06:53:05.762933Z","iopub.execute_input":"2022-06-07T06:53:05.763295Z","iopub.status.idle":"2022-06-07T06:53:24.098688Z","shell.execute_reply.started":"2022-06-07T06:53:05.763266Z","shell.execute_reply":"2022-06-07T06:53:24.096912Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test = test[['Generator_converter_speed', 'Rotor_speed']]","metadata":{"execution":{"iopub.status.busy":"2022-06-07T06:53:24.100083Z","iopub.execute_input":"2022-06-07T06:53:24.100464Z","iopub.status.idle":"2022-06-07T06:53:24.107348Z","shell.execute_reply.started":"2022-06-07T06:53:24.100434Z","shell.execute_reply":"2022-06-07T06:53:24.106511Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred_test = reg.predict(test)","metadata":{"execution":{"iopub.status.busy":"2022-06-07T06:53:24.108536Z","iopub.execute_input":"2022-06-07T06:53:24.109053Z","iopub.status.idle":"2022-06-07T06:53:24.127284Z","shell.execute_reply.started":"2022-06-07T06:53:24.109003Z","shell.execute_reply":"2022-06-07T06:53:24.126094Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"result = pd.DataFrame()\nresult['ID'] = ids\nresult['TARGET'] = y_pred_test\n\nresult.to_csv('v1.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2022-06-07T06:55:12.923296Z","iopub.execute_input":"2022-06-07T06:55:12.923664Z","iopub.status.idle":"2022-06-07T06:55:13.357382Z","shell.execute_reply.started":"2022-06-07T06:55:12.923636Z","shell.execute_reply":"2022-06-07T06:55:13.356484Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}