{"cells":[{"metadata":{"_uuid":"6843889150b2905c0689670025c2ef3a98c7c8d3","_execution_state":"idle","_cell_guid":"b95ecc35-f797-477b-9a70-1f3e83ba8027"},"cell_type":"markdown","source":""},{"metadata":{"_uuid":"59a9faa8133d47009a4300e5443da257e9c852e5","_cell_guid":"276a68e1-8348-47ce-adb2-efc7d0c1d6ff","_execution_state":"idle","trusted":false},"cell_type":"code","source":"#Importing Libraries\nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"0335fa0d5e4c183edf2af671de29c6106854fe21","_cell_guid":"2b70426c-b341-425a-97cd-ece2850e3378","_execution_state":"idle","trusted":false},"cell_type":"code","source":"#Importing dataset\ntrain = pd.read_csv('../input/train_1.csv').fillna(0)\npage = train['Page']\ntrain.head()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"a8ece73768260b61dffa1d2de3459c3b04b6c419","_cell_guid":"15ef8cd8-ce99-4536-9023-02b1579c77ec","_execution_state":"idle","trusted":false},"cell_type":"code","source":"#Dropping Page Column\ntrain = train.drop('Page',axis = 1)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"526f5d28d294819c5b45c5d1f0fdbbdef37e67c8","_cell_guid":"3e1f9ade-80af-4c88-88b0-152b071f34f5","_execution_state":"idle","trusted":false},"cell_type":"code","source":"#Using Data From Random Row for Training and Testing\n\nrow = train.iloc[90000,:].values\nX = row[0:549]\ny = row[1:550]\n\n# Splitting the dataset into the Training set and Test set\nfrom sklearn.model_selection import train_test_split\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.3, random_state = 0)\n\n\n\n# Feature Scaling\nfrom sklearn.preprocessing import MinMaxScaler\nsc = MinMaxScaler()\nX_train = np.reshape(X_train,(-1,1))\ny_train = np.reshape(y_train,(-1,1))\nX_train = sc.fit_transform(X_train)\ny_train = sc.fit_transform(y_train)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"f0ad994ddf4545ef7bb2b662602be778247bd5f4","_cell_guid":"d124267e-ca91-4561-949d-8dc7938ac59c","_execution_state":"idle","trusted":false},"cell_type":"code","source":"#Training LSTM\n\n#Reshaping Array\nX_train = np.reshape(X_train, (384,1,1))\n\n\n# Importing the Keras libraries and packages for LSTM\nfrom keras.models import Sequential\nfrom keras.layers import Dense\nfrom keras.layers import LSTM\n\n# Initialising the RNN\nregressor = Sequential()\n\n# Adding the input layerand the LSTM layer\nregressor.add(LSTM(units = 8, activation = 'relu', input_shape = (None, 1)))\n\n\n# Adding the output layer\nregressor.add(Dense(units = 1))\n\n# Compiling the RNN\nregressor.compile(optimizer = 'adam', loss = 'mean_squared_error')\n\n# Fitting the RNN to the Training set\nregressor.fit(X_train, y_train, batch_size = 10, epochs = 100, verbose = 0)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"99dce760e0faa81ea14c89746bfbd1561daea50b","_cell_guid":"b7ab4532-d0fd-430f-bca5-9eeca1b286cc","_execution_state":"idle","trusted":false},"cell_type":"code","source":"# Getting the predicted Web View\ninputs = X_test\ninputs = np.reshape(inputs,(-1,1))\ninputs = sc.transform(inputs)\ninputs = np.reshape(inputs, (165, 1, 1))\ny_pred = regressor.predict(inputs)\ny_pred = sc.inverse_transform(y_pred)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"af744ff426357a0ad57265eb1d690b0a26003637","_cell_guid":"f570691b-c380-4819-b012-45af0a8d9099","_execution_state":"idle","trusted":false},"cell_type":"code","source":"#Visualising Result\nplt.figure\nplt.plot(y_test, color = 'red', label = 'Real Web View')\nplt.plot(y_pred, color = 'blue', label = 'Predicted Web View')\nplt.title('Web View Forecasting')\nplt.xlabel('Number of Days from Start')\nplt.ylabel('Web View')\nplt.legend()\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"3b3e815a9be09cd0882a48555f4a7ada12d6dffa","_cell_guid":"6aeee05f-9e94-4758-b905-458bd65c9e3f","_execution_state":"idle","trusted":false},"cell_type":"code","source":"#As you can see the prediction is quite accurate for a test set. Now repeat this for some other rows","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d743a4b63e706d88cdf22787580a9501c8b02594","_cell_guid":"436cceba-06b5-41e6-9fb0-2b464cd07340","_execution_state":"idle","trusted":false},"cell_type":"code","source":"row = train.iloc[0,:].values\nX = row[0:549]\ny = row[1:550]\n\n# Splitting the dataset into the Training set and Test set\nfrom sklearn.model_selection import train_test_split\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.3, random_state = 0)\n\n\n\n# Feature Scaling\nfrom sklearn.preprocessing import MinMaxScaler\nsc = MinMaxScaler()\nX_train = np.reshape(X_train,(-1,1))\ny_train = np.reshape(y_train,(-1,1))\nX_train = sc.fit_transform(X_train)\ny_train = sc.fit_transform(y_train)\n\n#Training LSTM\n\n#Reshaping Array\nX_train = np.reshape(X_train, (384,1,1))\n\n\n# Importing the Keras libraries and packages for LSTM\nfrom keras.models import Sequential\nfrom keras.layers import Dense\nfrom keras.layers import LSTM\n\n# Initialising the RNN\nregressor = Sequential()\n\n# Adding the input layerand the LSTM layer\nregressor.add(LSTM(units = 8, activation = 'relu', input_shape = (None, 1)))\n\n\n# Adding the output layer\nregressor.add(Dense(units = 1))\n\n# Compiling the RNN\nregressor.compile(optimizer = 'adam', loss = 'mean_squared_error')\n\n# Fitting the RNN to the Training set\nregressor.fit(X_train, y_train, batch_size = 10, epochs = 100, verbose = 0)\n\n# Getting the predicted Web View\ninputs = X_test\ninputs = np.reshape(inputs,(-1,1))\ninputs = sc.transform(inputs)\ninputs = np.reshape(inputs, (165, 1, 1))\ny_pred = regressor.predict(inputs)\ny_pred = sc.inverse_transform(y_pred)\n\n#Visualising Result\nplt.figure\nplt.plot(y_test, color = 'red', label = 'Real Web View')\nplt.plot(y_pred, color = 'blue', label = 'Predicted Web View')\nplt.title('Web View Forecasting')\nplt.xlabel('Number of Days from Start')\nplt.ylabel('Web View')\nplt.legend()\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"3274290f5638f0cd5a74b636a1604879068b04e5","_cell_guid":"53f35e50-2ea4-493b-8a59-5c9f62e12249","_execution_state":"idle","trusted":false},"cell_type":"code","source":"row = train.iloc[10,:].values\nX = row[0:549]\ny = row[1:550]\n\n# Splitting the dataset into the Training set and Test set\nfrom sklearn.model_selection import train_test_split\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.3, random_state = 0)\n\n\n\n# Feature Scaling\nfrom sklearn.preprocessing import MinMaxScaler\nsc = MinMaxScaler()\nX_train = np.reshape(X_train,(-1,1))\ny_train = np.reshape(y_train,(-1,1))\nX_train = sc.fit_transform(X_train)\ny_train = sc.fit_transform(y_train)\n\n#Training LSTM\n\n#Reshaping Array\nX_train = np.reshape(X_train, (384,1,1))\n\n\n# Importing the Keras libraries and packages for LSTM\nfrom keras.models import Sequential\nfrom keras.layers import Dense\nfrom keras.layers import LSTM\n\n# Initialising the RNN\nregressor = Sequential()\n\n# Adding the input layerand the LSTM layer\nregressor.add(LSTM(units = 8, activation = 'relu', input_shape = (None, 1)))\n\n\n# Adding the output layer\nregressor.add(Dense(units = 1))\n\n# Compiling the RNN\nregressor.compile(optimizer = 'adam', loss = 'mean_squared_error')\n\n# Fitting the RNN to the Training set\nregressor.fit(X_train, y_train, batch_size = 10, epochs = 100, verbose = 0)\n\n# Getting the predicted Web View\ninputs = X_test\ninputs = np.reshape(inputs,(-1,1))\ninputs = sc.transform(inputs)\ninputs = np.reshape(inputs, (165, 1, 1))\ny_pred = regressor.predict(inputs)\ny_pred = sc.inverse_transform(y_pred)\n\n#Visualising Result\nplt.figure\nplt.plot(y_test, color = 'red', label = 'Real Web View')\nplt.plot(y_pred, color = 'blue', label = 'Predicted Web View')\nplt.title('Web View Forecasting')\nplt.xlabel('Number of Days from Start')\nplt.ylabel('Web View')\nplt.legend()\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"65a779b67cd8db29d2d1a80116c692da09b7ceb7","_cell_guid":"fb37c5dd-f6b8-4745-a7ed-19c4bf6cf1b6","_execution_state":"idle","trusted":false},"cell_type":"code","source":"row = train.iloc[100,:].values\nX = row[0:549]\ny = row[1:550]\n\n# Splitting the dataset into the Training set and Test set\nfrom sklearn.model_selection import train_test_split\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.3, random_state = 0)\n\n\n\n# Feature Scaling\nfrom sklearn.preprocessing import MinMaxScaler\nsc = MinMaxScaler()\nX_train = np.reshape(X_train,(-1,1))\ny_train = np.reshape(y_train,(-1,1))\nX_train = sc.fit_transform(X_train)\ny_train = sc.fit_transform(y_train)\n\n#Training LSTM\n\n#Reshaping Array\nX_train = np.reshape(X_train, (384,1,1))\n\n\n# Importing the Keras libraries and packages for LSTM\nfrom keras.models import Sequential\nfrom keras.layers import Dense\nfrom keras.layers import LSTM\n\n# Initialising the RNN\nregressor = Sequential()\n\n# Adding the input layerand the LSTM layer\nregressor.add(LSTM(units = 8, activation = 'relu', input_shape = (None, 1)))\n\n\n# Adding the output layer\nregressor.add(Dense(units = 1))\n\n# Compiling the RNN\nregressor.compile(optimizer = 'adam', loss = 'mean_squared_error')\n\n# Fitting the RNN to the Training set\nregressor.fit(X_train, y_train, batch_size = 10, epochs = 100, verbose = 0)\n\n# Getting the predicted Web View\ninputs = X_test\ninputs = np.reshape(inputs,(-1,1))\ninputs = sc.transform(inputs)\ninputs = np.reshape(inputs, (165, 1, 1))\ny_pred = regressor.predict(inputs)\ny_pred = sc.inverse_transform(y_pred)\n\n#Visualising Result\nplt.figure\nplt.plot(y_test, color = 'red', label = 'Real Web View')\nplt.plot(y_pred, color = 'blue', label = 'Predicted Web View')\nplt.title('Web View Forecasting')\nplt.xlabel('Number of Days from Start')\nplt.ylabel('Web View')\nplt.legend()\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"532105e4ee36d51698c5355f7e59d08d5078c01a","_cell_guid":"8c99b97c-5601-4966-aeb2-f78c4d6037bd","_execution_state":"idle","trusted":false},"cell_type":"code","source":"row = train.iloc[1000,:].values\nX = row[0:549]\ny = row[1:550]\n\n# Splitting the dataset into the Training set and Test set\nfrom sklearn.model_selection import train_test_split\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.3, random_state = 0)\n\n\n\n# Feature Scaling\nfrom sklearn.preprocessing import MinMaxScaler\nsc = MinMaxScaler()\nX_train = np.reshape(X_train,(-1,1))\ny_train = np.reshape(y_train,(-1,1))\nX_train = sc.fit_transform(X_train)\ny_train = sc.fit_transform(y_train)\n\n#Training LSTM\n\n#Reshaping Array\nX_train = np.reshape(X_train, (384,1,1))\n\n\n# Importing the Keras libraries and packages for LSTM\nfrom keras.models import Sequential\nfrom keras.layers import Dense\nfrom keras.layers import LSTM\n\n# Initialising the RNN\nregressor = Sequential()\n\n# Adding the input layerand the LSTM layer\nregressor.add(LSTM(units = 8, activation = 'relu', input_shape = (None, 1)))\n\n\n# Adding the output layer\nregressor.add(Dense(units = 1))\n\n# Compiling the RNN\nregressor.compile(optimizer = 'adam', loss = 'mean_squared_error')\n\n# Fitting the RNN to the Training set\nregressor.fit(X_train, y_train, batch_size = 10, epochs = 100, verbose = 0)\n\n# Getting the predicted Web View\ninputs = X_test\ninputs = np.reshape(inputs,(-1,1))\ninputs = sc.transform(inputs)\ninputs = np.reshape(inputs, (165, 1, 1))\ny_pred = regressor.predict(inputs)\ny_pred = sc.inverse_transform(y_pred)\n\n#Visualising Result\nplt.figure\nplt.plot(y_test, color = 'red', label = 'Real Web View')\nplt.plot(y_pred, color = 'blue', label = 'Predicted Web View')\nplt.title('Web View Forecasting')\nplt.xlabel('Number of Days from Start')\nplt.ylabel('Web View')\nplt.legend()\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"27cdcf611fa0b7bf2b645bfdfba2210bf6bc79f0","_cell_guid":"cfb38236-eb1e-4c47-8491-ff78eda1553c","_execution_state":"idle","trusted":false},"cell_type":"code","source":"#Now lets train on one page and test on another page\ntrain_row = train.iloc[90000,:].values\nX = train_row[0:549]\ny = train_row[1:550]\n\n\n# Feature Scaling\nfrom sklearn.preprocessing import MinMaxScaler\nsc = MinMaxScaler()\nX_train = np.reshape(X,(-1,1))\ny_train = np.reshape(y,(-1,1))\nX_train = sc.fit_transform(X_train)\ny_train = sc.fit_transform(y_train)\n\n#Training LSTM\n\n#Reshaping Array\nX_train = np.reshape(X_train, (549,1,1))\n\n\n# Importing the Keras libraries and packages for LSTM\nfrom keras.models import Sequential\nfrom keras.layers import Dense\nfrom keras.layers import LSTM\n\n# Initialising the RNN\nregressor = Sequential()\n\n# Adding the input layerand the LSTM layer\nregressor.add(LSTM(units = 8, activation = 'relu', input_shape = (None, 1)))\n\n\n# Adding the output layer\nregressor.add(Dense(units = 1))\n\n# Compiling the RNN\nregressor.compile(optimizer = 'adam', loss = 'mean_squared_error')\n\n# Fitting the RNN to the Training set\nregressor.fit(X_train, y_train, batch_size = 10, epochs = 100, verbose = 0)\n\n# Getting the predicted Web View\ntest_row = train.iloc[10000,:].values\nX_test = test_row[0:549]\ny_test = test_row[1:550]\ninputs = X_test\ninputs = np.reshape(inputs,(-1,1))\ninputs = sc.transform(inputs)\ninputs = np.reshape(inputs, (549, 1, 1))\ny_pred = regressor.predict(inputs)\ny_pred = sc.inverse_transform(y_pred)\n\n#Visualising Result\nplt.figure\nplt.plot(y_test, color = 'red', label = 'Real Web View')\nplt.plot(y_pred, color = 'blue', label = 'Predicted Web View')\nplt.title('Web View Forecasting')\nplt.xlabel('Number of Days from Start')\nplt.ylabel('Web View')\nplt.legend()\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"2451eba1648dbb29b82a70ecc8aa74a91c192da3","_cell_guid":"0836e485-d7d4-44c1-a4a6-239d8c2be110","_execution_state":"idle","trusted":false},"cell_type":"code","source":"#Repeating on another page\n# Getting the predicted Web View\ntest_row = train.iloc[5000,:].values\nX_test = test_row[0:549]\ny_test = test_row[1:550]\ninputs = X_test\ninputs = np.reshape(inputs,(-1,1))\ninputs = sc.transform(inputs)\ninputs = np.reshape(inputs, (549, 1, 1))\ny_pred = regressor.predict(inputs)\ny_pred = sc.inverse_transform(y_pred)\n\n#Visualising Result\nplt.figure\nplt.plot(y_test, color = 'red', label = 'Real Web View')\nplt.plot(y_pred, color = 'blue', label = 'Predicted Web View')\nplt.title('Web View Forecasting')\nplt.xlabel('Number of Days from Start')\nplt.ylabel('Web View')\nplt.legend()\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"aefcbfc5bfa7e94d39f1a3b06d728cae85a27589","_cell_guid":"1b0f527f-6a36-4997-ad3f-c9c8c15ad400","_execution_state":"idle","trusted":false},"cell_type":"code","source":"# Getting the predicted Web View\nimport random\nX_value = random.randint(0,train.shape[0])\ntest_row = train.iloc[X_value,:].values\nX_test = test_row[0:549]\ny_test = test_row[1:550]\ninputs = X_test\ninputs = np.reshape(inputs,(-1,1))\ninputs = sc.transform(inputs)\ninputs = np.reshape(inputs, (549, 1, 1))\ny_pred = regressor.predict(inputs)\ny_pred = sc.inverse_transform(y_pred)\n\n#Visualising Result\nplt.figure\nplt.plot(y_test, color = 'red', label = 'Real Web View')\nplt.plot(y_pred, color = 'blue', label = 'Predicted Web View')\nplt.title('Web View Forecasting for')\nplt.xlabel('Number of Days from Start')\nplt.ylabel('Web View')\nplt.legend()\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"84af2ebf42a79b2d2716880ae3fb9d5036be9d46","_cell_guid":"92bed01a-8aa2-4b69-9090-35e19f515f50","_execution_state":"idle","trusted":false},"cell_type":"code","source":"# Getting the predicted Web View\nimport random\nX_value = random.randint(0,train.shape[0])\ntest_row = train.iloc[X_value,:].values\nX_test = test_row[0:549]\ny_test = test_row[1:550]\ninputs = X_test\ninputs = np.reshape(inputs,(-1,1))\ninputs = sc.transform(inputs)\ninputs = np.reshape(inputs, (549, 1, 1))\ny_pred = regressor.predict(inputs)\ny_pred = sc.inverse_transform(y_pred)\n\n#Visualising Result\nplt.figure\nplt.plot(y_test, color = 'red', label = 'Real Web View')\nplt.plot(y_pred, color = 'blue', label = 'Predicted Web View')\nplt.title('Web View Forecasting for')\nplt.xlabel('Number of Days from Start')\nplt.ylabel('Web View')\nplt.legend()\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"6df1c440c4d905bc1d9688ae6d804bf345433e26","_cell_guid":"a66f1739-1335-42d3-9851-cc88c0e42ca5","_execution_state":"idle","trusted":false},"cell_type":"code","source":"# Getting the predicted Web View\nimport random\nX_value = random.randint(0,train.shape[0])\ntest_row = train.iloc[X_value,:].values\nX_test = test_row[0:549]\ny_test = test_row[1:550]\ninputs = X_test\ninputs = np.reshape(inputs,(-1,1))\ninputs = sc.transform(inputs)\ninputs = np.reshape(inputs, (549, 1, 1))\ny_pred = regressor.predict(inputs)\ny_pred = sc.inverse_transform(y_pred)\n\n#Visualising Result\nplt.figure\nplt.plot(y_test, color = 'red', label = 'Real Web View')\nplt.plot(y_pred, color = 'blue', label = 'Predicted Web View')\nplt.title('Web View Forecasting for')\nplt.xlabel('Number of Days from Start')\nplt.ylabel('Web View')\nplt.legend()\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d13a87b473ab79cb2f2e38b3561dae14b40fbb8a","_cell_guid":"061e9b61-1124-4bef-85dd-e6dc55a84560","_execution_state":"idle","trusted":false},"cell_type":"code","source":"# Getting the Mean Web View - 1000 Pages\ny_test_mean = []\ny_pred_mean = []\nfor X_value in range(0,1000):\n    test_row = train.iloc[X_value,:].values\n    X_test = test_row[0:549]\n    y_test = test_row[1:550]\n    y_test_mean.append(np.mean(y_test))\n    inputs = X_test\n    inputs = np.reshape(inputs,(-1,1))\n    inputs = sc.transform(inputs)\n    inputs = np.reshape(inputs, (549, 1, 1))\n    y_pred = regressor.predict(inputs)\n    y_pred = sc.inverse_transform(y_pred)\n    y_pred_mean.append(np.mean(y_pred))","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"949820d67f2e2a1f9d5995598f506e4140037574","_cell_guid":"5d8f2417-8e5c-47ce-909b-cccc85fda833","_execution_state":"idle","trusted":false},"cell_type":"code","source":"#Visualising mean\nplt.figure\nplt.plot(y_test_mean, color = 'red', label = 'Mean Real Web View')\nplt.plot(y_pred_mean, color = 'blue', label = 'Mean Predicted Web View')\nplt.title('Mean Web View Forecasting')\nplt.xlabel('Index of Page')\nplt.ylabel('Mean Web View')\nplt.legend()\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"e87b6327578273cdd47bbee2deb5b1c888e0e6aa","_cell_guid":"7419363e-99d2-4f41-8ba2-6431a29bae62","_execution_state":"idle","trusted":false},"cell_type":"code","source":"# Getting the Mean Web View - 100 Pages\ny_test_mean = []\ny_pred_mean = []\nfor X_value in range(0,100):\n    test_row = train.iloc[X_value,:].values\n    X_test = test_row[0:549]\n    y_test = test_row[1:550]\n    y_test_mean.append(np.mean(y_test))\n    inputs = X_test\n    inputs = np.reshape(inputs,(-1,1))\n    inputs = sc.transform(inputs)\n    inputs = np.reshape(inputs, (549, 1, 1))\n    y_pred = regressor.predict(inputs)\n    y_pred = sc.inverse_transform(y_pred)\n    y_pred_mean.append(np.mean(y_pred))\n    \n#Visualising mean\nplt.figure\nplt.plot(y_test_mean, color = 'red', label = 'Mean Real Web View')\nplt.plot(y_pred_mean, color = 'blue', label = 'Mean Predicted Web View')\nplt.title('Mean Web View Forecasting')\nplt.xlabel('Index of Page')\nplt.ylabel('Mean Web View')\nplt.legend()\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"14d8f171246e4cbfacffba787af2096065847139","_cell_guid":"6c1ae680-354a-4725-9932-fa950f38e38b","_execution_state":"idle","trusted":false},"cell_type":"code","source":"# Getting the Mean Web View - random 100 Pages in between\npages = np.random.randint(0,train.shape[0],100)\ny_test_mean = []\ny_pred_mean = []\nfor X_value in pages:\n    test_row = train.iloc[X_value,:].values\n    X_test = test_row[0:549]\n    y_test = test_row[1:550]\n    y_test_mean.append(np.mean(y_test))\n    inputs = X_test\n    inputs = np.reshape(inputs,(-1,1))\n    inputs = sc.transform(inputs)\n    inputs = np.reshape(inputs, (549, 1, 1))\n    y_pred = regressor.predict(inputs)\n    y_pred = sc.inverse_transform(y_pred)\n    y_pred_mean.append(np.mean(y_pred))\n    \n#Visualising mean\nplt.figure\nplt.plot(y_test_mean, color = 'red', label = 'Mean Real Web View')\nplt.plot(y_pred_mean, color = 'blue', label = 'Mean Predicted Web View')\nplt.title('Mean Web View Forecasting')\nplt.ylabel('Mean Web View')\nplt.legend()\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"958cfb0a5cc296df70cd66a6aa545b0b5daa5aba","_cell_guid":"971ded2c-e0a7-4b96-a16d-b39280ecbc8e","_execution_state":"idle","trusted":false},"cell_type":"code","source":"# Getting the Mean Web View - random 100 Pages in between\npages = np.random.randint(0,train.shape[0],100)\ny_test_mean = []\ny_pred_mean = []\nfor X_value in pages:\n    test_row = train.iloc[X_value,:].values\n    X_test = test_row[0:549]\n    y_test = test_row[1:550]\n    y_test_mean.append(np.mean(y_test))\n    inputs = X_test\n    inputs = np.reshape(inputs,(-1,1))\n    inputs = sc.transform(inputs)\n    inputs = np.reshape(inputs, (549, 1, 1))\n    y_pred = regressor.predict(inputs)\n    y_pred = sc.inverse_transform(y_pred)\n    y_pred_mean.append(np.mean(y_pred))\n    \n#Visualising mean\nplt.figure\nplt.plot(y_test_mean, color = 'red', label = 'Mean Real Web View')\nplt.plot(y_pred_mean, color = 'blue', label = 'Mean Predicted Web View')\nplt.title('Mean Web View Forecasting')\nplt.ylabel('Mean Web View')\nplt.legend()\nplt.show()","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.6","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}