{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# LSTM (Long Short Term Memory)\n", "\n", "There is a branch of Deep Learning that is dedicated to processing time series. These deep Nets are **Recursive Neural Nets (RNNs)**. LSTMs are one of the few types of RNNs that are available. Gated Recurent Units (GRUs) are the other type of popular RNNs.\n", "\n", "This is an illustration from http://colah.github.io/posts/2015-08-Understanding-LSTMs/ (A highly recommended read)\n", "\n", "\n", "\n", "Pros:\n", "- Really powerful pattern recognition system for time series\n", "\n", "Cons:\n", "- Cannot deal with missing time steps.\n", "- Time steps must be discretised and not continuous.\n", "" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": true }, "outputs": [], "source": [ "%matplotlib inline\n", "import pandas as pd\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "\n", "import re\n", "\n", "from keras.models import Sequential\n", "from keras.layers import Activation, Dropout, Flatten, Dense, BatchNormalization, LSTM, Embedding, TimeDistributed\n", "from keras.models import load_model, model_from_json" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | source | \n", "text | \n", "created_at | \n", "favorite_count | \n", "is_retweet | \n", "id_str | \n", "
|---|---|---|---|---|---|---|
| 0 | \n", "Twitter for iPhone | \n", "i think senator blumenthal should take a nice ... | \n", "08-07-2017 20:48:54 | \n", "61446 | \n", "false | \n", "8.946617e+17 | \n", "
| 1 | \n", "Twitter for iPhone | \n", "how much longer will the failing nytimes with ... | \n", "08-07-2017 20:39:46 | \n", "42235 | \n", "false | \n", "8.946594e+17 | \n", "
| 2 | \n", "Twitter for iPhone | \n", "the fake news media will not talk about the im... | \n", "08-07-2017 20:15:18 | \n", "45050 | \n", "false | \n", "8.946532e+17 | \n", "
| 4 | \n", "Twitter for iPhone | \n", "on #purpleheartday💜i thank all the brave men a... | \n", "08-07-2017 18:03:42 | \n", "48472 | \n", "false | \n", "8.946201e+17 | \n", "
| 5 | \n", "Twitter for iPhone | \n", "...conquests how brave he was and it was all a... | \n", "08-07-2017 12:01:20 | \n", "59253 | \n", "false | \n", "8.945289e+17 | \n", "