Omniscope Custom Blocks › Analytics/Network-Analysis/TSNE

TSNE

Places the nodes of a network on a 2-D (or 1-D or 3-D) map with t-SNE, so that nodes connected to the same other nodes end up close together and nodes with different connections far apart. Input: one record per connection.

Analytics › Network Analysis R

Open the demo in Omniscope Download demo.ioz Sample data: email-network.csv Source on GitHub

Omniscope custom block · Analytics · Network Analysis

Turn a list of who-contacts-whom into a map where each node sits next to the nodes it shares connections with, as two ordinary fields you can plot, filter and join.

R · Rtsne, data.table · install both on the server's R if missing

The problem it solves

An organisation has a quarter's e-mail log: who wrote to whom, and how often. It wants to see how people actually group together, which may or may not follow the org chart. A drawing of 60 people and 380 links is a tangle; a table of counts is unreadable.

The block describes each person by whom they exchange e-mails with, and places people with similar contacts near each other. Groups of people who work together show up as clusters of points, with no team information given to the block.

How it works

What goes in

E-mail network

380 invented records: a sender, a recipient and the number of e-mails between them in the quarter, for 60 staff.

From To Emails
Fin-01 Fin-04 10
Fin-01 Fin-05 12
Fin-01 Fin-18 13
Fin-01 Fin-08 11

380 rows in the sample file; one has no count and is left out. The names start with the team (Fin, Log, Pro) so the result is easy to check; the block does not use that.

The options

Option Demo setting What it does
From field From One end of each connection.
To field To The other end.
Weight field Emails How strong each connection is.
Number of output dimensions 2 Two coordinates per person.
PCA dimensions 25 Detail kept before t-SNE.
Perplexity 15 Roughly how many neighbours each person takes into account.

What comes out

Map (first 6)

Node Dimension 1 Dimension 2 Connections
Fin-01 -2.109124 6.812777 10
Fin-04 2.289994 6.804985 12
Fin-05 2.650993 5.171562 12
Fin-18 0.783911 4.649844 10
Fin-08 1.285056 5.279385 11
Pro-10 -6.351652 -1.228815 14

Where the teams land

Team (from the names) Dimension 1 range Dimension 2 range
Finance -2.1 to 2.7 4.6 to 8.7
Logistics 2.4 to 8.3 -6.4 to -1.2
Product -9.6 to -3.3 -3.6 to 1.2

Three clusters that do not overlap. Connections (8 to 19 per person) can size the points, so the busiest people, such as Pro-09 with 19, stand out.

Where it pays off

Organisations: How people really work together

From e-mail, chat or meeting records, see the working groups that exist in practice, and who sits between them.

Retail: Customers and products

From purchases (customer to product), customers who buy the same things land together, and so do products bought by the same customers.

Web and content: Pages and links

From page-to-page links or co-visits, see which pages form natural sections of a site.

Research: Citation and collaboration networks

From co-authorship or citation records, see the communities in a field.

Use cases describe typical scenarios and are illustrative; the sample data is invented.

Why do this in Omniscope

How it fits into an Omniscope workflow

E-mail log (Database) → Aggregate (From, To: count) → TSNE → Join (staff list: team, office) → Report (scatter of Dimension 1 by Dimension 2, coloured by team)

If the source has one record per message, aggregate it to one record per pair with a count first, or feed it as it is: repeated pairs are added up either way.

Try it

  1. Open the demo project (demo.iox on the demo server, or import demo.ioz from this folder): 380 invented e-mail counts between 60 staff.
  2. The question: which groups of people work together?
  3. Open TSNE: From field From, To field To, Weight field Emails, the other options at their defaults. Run it.
  4. Look at the output: 60 records, one per person. In a scatter chart of Dimension 1 against Dimension 2, three separate clusters appear.
  5. Colour the points by the first three letters of Node (Fin, Log, Pro): each cluster is one team.

Running in Omniscope

Omniscope workflow
Omniscope workflow

The demo project's workflow: the sample data, the block, and a Validate data check on its output.

Language and libraries

R. It uses the Rtsne package (BSD 3-Clause; the Barnes-Hut t-SNE code it wraps is under a BSD licence with an advertising clause) for t-SNE, and data.table (MPL-2.0).

Neither is part of base R: install them on the Omniscope server's R if they are missing (install.packages(c("Rtsne", "data.table"))).

Tested

The block is covered by automated tests that run its script against a stand-in for Omniscope's R API: the sample data (every person next to their own team), repeated runs, nodes that only receive connections, repeated connections, numeric node IDs, no weight, one to three dimensions, an empty Weight option, empty input, bad options and inputs (perplexity too large, too many dimensions, text or negative weights, missing choices and fields), and 1,000 nodes.

Reference

Fields it reads

NameTypeWhat it does
From fieldFieldOne end of each connection (for example the sender).
To fieldFieldThe other end of each connection (for example the recipient). Connections count in both directions.
Weight fieldFieldOptional numeric field: how strong each connection is (for example a number of messages). Repeated connections between the same two nodes are added up. Without it every connection counts 1.

Options

NameTypeWhat it does
Number of output dimensionsWhole numberHow many coordinates each node gets: 2 for a scatter chart, 1 for an ordering, 3 for a 3-D view.
PCA dimensionsWhole numberBefore t-SNE, each node's connection profile is reduced to this many dimensions with principal component analysis. More keeps more detail but is slower.
PerplexityWhole numberRoughly how many neighbours each node takes into account. Lower values bring out small, local groups; higher values the overall structure. Must be at most (number of nodes - 1) / 3.

Outputs

OutputWhat it holds
MapOne record per node: Node, Dimension 1, Dimension 2 (and 3) and Connections (the number of connection records it is part of).