Tag: data

  • Part 3: Who’s Talking About The Future Of Newspapers?

    Continued on from Part 2, I’m representing similar data in a different (less exciting) way.

    Before, we looked at how the activity on the twitter streams was spread out over the day and by different types of interaction. Here, I’m using charts to show the breakdown for the day, by user. I’ve also created charts for each type – these are too busy to show much more than users who are way above average in a particular tweet type.

    Like last time, something is either:

    • Directed
    • Not directed, but containing a mention
    • Contains a link, not an @ mention
    • None of the above.

    I’m using the existing code I’ve built up – Apache POI to import and some custom data-structures.

  • Part 2: Who’s Talking About the Future of Newspapers?

    After breaking down the overall types of tweets from people, next step was to create scatter plots of their activity.

    Unfortunately, Excel will only plot 250 data points – how unreasonable! Luckily I love breaking Excel and coding something that will do what I want it to do and look prettier, so voila.

    Color scheme:

    1. Is directed at someone by starting with an @
    2. Contains a mention (@) of someone else
    3. Contains a link

    Otherwise, the point for that tweet is light gray. Note this is done in the order above, so if 1 is true, then it doesn’t matter if both 2 and 3 are true or false – the tweet will be pink. If 2 is true, the tweet may or may not contain a link – it will still be purple.

    I used the Processing core.jar library within Eclipse, along with the data-structures I created originally and the Apache POI code for extracting the data from Excel.

    I’m enclosing the code below, with some comments:

    • This code will not compile even with the Processing core.jar library (requires data-structure code that I have not yet released).
    • There is a horrible hack for calculating the time passed since original date – if you’re doing anything more with time consider Joda Time instead.
    • The code is written to visualize this data and only this data. Whilst I may create a proper ScatterPlot class for Processing at some point, I’ll probably wait until Java 7 because without lambda functions it will require either a standard data format, or some kind of interface hack to create an adapter pattern. I don’t like either of these approaches.
    • Aside from this, if you have some other use for it feel free to ping me with questions!
    package com.catehuston.caitlin.viz;
    
    import java.io.IOException;
    import java.util.Calendar;
    import java.util.Date;
    
    import com.catehuston.caitlin.datastructures.Tweet;
    import com.catehuston.caitlin.datastructures.User;
    import com.catehuston.caitlin.parse.UserList;
    
    import processing.core.PApplet;
    
    @SuppressWarnings("serial")
    public class Scatterplot extends PApplet {
    
    	private static final int w = 1260; // 1160 for graph
    	private static final int h = 600; // 480 for graph
    
    	// spacing at either side
    	private static final int xmargin = 70;
    	private static final int ymargin = 60;
    
    	// axis length
    	private static final int xlen = w-(xmargin*2);
    	private static final int ylen = h-(ymargin*2);
    
    	// increments for day, hour, minute
    	private static final int di = xlen/58;
    	private static final int hi = ylen/24;
    	private static final double mi = hi/60d;
    
    	// user we're graphing
    	private int index = 5;
    	private User user;
    
    	// calendar for date comparison
    	Calendar startDate;
    
    	public void setup() {
    		UserList ul;
    		try {
    			// generate user list from spreadsheet
    			ul = new UserList("../data/data_june16_top20.xls");
    		} catch (IOException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    			return;
    		}
    
    		// get data just for the user we're interested in
    		user = ul.get(index);
    
    		// set applet size
    		size(w, h);
    
    		// draw() method will be called only once
    		noLoop();
    
    		// set up calendar with base date
    		startDate = Calendar.getInstance();
    		startDate.set(Calendar.YEAR, 2010);
    		startDate.set(Calendar.MONTH, Calendar.FEBRUARY);
    		startDate.set(Calendar.DAY_OF_MONTH, 1);
    		startDate.set(Calendar.HOUR_OF_DAY, 0);
    		startDate.set(Calendar.MINUTE, 0);
    	}
    
    	public void draw() {
    		// set background color - dark grey
    		background(64);
    
    		// set foreground color for text and axes - light grey
    		stroke(238);
    		fill(238);
    
    		// draw user name string top left
    		text(user.getUser(), 5, 15);
    
    		// draw x-axis
    		int ypos = ylen+ymargin;
    		line(xmargin, ypos, xmargin + xlen, ypos);
    		// add major markers
    
    		// initial
    		line(xmargin, ypos, xmargin, ypos+5);
    		text("Feb 1, 2010", xmargin, ypos+20);
    
    		// mid-feb
    		int inc = 13*di;
    		line(xmargin + inc, ypos, xmargin + inc, ypos+5);
    		text("Feb 14, 2010", xmargin + inc, ypos+20);
    
    		// start of march
    		inc = 28*di;
    		line(xmargin + inc, ypos, xmargin + inc, ypos+5);
    		text("Mar 1, 2010", xmargin + inc, ypos+20);
    
    		// mid march
    		inc = inc + 14*di;
    		line(xmargin + inc, ypos, xmargin + inc, ypos+5);
    		text("Mar 15, 2010", xmargin + inc, ypos+20);
    
    		// end of march
    		inc = 58*di;
    		line(xmargin + inc, ypos, xmargin + inc, ypos+5);
    		text("Mar 31, 2010", xmargin + inc - 60, ypos+20);
    
    		// draw y-axis
    		line(xmargin, ymargin, xmargin, ypos);
    		// add markers
    		for (int i = 0; i < 2401; i+=200) {
    			inc = i/100*hi;
    			ypos = ymargin + ylen - inc;
    			line(xmargin-5, ypos, xmargin, ypos);
    			String hrs = i + "h";
    			if (i == 0) {
    				hrs = "0000h";
    			}
    			else if (i < 1000) {
    				hrs = "0" + hrs;
    			}
    			text(hrs, xmargin-50, ypos+10);
    		}
    
    		// go through and plot points, color according to type
    		for (Tweet t : user.getTweets()) {
    			// set color according to tweet type
    			// @ message
    			if (t.isDirected()) {
    				// pink
    				stroke(236, 0, 128);
    				fill(236, 0, 128);
    			}
    			// someone else is mentioned
    			else if (t.isMention()) {
    				// purple
    				stroke(140, 9, 214);
    				fill(140, 9, 214);
    			}
    			// contains link
    			else if (t.hasLink()){
    				// yellow
    				stroke(255, 126, 0);
    				fill(255, 126, 0);
    			}
    			// otherwise
    			else {
    				stroke(238);
    				fill(238);
    			}
    
    			Date d = t.getDate();
    			int x = getXPos(d);
    			int y = getYPos(d);
    			ellipse(x, y, 3, 3);
    		}
    	}
    
    	private int getXPos(Date date) {
    		// make calendar with specified date
    		Calendar newDate = Calendar.getInstance();
    		newDate.setTime(date);
    
    		// count how many days we go back to find start date
    		int count = -1;
    		while(startDate.before(newDate)) {
    			count++;
    			newDate.add(Calendar.DATE, -1);
    		}
    
    		return xmargin + count * di;
    	}
    
    	private int getYPos(Date date) {
    		// put date in calendar so we can manipulate it
    		Calendar time = Calendar.getInstance();
    		time.setTime(date);
    
    		// work out hour increment
    		int hrs = time.get(Calendar.HOUR_OF_DAY) * hi;
    		// wor out minute increment
    		double mins = time.get(Calendar.MINUTE) * mi;
    
    		// return y value
    		return (int) (ylen + ymargin - hrs - mins);
    	}
    }
    
  • My Journal is Online

    WTJ 94 - Write a list of more ways to wreck this journal
    Credit: flickr / isazappy

    Now that my iPhone is unlocked (yay!) and has a data plan, I can play Foursquare. Which is exciting for me, but I know some people hate it and my boyfriend has been getting all angsty about giving up my privacy for nothing.

    The thing is though, I love tracking things. I track the applications I use, and the music I listen to. I track random things on Mycrocosm. I track my todo list through Remember the Milk and my goals page and I use various applications for tracking how I’m doing on Twitter (am I tweeting too much? Tweeting stuff that’s interesting?). I track my blog stats through Google Analytics which means I can say that when I added related posts to my blog, my bounce rate went down. I’m a bit of a data junkie, I guess. But that is probably fitting considering that to describe what I like to work on I’ve taken to saying, “I take data and try and present and organize it in a way such that I can answer questions that you didn’t think to ask.”

    Not everyone is interested in doing this, of course. But I’ve been thinking about why I like to document my life and track it online like this and I have an answer. And no, it’s not that I’m self-obsessed and want everyone to know exactly what I’m doing, all the goddamn time. It’s my way of keeping a journal – the journal I tried to keep at numerous points growing up, but never had the dedication to stick with. It’s easier! I track my music and application use just by running stuff in the background. My task lists are a little more arduous to maintain, but they can be updated anywhere and the payoff in terms of organization is well worth the time. Twitter allows me to keep track of funny or useful articles I find online and document the highlights of my days in snippets, now I archive my tweets into weekly blogposts for easier searching. My blog is a history of things I’ve thought about and worked on, it documents my ideas and is search-able, and sometimes I find things in the related posts section that I’ve forgotten I wrote.

    Now with Foursquare, I can keep track of where I’ve been. And I get that it’s annoying when your every check-in gets posted to your Twitter or Facebook stream, so I don’t do that. Currently it’s set to post only badges and mayorships, but I’ll turn that off if they’re frequent occurrences. Here’s what I’m getting out of it:

    Ambient Awareness

    I’m a big fan of this idea, I like the ease of keeping track of people and staying in touch this way, rather than the long “this is everything I’ve done in the last month” emails. And I suck at writing emails anyway (working on replying, I’m getting better at it), so nobody gets those from me. This makes it all the more useful to have places where people who are interested in what I’m up to but can’t be bothered to write the email and wait for the response can keep up with me, and hopefully I can keep up with them in return. If you’re not that person and my content is boring, I’m sorry – but it’s not meant for you. I tend to use Facebook for this, because it’s closed and I tend to limit it to people I know, but I think Foursquare can potentially be nice for that too.

    Serendipitous Meetings

    OK, this hasn’t happened yet but I hope it will. If I’m in Starbucks and you’re nearby and fancy a coffee then maybe you’ll come by and hang out. That’s kinda cool! And the other day when I was meeting friends at a restaurant, I knew one of them was there because his Foursquare check-in popped up on my phone. That’s potentially useful, too.

    Competition

    I really want to be Mayor of where I kickbox. Perhaps some people might find that a little sad, but if it gets me training more isn’t that a good thing? Competition encourages me to get out there, and visit new places. It’s pretty cold in Ottawa right now – the more motivation to get out and about, the better.

    How about you? Do you think Foursquare and services like that are stupid, or do you use them? And if so, why – what do you get out of it?

  • Tracking Things

    For a while now, I’ve been tracking something I’m describing “day in one word” on Mycrocosm. Thing is, by the end of each day I’m judging myself harshly and finding myself inadequate so looking at the data it seems I’m pretty miserable – and yet I think I’m fairly happy. After a good sleep, I wake up eager to do it again.

    So now I’m tracking “morning mood” too. And, as I’m finally able to exercise (kinda) as my knee is a lot better I’m tracking that as well. I’m really out of the habit, so hopefully the shame of having to write “none” will get me into the pool!

    All my datasets are here.

  • Information -> Data -> Meaning

    Clay Shirky wrote about this in Here Comes Everybody; the arrival of the printing press and how it changed everything. To summarize: when the printing press was invented the Church flipped out because they realized that they would no longer be in control of the information (namely, the Bible) that people had available to them. And they complained that this would lead to the death of scribes, which of course it did, and various other things. However to alert people to how terrible the printing press was as an invention, they had to use a printing press. Becaue scribes couldn’t produce enough copies at a fast enough pace.

    Of course the Church lost that battle, and the number of different books rapidly increased.

    So not that long ago, humans had very little information – the Bible was their primary source, and it was read to them and interpreted for them, and they had few other options other than to follow it blindly. Then we had the printing press, and there were books and the number of books grew rapidly until it was soon more than any person could read in a lifetime. And now, we have the internet and every day more content is produced and we have no hope keeping up with it all.

    It’s amazing, how we can go from a place of so little information to too much. But here’s where I think we’ll go next – we’ll be able to manage this information because computers will get better at harvesting it, and it’ll become easier and easier to visualize it using tools like Wordles (nice example here) and mashups (Google’s medal mashup from the 2008 Olympics is a nice example). In fact, visualizing this data can be an Installation, as in I Want You To Want Me.

    Smashing Magazine has a list of resources for Data Visualization and Infographics here. The more mainstream it gets, the better we’ll be able to manage all this information and pull the important points from it. In fact, we don’t even have to be able to visualize it! For instance, TweetMeme and TechMeme keep track of what links are being shared a lot on Twitter and deliver them right to your Twitter or RSS feed. So I don’t have to try and see everything that’s shared on Twitter, I can just keep track of what’s popular – much more achievable!

    At the moment I’m working on Visualizing something that I think will show something interesting… more soon!