Wiki
Social Graphs and Interactions

Lecture 1
Page last edited by Sune Lehmann Jørgensen (sljo) 22/08-2014

We will work on the exercises below during the first lecture. If you want to prepare for the class, make sure you Python programming skills are up to date.

 

Goals

  • Get your system in shape for hacking
  • Read about basics of Twitter
  • Familiarize (or re-familiarize) yourself with Python
  • Get excited about the class

Reading

  • MTSW Appendix A, Appendix C, and Chapter 1.

Exercises

[A note on the exercises.] The class will be graded according to your performance on the exercises. Every few weeks, selected exercises from the previous weeks will be collected in "Assignments" to be handed in. Thus, if you work on the exercises from week to week, you will have an easy time when the assignments are due (and you will be getting good grades in the class).

 

1) Twitter A. Start a Twitter account and follow @suneman, @sapiezynski, and @utdiscant . Work on getting as many followers as you can. Which strategies did you employ to gain followers? Post at least one tweet that includes the hashtag "#02805signup".

 

2) Set up your system.  Start by watching the 3 intro videos on http://vimeo.com/channels/miningthesocialweb/72709114

  • Follow the instructions in Appendix A (and the first Video) to set up the virtual machine on your system. Make sure that you can edit the ipython notebooks (as explained in the second video). See also the written instructions at github here.
  • Do you understand what's going on in the third video? What is SSH? What is bash? Can you run IPython notebooks after typing "vagrant suspend" at the terminal? Why not?

 

3) Python. It's a prerequisite to the course that you know how to program - but what about Python? Some basic Python concepts are explained in Appendix C of MTSW, but that might be too difficult still. Going over the following exercises will help you feel more comfortable in a new environment.  Write an iPython Notebook (or a script) that does the following:

  • Create a list a that contains the numbers from 1 to 1110, incremented by one, using the range function.
  • Show that you understand slicing in Python by extracting a list b with the numbers from 543 to 779 from the list created above.
  • Using def, define a function that takes as input a number x and outputs the number multiplied by itself plus three f(x) = x(x+3). Apply this function to every element of the list b using a for loop. Do the same thing using a list comprehension.
  • Write the output of your function to a text file with one number per line.
  • Show that you know about strings typing and understanding everything in the example in http://learnpythonthehardway.org/book/ex6.html If you feel this is too complex, try completing exercises 0-5 first. 
  • Learn about JSON by reading the wikipedia page. Why is json superior to xml? (... or why not?)
  • Use the json module (http://docs.python.org/library/json.html). First use urllib2 (http://docs.python.org/howto/urllib2.html) to download this file, then load the json as a python object and use pprint to make it look good when written to the terminal.
  • Skim through MTSW's Appendix C. You don't have to understand everything, but tinker around a a bit so you know what's there so you can find the relevant sections when you need them.

[IMPORTANT] Experience shows that some of you will find Python difficult . If that's the case, you will need to learn how to code in Python - this is essential to succeed in the course. And the sooner you get started, the better your chances of getting on to of this will be. I recommend two options.

A) Either complete all of CodeAcademy's excellent classes (1-21). Recommended option if you feel like a total beginner.

B) Work throuth Exercise 1-40 of http://learnpythonthehardway.org/book/. This option is better if you know a bit about programming but not about Python.

 

4) Context. Read the preface to MTSW. This is important - it explains how the book works.

  • What is Github? How do you use it to work with the examples in this book?
  • What is an IPython notebook? Describe in your own words.

 

5) Twitter B. Read about twitter, learn how to get data via the API (and get some yourself) by working through the text and exampels in chapter 1.

  • According to MTSW, how many users does Twitter have? And how many actively engage with the platform?
  • How is twitter different from Facebook in terms of how people connect to each other?
  • Create your own twitter application and get OAuth credentials as described.
  • Work through examples 1-1 to 1-4
  • What are today's Stockholm trends?
Support: +45 45 25 74 43