Moving to Python 3

The time has come. All the libraries I use on a regular basis are available for Python 3.4. I just spent a frighteningly short amount of time with [MacPorts][] installing everything I need and then making sure that Python 3.4 and iPython 3.4 are the defaults. Here’s all that I had to type:

% sudo port selfupdate
% sudo port install python34
% sudo port install py34-numpy
% sudo port install py34-scipy
% sudo port install py34-nltk
% sudo port install py34-pandas
% sudo port install ipython34
% sudo port select –set python python3
% sudo port select –set ipython ipython3

And then, because I’m working on something for [The Programming Historian][] and it’s just easier to do everything in an iPython notebook:

% ipython notebook

Later, all I will need to do is:

% ipython nbconvert –to markdown myFile.ipynb

[MacPorts]: https://www.macports.org
[The Programming Historian]: http://programminghistorian.org

Fantastical

While Mac OS X’s Calendar and the iCloud service handle the back-end, I increasingly only use Fantastical for interacting with times, dates, appointments, and schedules. Not only is its natural language system very good — “Meet with this person next Friday from 2 to 2:30 in my office” — but it just looks good:

Screen Shot 2015-07-24 at 3.27.44 PM

Residential Alternatives

The more I live in Louisiana, the more I would like either to live somewhere else or at least be able to get to other places when I have the time. (Sadly, the more I live here, the less I am able to afford anything.) Until that moment where I live elsewhere, I like to daydream about either living in a small house, maybe even a tiny house as they are now known, or at least camping in a similarly outfitted trailer.

Here are some ideas:

![Airstream](http://farm8.staticflickr.com/7421/9532578741_71873e52dc_o.png)
*An [Updated Airstream](http://www.mooreachats.com/mooreasealblog/orea-seal.com/2013/08/a-mod-airstream-remodel.html)*

![Updated 1962 Bambi Airstream](http://www.silvertrailer.com/edit/assets/SilverTrailerBambi.jpg)
*A [1962 Airstream Bambi](http://www.silvertrailer.com/design_bambi.php)*

![Travel Trailer Home](http://static1.squarespace.com/static/52fa6ad7e4b0e8aa92db7ab7/t/531bc40ae4b02c4ce25fabd3/1394328592492/IMG_6884.jpg?format=750w)
*A [Lived-In Travel Trailer](http://www.anchoredhomeblog.com/blog/2014/2/19/our-anchored-home-before-after)*

Complete MacPorts Installation Cheat Sheet

The following set of commands assume that you begin with a Mac OS X that does not have any of the necessities already installed. You can, thus, skip anything you have already done, e.g., if you have already installed Xcode, skip to Step 2.

  1. Install the Xcode development and command line tool environment.
  2. Install the MacPorts basic installation.
  3. Install Python 2.7 for math, science, and NLP.
  4. Install iPython and select it like you did for Python:
    port select --set ipython ipython27
  1. Install iPython notebook. (And here’s a list of dependencies in case the notebook installation doesn’t complete by itself.)

Python ML Projects

Bhavya Geethika Peddibhotla at _KD Nuggets_ has compiled a list of the [“Top 20 Python Machine Learning Open Source Projects.”](http://www.kdnuggets.com/2015/06/top-20-python-machine-learning-open-source-projects.html) At the top? `scikit-learn`, as evidenced in one of the graphics from the article:

![The Top 20 Open Source Machine Learning Projects in Python](http://www.kdnuggets.com/wp-content/uploads/top-python-machine-learning-projects1.jpg)

Visual Correspondence

In addition to the Map of Metaphor in English, there is also [Visual Correspondence][1], a project to make available not only the contents of correspondence but also the metadata — who received the letter? who else was a correspondent? — and to make all of this data and metadata available for visualization.

[1]: http://letters.nialloleary.ie

Mapping Metaphor

The [Metaphor Map of English][] is now available. It’s a fascinating labyrinth, especially if you have any interest in conceptual metaphors. Here’s what the map’s developers have to say:

> The Metaphor Map of English shows the metaphorical links which have been identified between different areas of meaning. These links can be from the Anglo-Saxon period right up to the present day so the map covers 1300 years of the English language. This allows us the opportunity to track metaphorical ways of thinking and expressing ourselves over more than a millennium; see the Metaphor in English section for more information.
>
> The Metaphor Map was built as part of the Mapping Metaphor with the Historical Thesaurus project. This was completed by a team in English Language at the University of Glasgow and funded by the Arts and Humanities Research Council from 2012 to early 2015. The Metaphor Map is based on the Historical Thesaurus of English, which was published in 2009 by Oxford University Press as the Historical Thesaurus of the Oxford English Dictionary.

[Metaphor Map of English]: http://mappingmetaphor.arts.gla.ac.uk

From CSV to Bipartite Network to One-Mode Projection

I am continuing my effort to develop my own stack of scripts that do exactly what I want and that I understand how they work. They are not, in all honesty, scalable like the work done by Tim Tangherlini, but my work here pleases me.

I don’t have weighting in place yet to make the projection have more meaning than it does, but this code uses `pandas` and works quite well:

~~~~
#! /usr/bin/env python

import pandas as pd, networkx as nx, matplotlib.pyplot as plt
from networkx.algorithms import bipartite

# Build lists of nodes and edges:

df = (pd.read_csv(‘tales-01.txt’, header=None)
.groupby(level=0)
.apply(lambda x : pd.DataFrame ([[x.iloc[0,0],v] for v in x.iloc[0,1:]]))
.reset_index(drop=True)
.dropna()
.rename_axis({0:’text’,1:’word’},axis=1)
)
edges = df.values.tolist()
nodes_0 = list(set(df[‘text’].values.tolist()))
nodes_1 = list(set(df[‘word’].values.tolist()))

# Build a bipartite graph:

B = nx.Graph()
B.add_nodes_from(nodes_0, bipartite=0) # Add the node attribute “bipartite”
B.add_nodes_from(nodes_1, bipartite=1)
B.add_edges_from(edges)

# Project one side of the graph:

G = nx.projected_graph(B, nodes_1)
nx.draw(G,
pos=nx.spring_layout(G),
with_labels = True,
node_color = ‘#00CCFF’)

# Choose your output:
plt.show()
# plt.savefig(“graphing.png”, dpi=300)
~~~~

For those less familiar with bipartite networks, Wikipedia as always has [a decent introduction][].

[a decent introduction]: https://en.wikipedia.org/wiki/Bipartite_network_projection