Friday, September 16, 2016

Blow it up and start again

The president of Olin College, Rick Miller, spoke recently at the Business Innovation Factory.  Here's the most-tweeted quote from the talk: "The only way to change education is to blow it up and start again."

I agree, and I saw an example recently that helps make the point.  The American Statistical Association recently published this Statement on p-Values.  Here's how it starts:
In February 2014, George Cobb, Professor Emeritus of Mathematics
and Statistics at Mount Holyoke College, posed these
questions to an ASA discussion forum:
Q: Why do so many colleges and grad schools teach p = 0.05?
A: Because that’s still what the scientific community and journal
editors use.
Q: Why do so many people still use p = 0.05?
A: Because that’s what they were taught in college or grad school.
Cobb’s concern was a long-worrisome circularity in the sociology
of science based on the use of bright lines such as p < 0.05:
“We teach it because it’s what we do; we do it because it’s what
we teach.” 
This "worrisome circularity" is a concrete example of why gradual change is so hard, and why sometimes the only solution is to blow it up and start again.  That idea is scary to a lot of people, but it doesn't have to be.  I have an example that might help, the statistics curriculum at Olin.

Statistics at Olin

First I'll explain what worked, then we'll look at what could have gone wrong.

In 2010, I proposed a new class called Computational Probability and Statistics, as a substitute for a very conventional statistics class that was offered at the time.  My class was based on a library I developed while I was on sabbatical at Google, which is now the thinkstats module in ThinkX.

While teaching the class, I wrote Think Stats, which was published by O'Reilly Media in 2011. After a few semesters, I developed another course called Computational Bayesian Statistics, and wrote Think Bayes, which was published in 2013.

In 2014 I expanded CompProbStat from 2 credits to 4 and renamed it Data Science.  I recruited external collaborators to provide data and motivating questions for student projects, and several other professors sat in and helped guide student projects.  In 2016 one of those professors took over and taught his version of the class, adding his expertise in machine learning.

At the same time, two of my colleagues were developing their own statistics classes, focused on applications in diverse areas of engineering and science.   None of these classes look much like the conventional statistics material, and they are much better for it.

In six years, we developed five new classes, published two books, got six additional professors involved in teaching data science and statistics, and, most importantly, we developed a curriculum that serves the goals and needs of our students.

How did that happen?

This project would have been impossible at almost any other college.

At most colleges and universities, a professor of computer science (like me) who proposes a new statistics class will not get far, because of two fundamental and unquestioned assumptions of undergraduate education: (1) you need a Ph.D. in a topic before you can teach an introductory course, and (2) if you do research in a field, that makes you better at teaching it to undergraduates.  Note: neither of these is true.

And the content of my courses would have been scrutinized by a committee with a checklist.  To teach something new, you have to stop teaching something old, and it is nearly impossible to get permission to stop teaching anything.  Every topic, no matter how obsolete, is defended by zealots with no respect for evidence or reason.   Fun example: here are Time magazine's Five Reasons Kids Should Still Learn Cursive Writing.  Note: none of them are good.

Every field has its obstructionists, but statistics has its own special kind: the anti-Bayesians.  I can only imagine the howls if I proposed teaching Bayesian statistics to undergraduates.  When I suggested teaching it before classical statistics, I would have been thrown out a window.  And when I proposed to teach it instead of classical statistics, I would have been dragged through the streets.

At Olin, fixing engineering education is our mission.  When someone proposes an experiment, we ask the right questions: Does it contribute to our mission by improving undergraduate education at Olin and other institutions?  Is it a reasonable risk?  And do we have the resources to do it?  If the answers are yes, we do it.  Note: if it's an unreasonable risk and we don't have the resources, sometimes we do it anyway.

The second reason my project would be impossible at most schools is that statistics is owned by the math or statistics department, and even though the faculty don't like teaching classes for non-majors, they get credit for providing "service classes" (a term I would like to ban), so they have an incentive to protect their territory.

And just as the math department would fight to keep me out, the computer science department would fight to keep me in.  If the CS department owns my "faculty line" (another term I would like to ban), they want me to teach CS classes.

At Olin, we have no departments.  We don't have to do this kind of bookkeeping, and that leaves us free to think about the students (remember them?) and design a curriculum that serves their needs.

The third reason my project wouldn't happen anywhere else is that I wouldn't do it anywhere else.  At most universities, there is no incentive to develop new classes; in fact, there is a strong disincentive.  If you try something new, you make enemies, because the new is an insult to the old.  If it doesn't work, you get punished, and even if it works, you get no reward.

The one factor that drives hiring and firing is research.  Even at liberal arts colleges that value good teaching, there is no expectation for innovation.  If you do a decent job of teaching the same two or three classes over and over, that's good enough.  At Olin, we are encouraged to take risks, supported while we work out the bugs, and rewarded for the effort.

Also, at most universities, there is no incentive to write textbooks.  They don't count as research and they don't count as teaching; the time you spend on a textbook is just time you didn't spend on research.  At Olin, we use broad categories to evaluate faculty work, and a successful textbook is valued because it benefits students (at Olin and other institutions) and contributes to our mission to change engineering education.

