From cdc6a810cc6c8b050f95f359346998a227d95164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Schr=C3=B6der?= Date: Wed, 6 Jan 2016 22:16:31 +0100 Subject: [PATCH 1/3] Changed the code to make it run in python 3 --- .gitignore | 3 +- environment3.yaml | 156 ++++++++++++++++++++++++++++++++++++++++++++++ neural_nets.ipynb | 26 ++++---- 3 files changed, 171 insertions(+), 14 deletions(-) create mode 100644 environment3.yaml diff --git a/.gitignore b/.gitignore index 2a1cde6..ab08415 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.nogit -.ipynb_checkpoints/ \ No newline at end of file +.ipynb_checkpoints/ +GoogleNews-vectors-negative300.bin \ No newline at end of file diff --git a/environment3.yaml b/environment3.yaml new file mode 100644 index 0000000..8c3848d --- /dev/null +++ b/environment3.yaml @@ -0,0 +1,156 @@ +name: root +dependencies: +- alabaster=0.7.6=py35_0 +- anaconda=2.4.0=np110py35_0 +- anaconda-client=1.1.0=py35_0 +- argcomplete=1.0.0=py35_1 +- astropy=1.0.5=np110py35_1 +- babel=2.1.1=py35_0 +- beautifulsoup4=4.4.1=py35_0 +- bitarray=0.8.1=py35_1 +- blaze-core=0.8.3=py35_0 +- bokeh=0.10.0=py35_0 +- boto=2.38.0=py35_0 +- bzip2=1.0.6=vc14_2 +- cffi=1.2.1=py35_0 +- clyent=0.4.0=py35_0 +- colorama=0.3.3=py35_0 +- comtypes=1.1.2=py35_0 +- conda=3.19.0=py34_0 +- conda-build=1.18.1=py35_0 +- conda-env=2.4.5=py34_0 +- configobj=5.0.6=py35_0 +- console_shortcut=0.1.1=py35_1 +- cryptography=1.0.2=py35_0 +- curl=7.45.0=vc14_0 +- cycler=0.9.0=py34_0 +- cython=0.23.4=py35_0 +- cytoolz=0.7.4=py35_0 +- datashape=0.4.7=np110py35_1 +- decorator=4.0.4=py34_0 +- docutils=0.12=py35_1 +- fastcache=1.0.2=py35_0 +- flask=0.10.1=py35_1 +- freetype=2.5.5=vc14_0 +- gensim=0.12.2=np110py34_0 +- greenlet=0.4.9=py35_0 +- h5py=2.5.0=np19py34_0 +- hdf5=1.8.15.1=vc14_3 +- idna=2.0=py35_0 +- ipykernel=4.1.1=py34_0 +- ipython=4.0.0=py34_1 +- ipython-notebook=4.0.4=py34_3 +- ipython-qtconsole=4.0.1=py35_4 +- ipython_genutils=0.1.0=py34_0 +- ipywidgets=4.1.0=py35_0 +- itsdangerous=0.24=py35_0 +- jdcal=1.0=py35_0 +- jedi=0.9.0=py35_0 +- jinja2=2.8=py34_0 +- jpeg=8d=vc10_0 +- jsonschema=2.4.0=py34_0 +- jupyter=1.0.0=py35_0 +- jupyter_client=4.1.1=py34_0 +- jupyter_console=4.0.3=py35_0 +- jupyter_core=4.0.6=py34_0 +- klustakwik2=0.2.4=nppy34_0 +- launcher=1.0.0=4 +- libpng=1.6.17=vc10_1 +- libsodium=1.0.3=0 +- libtiff=4.0.6=vc10_1 +- lxml=3.4.4=py35_0 +- markupsafe=0.23=py34_0 +- matplotlib=1.5.0=np110py34_0 +- menuinst=1.3.1=py34_0 +- mistune=0.7.1=py34_0 +- msvc_runtime=1.0.1=vc10_0 +- multipledispatch=0.4.8=py35_0 +- nbconvert=4.0.0=py34_0 +- nbformat=4.0.1=py34_0 +- networkx=1.10=py35_0 +- nltk=3.1=py35_0 +- node-webkit=0.10.1=0 +- nose=1.3.7=py34_0 +- notebook=4.0.6=py34_0 +- numexpr=2.4.4=np110py35_0 +- numpy=1.10.1=py34_0 +- odo=0.3.4=py35_0 +- openpyxl=2.2.6=py35_0 +- openssl=1.0.2d=vc10_0 +- pandas=0.17.1=np110py34_0 +- path.py=8.1.2=py34_0 +- patsy=0.4.0=np110py35_0 +- pep8=1.6.2=py35_0 +- pickleshare=0.5=py34_0 +- pillow=3.0.0=py35_1 +- pip=7.1.2=py34_0 +- ply=3.8=py35_0 +- psutil=3.2.2=py35_0 +- py=1.4.30=py35_0 +- pyasn1=0.1.9=py35_0 +- pycosat=0.6.1=py34_0 +- pycparser=2.14=py35_0 +- pycrypto=2.6.1=py35_3 +- pycurl=7.19.5.1=py35_1 +- pyflakes=1.0.0=py35_0 +- pygments=2.0.2=py34_0 +- pyopengl=3.1.1a1=np19py34_0 +- pyopenssl=0.15.1=py35_1 +- pyparsing=2.0.3=py34_0 +- pyqt=4.11.4=py34_4 +- pyreadline=2.1=py34_0 +- pytables=3.2.2=np110py35_1 +- pytest=2.8.1=py35_0 +- python=3.4.3=5 +- python-dateutil=2.4.2=py34_0 +- pytz=2015.7=py34_0 +- pywin32=219=py35_1 +- pyyaml=3.11=py34_2 +- pyzmq=14.7.0=py34_0 +- qt=4.8.7=vc10_5 +- qtconsole=4.1.0=py35_0 +- requests=2.9.0=py34_0 +- rope=0.9.4=py35_1 +- scikit-image=0.11.3=np110py35_0 +- scikit-learn=0.17=np110py34_1 +- scipy=0.16.0=np110py34_0 +- seaborn=0.6.0=np110py34_0 +- setuptools=19.1.1=py34_0 +- simplegeneric=0.8.1=py34_0 +- simplejson=3.8.0=py34_0 +- sip=4.16.9=py34_2 +- six=1.10.0=py34_0 +- snowballstemmer=1.2.0=py35_0 +- sockjs-tornado=1.0.1=py35_0 +- sphinx=1.3.1=py35_0 +- sphinx_rtd_theme=0.1.7=py35_0 +- spyder=2.3.7=py35_3 +- spyder-app=2.3.7=py35_0 +- sqlalchemy=1.0.9=py35_0 +- statsmodels=0.6.1=np110py35_0 +- sympy=0.7.6.1=py35_0 +- tk=8.5.18=vc10_0 +- toolz=0.7.4=py35_0 +- tornado=4.2.1=py34_1 +- traitlets=4.0.0=py34_0 +- ujson=1.33=py35_0 +- unicodecsv=0.14.1=py35_0 +- vispy=0.4.0.106.gf8a69d0=np19py34_0 +- werkzeug=0.10.4=py35_0 +- wheel=0.26.0=py34_1 +- xlrd=0.9.4=py35_0 +- xlsxwriter=0.7.7=py35_0 +- xlwings=0.4.1=py35_0 +- xlwt=1.0.0=py35_0 +- zeromq=4.1.3=vc14_1 +- zlib=1.2.8=vc10_2 +- pip: + - blaze==0.8.3 + - ipython-genutils==0.1.0 + - jupyter-client==4.1.1 + - jupyter-console==4.0.3 + - jupyter-core==4.0.6 + - phy==0.2.2 + - rope-py3k-0.9.4==1 + - sphinx-rtd-theme==0.1.7 + - tables==3.2.2 diff --git a/neural_nets.ipynb b/neural_nets.ipynb index f1f2707..04bf2e8 100644 --- a/neural_nets.ipynb +++ b/neural_nets.ipynb @@ -4,7 +4,7 @@ "cell_type": "code", "execution_count": null, "metadata": { - "collapsed": true + "collapsed": false }, "outputs": [], "source": [ @@ -50,7 +50,7 @@ "import numpy as np\n", "import matplotlib.pylab as plt\n", "from scipy.special import expit as sigmoid\n", - "from itertools import izip\n", + "#from itertools import izip\n", "\n", "SIZE = 100\n", "\n", @@ -143,7 +143,7 @@ "learning_rate = .001\n", "\n", "normalized_weight_history = []\n", - "for epoch in xrange(epochs):\n", + "for epoch in range(epochs):\n", " pred = sigmoid(np.dot(training_x, weights))\n", " deriv = pred * (1 - pred) * (pred - training_t)\n", " update = np.dot(deriv, training_x)\n", @@ -154,9 +154,9 @@ " \n", "preds = (sigmoid(np.dot(training_x, weights)) > .5).astype(int)\n", "\n", - "print \"Mean Absolute Error:\", metrics.mean_absolute_error(training_t, preds)\n", - "print \"Mean Squared Error:\", metrics.mean_squared_error(training_t, preds)\n", - "print \"R^2:\", metrics.r2_score(training_t, preds)\n", + "print(\"Mean Absolute Error: {mae}\".format(mae=metrics.mean_absolute_error(training_t, preds)))\n", + "print(\"Mean Squared Error: {mse}\".format(mse=metrics.mean_squared_error(training_t, preds)))\n", + "print(\"R^2: {r2}\".format(r2=metrics.r2_score(training_t, preds)))\n", "\n", "plt.scatter(\n", " normalized_weight_history[:, 0],\n", @@ -293,7 +293,7 @@ "cell_type": "code", "execution_count": null, "metadata": { - "collapsed": true + "collapsed": false }, "outputs": [], "source": [ @@ -467,7 +467,7 @@ "outputs": [], "source": [ "# this took about an hour on our 16GB Digital Ocean instance - go grab lunch!\n", - "yelp_model = gensim.models.word2vec.Word2Vec(reviews)" + "yelp_model = gensim.models.word2vec.Word2Vec(['test'])" ] }, { @@ -630,21 +630,21 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 2", + "display_name": "Python 3", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.8" + "pygments_lexer": "ipython3", + "version": "3.4.3" } }, "nbformat": 4, From 525791224b06a73d9d292816644b3e7af482d9d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Schr=C3=B6der?= Date: Wed, 6 Jan 2016 22:20:53 +0100 Subject: [PATCH 2/3] Fixed error that was introduced in last commit when testing --- neural_nets.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neural_nets.ipynb b/neural_nets.ipynb index 04bf2e8..b4d3efe 100644 --- a/neural_nets.ipynb +++ b/neural_nets.ipynb @@ -467,7 +467,7 @@ "outputs": [], "source": [ "# this took about an hour on our 16GB Digital Ocean instance - go grab lunch!\n", - "yelp_model = gensim.models.word2vec.Word2Vec(['test'])" + "yelp_model = gensim.models.word2vec.Word2Vec(reviews)" ] }, { From b892fa0252e376cddb709caca5ee4ae1fee4ef8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Schr=C3=B6der?= Date: Wed, 6 Jan 2016 22:25:17 +0100 Subject: [PATCH 3/3] renamed notebook to have python 2 and 3 present simultaneously --- neural_nets.ipynb => neural_nets3.ipynb | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename neural_nets.ipynb => neural_nets3.ipynb (100%) diff --git a/neural_nets.ipynb b/neural_nets3.ipynb similarity index 100% rename from neural_nets.ipynb rename to neural_nets3.ipynb