d3_tutorials



d3_tutorials

0 0


d3_tutorials

intro(s) to d3 that are tied to my work in the data science field.

On Github blehman / d3_tutorials

D3 + DS:

A Data Visualization Workshop

#BoulderD3

Thursday, December 4th

5:00pm - 7:00pm

Flemming Building - Idea Forge Active Learning Classroom

Twitter Data Science

@BrianLehman

I work with data; specifically data from Tweets. What's in a tweet? Well, while people are still getting settled, I'm going to let a duo explain the a common element in a tweet body known as the hashtag.

One Tweet

What data is under the covers of a single Tweet?

One Tweet

{"id":"tag:search.twitter.com,2005:535907063617294337","objectType":"activity","actor":{"objectType":"person","id":"id:twitter.com:23085343","link":"http://www.twitter.com/SteveHult","displayName":"Steve Hult","postedTime":"2009-03-06T16:41:03.000Z","image":"https://pbs.twimg.com/profile_images/502088751820984320/kizmrvpm_normal.jpeg","summary":"Jersey-native in Colorado, NYU Alum. Fishing, Snowboarding. Data @twitter","links":[{"href":"http://stevehult.com","rel":"me"}],"friendsCount":852,"followersCount":655,"listedCount":18,"statusesCount":2176,"twitterTimeZone":"Mountain Time (US & Canada)","verified":false,"utcOffset":"-25200","preferredUsername":"SteveHult","languages":["en"],"favoritesCount":449},"verb":"post","postedTime":"2014-11-21T21:26:15.000Z","generator":{"displayName":"Vine - Make a Scene","link":"http://vine.co"},"provider":{"objectType":"service","displayName":"Twitter","link":"http://www.twitter.com"},"link":"http://twitter.com/SteveHult/statuses/535907063617294337","body":"This is how @twitter #datascience rolls... Handstand push-ups after every meeting w/ @drskippy https://t.co/dzxkz54XTS","object":{"objectType":"note","id":"object:search.twitter.com,2005:535907063617294337","summary":"This is how @twitter #datascience rolls... Handstand push-ups after every meeting w/ @drskippy https://t.co/dzxkz54XTS","link":"http://twitter.com/SteveHult/statuses/535907063617294337","postedTime":"2014-11-21T21:26:15.000Z"},"favoritesCount":0,"twitter_entities":{"hashtags":[{"text":"datascience","indices":[21,33]}],"trends":[],"urls":[{"url":"https://t.co/dzxkz54XTS","expanded_url":"https://vine.co/v/OJxPvxpwaJY","display_url":"vine.co/v/OJxPvxpwaJY","indices":[95,118]}],"user_mentions":[{"screen_name":"twitter","name":"Twitter","id":783214,"id_str":"783214","indices":[12,20]},{"screen_name":"DrSkippy","name":"Scott Hendrickson","id":14304173,"id_str":"14304173","indices":[85,94]}],"symbols":[]},"twitter_filter_level":"medium","twitter_lang":"en","retweetCount":0,"gnip":{"matching_rules":[{"value":"from:SteveHult","tag":null}],"urls":[{"url":"https://t.co/dzxkz54XTS","expanded_url":"https://vine.co/v/OJxPvxpwaJY","expanded_status":200}],"language":{"value":"en"}}} 
What

Using Data

One way to expose meaning in data is to visualize it. How do we do this? What are phases of data visualization?

1 2 3 4 5

Visualization is Iterative

explore. zoom. repeat.

Why D3?

Allows for quick iteration efficient DOM manipulation (based on data) Data Drive Documents Opensource javascript library (web browser friendly) "D3 helps you bring data to life using HTML, SVG and CSS." _We'll take data, bind it to html elements, and then create a D3 visualization. 1st, we need to learn a little html.

HTML Basics for D3

Access the D3 library. Add/remove elements. Change elements' attributes. Modify elements with CSS styling.

please use a Chrome browser: bit.ly/practiceD3

We learned the basics so we can explore this month's worth of Tweets about Ebola.

Sample Data

One month of Tweets about Ebola

Total Tweets: 2,856,548

Sample size: 1,000

Relevant information parsed into csv

timeStamp,displayName,followersCount,followingCount,listedCount,statusesCount,activityType,tweetID
2014-10-01T00:18:44.000Z,influenza_bio,1403,732,64,9278,Retweet,5171063015001415682014-10-01T00:46:20.000Z,New_Narrative,2103,64,140,81521,Tweet,5171132498009415682014-10-01T01:14:06.000Z,FroJr18,204,178,0,1226,Reply,5170562005049303042014-10-01T01:22:44.000Z,drewspantry,307,332,2,4695,Retweet,5171224092968386562014-10-01T01:26:06.000Z,mjrivera07,264,250,1,14577,Retweet,5171232553005342732014-10-01T02:01:57.000Z,Mr_BuddyLee,566,552,14,28740,Retweet,5171322755791257602014-10-01T02:06:37.000Z,wcollier33,494,1337,4,10545,Retweet,5171334499842375682014-10-01T02:39:37.000Z,ajones139,292,243,1,18057,Retweet,5171417555366215682014-10-01T02:54:04.000Z,BURNS_calories,319,266,2,5436,Retweet,517145394942590976...

Keep exploring this question: what stories can we find in this data? We start with a story about Follower vs Following counts.

EBOLA

LIVE D3

bit.ly/d3scatterplot_v0

Teamwork Outcome #1

(5 minutes)

Describe - list the facts. Analyze - develop interpretations. Judgement - build questions and create ideas for iterations.

LIVE D3

bit.ly/d3legend_scafolding

Teamwork Outcome #2

(15 minutes)

Learn how to build a legend

LIVE D3

bit.ly/d3event_scaffolding

Teamwork Outcome #3

(20 minutes)

Learn how to handle a click event.

Twitter User Analysis

LIVE D3

bit.ly/scatterplot_v1

Teamwork Outcome #4

(15 minutes)

Put your new learning to practice: iterate on the "final" design.

Thanks!

Twitter Data Science

@BrianLehman

Any questions?