So blow it up

You don't get a lot of opportunities to blow it up and start again, but when you do, a lot of good things can happen.  It's not as scary as it sounds.

Also, there is nothing special about p = 0.05.

Wednesday, September 14, 2016

It's a small world, scale-free network after all

Real social networks generally have the properties of small world graphs (high clustering and low path lengths) and the characteristics of scale free networks (a heavy-tailed degree distribution).

The Watts-Strogatz (WS) network model has small world characteristics, but the degree distribution is roughly normal, very different from observed distributions.

The Barabasi-Albert (BA) model has low path lengths and a heavy-tailed degree distribution, but

  1. It has low clustering, and
  2. The degree distribution does not fit observed data well.

The Holmes-Kim (HK) model generates graphs with higher clustering, although still not as high as observed values. And the degree distribution is heavy tailed, but it still doesn't fit observed distributions well.

I propose a new model that generates graphs with

  1. Low path lenths,
  2. Clustering coefficients similar to the HK model (but still lower than observed values), and
  3. A degree distribution that fits observed data well.

I test the models with a relatively small dataset from SNAP.

The proposed model is based on a "friend of a friend" growth mechanism that is a plausible description of the way social networks actually grow. The implementation is simple, comparable to BA and HK in both lines of code and run time.

All the details are in this Jupyter notebook, but I summarize the primary results here.

Comparing the models

The Facebook dataset from SNAP contains 4039 nodes and 88234 edges.  The mean path length is 3.7 and the clustering coefficient is 0.6.

A WS model with the same number of nodes and edges, and with probability of rewiring, p=0.05, has mean path length 3.2 and clustering 0.62, so it clearly has the small world properties.  But the distribution of degree does not match the data at all:

A BA model with the same number of nodes and edges has very short paths (2.5), but very low clustering (0.04).  The degree distribution is a better match for the data:

If we plot CDFs on a log-log scale, the BA model matches the tail of the distribution reasonably well, but the WS model is hopeless.

But if we plot CDFs on a log-x scale, we see that the BA model does not match the rest of the distribution:

The HK model also has short path lengths (2.8), and the clustering is much better (0.23), but still not as high as in the data (0.6).  The degree distribution is pretty much the same as in the BA model.

The FOF model

The generative model I propose is called FOF for "friends of friends". It is similar to both BA and HK, but it yields a degree distribution that matches observed data better.

It starts with a complete graph with m nodes, so initially all nodes have degree m. Each time we generate a node we:

  1. Select a random target uniformly from existing nodes.
  2. Iterate through the friends of the target. For each one, with probability p, we form a triangle that includes the source, friend, and a random friend of friend.
  3. Finally, we connect the source and target.

Because we choose friends of the target, this process has preferential attachment, but it does not yield a power law tail. Rather, the degree distribution is approximately lognormal with median degree m.
Because this process forms triangles, it yields a moderately high clustering coefficient.

A FOF graph with the same number of nodes and edges as the Facebook data has low path length (3.0) and moderate clustering (0.24, which is more than BA, comparable to HK, but still less than the observed value, 0.6).

The degree distribution is a reasonable match for the tail of the observed distribution:

And a good match for the rest of the distribution

In summary, the FOF model has

  • Short path lengths, like WS, BA, and HK.
  • Moderate clustering, similar to HK, less than WS, and higher than BA.
  • Good fit to the tail of the degree distribution, like BA and HK.
  • Good fit to the rest of the degree distribution, unlike WS, BA, and HK.

Also, the mechanism of growth is plausible: when a person joins the network, they connect to a randomly-chosen friend and then a random subset of "friends of friends". This process has preferential attachment because friends of friends are more likely to have high degree (see The Inspection Paradox is Everywhere) But the resulting distribution is approximately lognormal, which is heavy tailed, but does not have a power law tail.


Here is a function that generates FOF graphs:

def fof_graph(n, m, p=0.25, seed=None):
    if m < 1 or  m+1 >= n:
        raise nx.NetworkXError()
    if seed is not None:

    # start with a completely connected core
    G = nx.complete_graph(m+1)

    for source in range(len(G), n):
        # choose a random node
        target = random.choice(G.nodes())
        # enumerate neighbors of target and add triangles
        friends = G.neighbors(target)
        k = len(friends)
        for friend in friends:
            if flip(p):
                triangle(G, source, friend)

        # connect source and target
        G.add_edge(source, target)
    return G

def flip(p):
    return random.random() < p

def triangle(G, source, friend):
    """Chooses a random neighbor of `friend` and makes a triangle.
    Triangle connects `source`, `friend`, and 
    random neighbor of `friend`.
    fof = set(G[friend])
    if source in G:
        fof -= set(G[source])
    if fof:
        w = random.choice(list(fof))
        G.add_edge(source, w)
    G.add_edge(source, friend)

Again, all the details are in this Jupyter notebook.