IPython will continue to exist as a Python kernel for Jupyter, but
the notebook and other language-agnostic parts of IPython will
move to new projects under the Jupyter name. IPython 3.0 will
be the last monolithic release of IPython.
• interactive shell
• browser-based notebook
• great support for visualization library (eg. matplotlib)
• built on pyzmq, tornado
NOTEBOOK == BROWSER-BASED REPL
IPython Notebook is a web-based interactive
computational environment for creating IPython
notebooks. An IPython notebook is a JSON
document containing an ordered list of input/output
cells which can contain code, text, mathematics,
plots and rich media.
matplotlib tries to make easy things easy and hard things
possible. You can generate plots, histograms, power
spectra, bar charts, errorcharts, scatterplots, etc, with just a
few lines of code, with familiar MATLAB APIs.
• Spark on Python, this serves as the Kernel,
integrating with IPython
• Each notebook spins up a new instance of the
Kernel (ie. PySpark running as the Spark Driver, in
different deploy mode Spark/PySpark supports)
(All notebook examples are a subset of those in
the Meetup reconstructed here)
Word2Vec computes distributed vector
representation of words. Distributed vector
representation is showed to be useful in many
natural language processing applications such as
named entity recognition, disambiguation, parsing,
tagging and machine translation.
Spark MLlib implements the Skip-gram approach.
With Skip-gram we want to predict a window of
words given a single word.
Wikipedia dump http://mattmahoney.net/dc/
then randomly sampled to ~200k lines
To setup IPython
• Python 2.7.9 (separate from CentOS default 2.6.6), on all
• matplotlib, on the host running IPython
To run IPython with the PySpark Kernel, set these in the environment
(Please check out my handy script on github)
PYSPARK_PYTHON command to run python, eg. “python2.7”
PYSPARK_DRIVER_PYTHON command to run ipython
PYSPARK_DRIVER_PYTHON_OPTS “notebook —proﬁle”
PYSPARK_SUBMIT_ARGS pyspark commandline, eg. --master --deploy_mode
YARN_CONF_DIR if YARN mode
LD_LIBRARY_PATH for matplotlib
.. and more https://github.com/ipython/ipython/wiki/IPython-kernels-for-other-
Apache Zeppelin (incubating) is interactive data analytics environment
for distributed data processing system. It provides beautiful interactive
web-based interface, data visualization, collaborative work
environment and many other nice features to make your data analytics
more fun and enjoyable.
Zeppelin has been incubating since Dec 2014.
shell script &
calling library package
Load and process data
SQL query powered by
Spark SQL -
data passing across
• Clustering tries to ﬁnd natural groupings in
data. It puts objects into groups in which
those within a group are more similar to each
other than to those in other groups.
• Unsupervised learning
• First, given an initial set of k cluster centers,
we ﬁnd which cluster each data point is
• Then, we compute the average of each of the
new clusters and use the result to update our
K-MEANS|| IN MLLIB
• a parallelized variant of the k-means++
• k is the number of desired clusters.
• maxIterations is the maximum number of iterations to run.
• initializationMode speciﬁes either random initialization or initialization via
• runs is the number of times to run the k-means algorithm (k-means is not
guaranteed to ﬁnd a globally optimal solution, and when run multiple
times on a given dataset, the algorithm returns the best clustering result).
• initializationSteps determines the number of steps in the k-means||
• epsilon determines the distance threshold within which we consider k-
means to have converged.
• Train - model - predict works well on static
• What if data is
• Coming in streams
• Changing over time?
STREAMING K-MEANS DESIGN
• Proposed by Dr Jeremy Freeman (here)
• key concept: forgetfulness
• balances the relative importance of new
data versus past history
• time it takes before past data contributes to
only one half of the current model
• time unit
• batches (which have a ﬁxed duration in
time), or points
• eliminate dying clusters
• Lightning - data visualization server
• provides API-based access to reproducible, web-
based, interactive visualizations. It includes a core set
of visualization types, but is built for extendability
and customization. Lightning supports modern
libraries like d3.js and three.js, and is designed for
interactivity over large data sets and continuously
updating data streams.
VISUALIZING STREAMING K-
MEANS ON IPYTHON + LIGHTNING
The Freeman Lab at Janelia Research Campus uses Lightning to visualize
large-scale neural recordings from zebraﬁsh, in collaboration with the
SPARK STREAMING K-MEANS
• requires: numpy, scipy, scikit-learn
• IPython/Python requires: lightning-python package
Demo consists of 3 parts:
• Python driver script, data generator
• Scala job - Spark Streaming & Streaming k-means
• IPython notebook to process result, visualize with Lightning
Originally this was part of the Python driver script - it has
been modiﬁed for this talk to run within IPython