diff --git a/SET_Assignment_2.ipynb b/SET_Assignment_2.ipynb new file mode 100644 index 0000000..648bff9 --- /dev/null +++ b/SET_Assignment_2.ipynb @@ -0,0 +1,1212 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "name": "SET Assignment 2.ipynb", + "provenance": [], + "collapsed_sections": [] + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "7It97T8mWXLq", + "outputId": "83a2c656-a98e-40ee-c018-3766661246e3" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount(\"/content/drive\", force_remount=True).\n" + ] + } + ], + "source": [ + "from google.colab import drive\n", + "drive.mount('/content/drive')" + ] + }, + { + "cell_type": "code", + "source": [ + "# Importing the libraries\n", + "import pandas as pd\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import seaborn as sns\n", + "from sklearn.model_selection import train_test_split\n", + "from sklearn.linear_model import LinearRegression\n", + "from sklearn.metrics import mean_squared_error\n" + ], + "metadata": { + "id": "nvhGgRm1YAcd" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#Reading the dataset\n", + "data=pd.read_csv('/content/drive/MyDrive/SET-Dataset/energydata_complete.csv')" + ], + "metadata": { + "id": "MwmmYnhmYVhT" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "data.head()" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 444 + }, + "id": "ug_Uiu7VY15J", + "outputId": "219cd724-c60a-4bd4-b80f-3fbe78693d88" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/html": [ + "\n", + "
\n", + "
\n", + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
dateApplianceslightsT1RH_1T2RH_2T3RH_3T4RH_4T5RH_5T6RH_6T7RH_7T8RH_8T9RH_9T_outPress_mm_hgRH_outWindspeedVisibilityTdewpointrv1rv2
02016-01-11 17:00:00603019.8947.59666719.244.79000019.7944.73000019.00000045.56666717.16666755.207.02666784.25666717.20000041.62666718.248.90000017.03333345.536.600000733.592.07.00000063.0000005.313.27543313.275433
12016-01-11 17:10:00603019.8946.69333319.244.72250019.7944.79000019.00000045.99250017.16666755.206.83333384.06333317.20000041.56000018.248.86333317.06666745.566.483333733.692.06.66666759.1666675.218.60619518.606195
22016-01-11 17:20:00503019.8946.30000019.244.62666719.7944.93333318.92666745.89000017.16666755.096.56000083.15666717.20000041.43333318.248.73000017.00000045.506.366667733.792.06.33333355.3333335.128.64266828.642668
32016-01-11 17:30:00504019.8946.06666719.244.59000019.7945.00000018.89000045.72333317.16666755.096.43333383.42333317.13333341.29000018.148.59000017.00000045.406.250000733.892.06.00000051.5000005.045.41038945.410389
42016-01-11 17:40:00604019.8946.33333319.244.53000019.7945.00000018.89000045.53000017.20000055.096.36666784.89333317.20000041.23000018.148.59000017.00000045.406.133333733.992.05.66666747.6666674.910.08409710.084097
\n", + "
\n", + " \n", + " \n", + " \n", + "\n", + " \n", + "
\n", + "
\n", + " " + ], + "text/plain": [ + " date Appliances lights ... Tdewpoint rv1 rv2\n", + "0 2016-01-11 17:00:00 60 30 ... 5.3 13.275433 13.275433\n", + "1 2016-01-11 17:10:00 60 30 ... 5.2 18.606195 18.606195\n", + "2 2016-01-11 17:20:00 50 30 ... 5.1 28.642668 28.642668\n", + "3 2016-01-11 17:30:00 50 40 ... 5.0 45.410389 45.410389\n", + "4 2016-01-11 17:40:00 60 40 ... 4.9 10.084097 10.084097\n", + "\n", + "[5 rows x 29 columns]" + ] + }, + "metadata": {}, + "execution_count": 24 + } + ] + }, + { + "cell_type": "code", + "source": [ + "#Describing the shape of the dataset i.e. (Number of rows, Number of Columns)\n", + "data.shape" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "rQOptAzmkYTB", + "outputId": "4e6773c1-9476-4d44-a898-0ea0b78d9fc1" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "(19735, 29)" + ] + }, + "metadata": {}, + "execution_count": 40 + } + ] + }, + { + "cell_type": "code", + "source": [ + "#Complete view of dataset\n", + "data" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 835 + }, + "id": "WMlV-srPezrj", + "outputId": "260dd108-ab33-4a24-a4ee-20731b55b2ab" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/html": [ + "\n", + "
\n", + "
\n", + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
dateApplianceslightsT1RH_1T2RH_2T3RH_3T4RH_4T5RH_5T6RH_6T7RH_7T8RH_8T9RH_9T_outPress_mm_hgRH_outWindspeedVisibilityTdewpointrv1rv2
02016-01-11 17:00:00603019.89000047.59666719.20000044.79000019.79000044.73000019.00000045.56666717.16666755.2000007.02666784.25666717.20000041.62666718.200048.90000017.03333345.53006.600000733.592.0000007.00000063.0000005.30000013.27543313.275433
12016-01-11 17:10:00603019.89000046.69333319.20000044.72250019.79000044.79000019.00000045.99250017.16666755.2000006.83333384.06333317.20000041.56000018.200048.86333317.06666745.56006.483333733.692.0000006.66666759.1666675.20000018.60619518.606195
22016-01-11 17:20:00503019.89000046.30000019.20000044.62666719.79000044.93333318.92666745.89000017.16666755.0900006.56000083.15666717.20000041.43333318.200048.73000017.00000045.50006.366667733.792.0000006.33333355.3333335.10000028.64266828.642668
32016-01-11 17:30:00504019.89000046.06666719.20000044.59000019.79000045.00000018.89000045.72333317.16666755.0900006.43333383.42333317.13333341.29000018.100048.59000017.00000045.40006.250000733.892.0000006.00000051.5000005.00000045.41038945.410389
42016-01-11 17:40:00604019.89000046.33333319.20000044.53000019.79000045.00000018.89000045.53000017.20000055.0900006.36666784.89333317.20000041.23000018.100048.59000017.00000045.40006.133333733.992.0000005.66666747.6666674.90000010.08409710.084097
..........................................................................................
197302016-05-27 17:20:00100025.56666746.56000025.89000042.02571427.20000041.16333324.70000045.59000023.20000052.40000024.7966671.00000024.50000044.50000024.700050.07400023.20000046.790022.733333755.255.6666673.33333323.66666713.33333343.09681243.096812
197312016-05-27 17:30:0090025.50000046.50000025.75400042.08000027.13333341.22333324.70000045.59000023.23000052.32666724.1966671.00000024.55714344.41428624.700049.79000023.20000046.790022.600000755.256.0000003.50000024.50000013.30000049.28294049.282940
197322016-05-27 17:40:002701025.50000046.59666725.62857142.76857127.05000041.69000024.70000045.73000023.23000052.26666723.6266671.00000024.54000044.40000024.700049.66000023.20000046.790022.466667755.256.3333333.66666725.33333313.26666729.19911729.199117
197332016-05-27 17:50:004201025.50000046.99000025.41400043.03600026.89000041.29000024.70000045.79000023.20000052.20000022.4333331.00000024.50000044.29571424.662549.51875023.20000046.817522.333333755.256.6666673.83333326.16666713.2333336.3227846.322784
197342016-05-27 18:00:004301025.50000046.60000025.26428642.97142926.82333341.15666724.70000045.96333323.20000052.20000021.0266671.00000024.50000044.05400024.736049.73600023.20000046.845022.200000755.257.0000004.00000027.00000013.20000034.11885134.118851
\n", + "

19735 rows × 29 columns

\n", + "
\n", + " \n", + " \n", + " \n", + "\n", + " \n", + "
\n", + "
\n", + " " + ], + "text/plain": [ + " date Appliances lights ... Tdewpoint rv1 rv2\n", + "0 2016-01-11 17:00:00 60 30 ... 5.300000 13.275433 13.275433\n", + "1 2016-01-11 17:10:00 60 30 ... 5.200000 18.606195 18.606195\n", + "2 2016-01-11 17:20:00 50 30 ... 5.100000 28.642668 28.642668\n", + "3 2016-01-11 17:30:00 50 40 ... 5.000000 45.410389 45.410389\n", + "4 2016-01-11 17:40:00 60 40 ... 4.900000 10.084097 10.084097\n", + "... ... ... ... ... ... ... ...\n", + "19730 2016-05-27 17:20:00 100 0 ... 13.333333 43.096812 43.096812\n", + "19731 2016-05-27 17:30:00 90 0 ... 13.300000 49.282940 49.282940\n", + "19732 2016-05-27 17:40:00 270 10 ... 13.266667 29.199117 29.199117\n", + "19733 2016-05-27 17:50:00 420 10 ... 13.233333 6.322784 6.322784\n", + "19734 2016-05-27 18:00:00 430 10 ... 13.200000 34.118851 34.118851\n", + "\n", + "[19735 rows x 29 columns]" + ] + }, + "metadata": {}, + "execution_count": 41 + } + ] + }, + { + "cell_type": "code", + "source": [ + "# Drop columns \n", + "data=data.drop(['date', 'T7','RH_7', 'T8','RH_8', 'T9','RH_9', 'rv1', 'rv2'],axis=1)" + ], + "metadata": { + "id": "vgdvHRCpzt1L" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "data.shape" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "n_v67_e_0xg6", + "outputId": "098fa1a3-035e-4eaf-d18c-0f3c7fb1ac45" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "(19735, 20)" + ] + }, + "metadata": {}, + "execution_count": 43 + } + ] + }, + { + "cell_type": "code", + "source": [ + "data.columns" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "iyAhJGCG0_-m", + "outputId": "b014e771-d6bd-4b77-d4a3-ad0d53c7bd5f" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "Index(['Appliances', 'lights', 'T1', 'RH_1', 'T2', 'RH_2', 'T3', 'RH_3', 'T4',\n", + " 'RH_4', 'T5', 'RH_5', 'T6', 'RH_6', 'T_out', 'Press_mm_hg', 'RH_out',\n", + " 'Windspeed', 'Visibility', 'Tdewpoint'],\n", + " dtype='object')" + ] + }, + "metadata": {}, + "execution_count": 44 + } + ] + }, + { + "cell_type": "code", + "source": [ + "x=data.drop(['Windspeed'], axis=1)\n", + "y=data['Windspeed']" + ], + "metadata": { + "id": "jyeOr6uB1fF1" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "print('splitting the data into train and test')\n", + "x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.3,random_state=0)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "_-slONShaKHL", + "outputId": "9524e63e-3f18-4c33-e385-8cb85466ad79" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "splitting the data into train and test\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "print(x_train.shape,y_train.shape)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "kbiKBLlD2HCt", + "outputId": "e4f9eb27-eedb-4436-9bd3-30c29bb2feb1" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "(13814, 19) (13814,)\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "print(x_test.shape,y_test.shape)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "ab6cpifa2Lrg", + "outputId": "164a583b-8409-4cd1-f781-2f634f44c4df" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "(5921, 19) (5921,)\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "# Fitting Linear Regression to the dataset\n", + "model=LinearRegression()\n", + "model.fit(x_train,y_train)" + ], + "metadata": { + "id": "044jT5fviqwf", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "62246e06-2424-49f0-b9e9-efc6468af6a8" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "LinearRegression()" + ] + }, + "metadata": {}, + "execution_count": 49 + } + ] + }, + { + "cell_type": "code", + "source": [ + "model.score(x_test,y_test)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "Kkj2mjK07959", + "outputId": "aae625f1-7c47-44cf-cb31-b0a60afddb5c" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "0.35241150486596606" + ] + }, + "metadata": {}, + "execution_count": 50 + } + ] + }, + { + "cell_type": "code", + "source": [ + "y_pred = model.predict(x_test)\n", + "print(\"Predicted values:\")\n", + "print(y_pred)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "9PYG7Klb8NlT", + "outputId": "0809ac8e-17ae-445d-9a0f-9c62117b78cb" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Predicted values:\n", + "[5.05228562 4.54819651 5.18688828 ... 2.69611319 3.04059327 3.77132473]\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "mean_squared_error(y_test,y_pred)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "rHCtAuVs8Usv", + "outputId": "b265e753-6f8d-4130-8d72-a0871efd1080" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "3.9100376882934595" + ] + }, + "metadata": {}, + "execution_count": 52 + } + ] + } + ] +} \ No newline at end of file diff --git a/Student assignment updates.txt b/Student assignment updates.txt index 9979d7c..bd293a5 100644 --- a/Student assignment updates.txt +++ b/Student assignment updates.txt @@ -1,2 +1,3 @@ -Write your name and PRN no +Omkar Patil +2019BTECS00104 Hello Updated