Buenos Aires bicycle lanes: Let’s go for a ride together

Billy Mosse
Towards Data Science
4 min readJun 28, 2019

--

Riding a bike in BA. Isn’t the Women’s Bridge beautiful?

Who doesn’t like a good bicycle ride in the park? Buenos Aires people (“porteños”, a word which refers to our port), apparently love it.

In this article we will resume some analyses done with the goal of identifying and understanding social patterns hidden in Buenos Aires Ecobicis open data.

This dataset provides both geolocalization of bicycles stations and data points regarding:

  • Who (anonymized, of course) took a bicycle.
  • Where did they took it from, and where they left it.
  • At exactly what time.
  • Full duration of the trip.

My good friend Fede Catalano talked quite a bit about the characteristics of this dataset here, and presented some nice statistical distributions. It’s in Spanish, but you don’t need to know the language to enjoy the beautiful plots.

He focused on people going and returning from work. We are going to analyze some social clusters hidden in the data. That is, we are going to try detecting groups of people using the bicycles together.

With that goal in mind, we should restrict the data to events where the person returned the bicycle to the same station they took it from. By this, we clean the data and only consider events related to people using bicycles just for going to a ride.

Going for a ride alone is fun, but I also like it a lot when friends come with me. To check if the other porteños agree with me, we built a graph where two users shared a link if and only if at least one of them had taken a bicycle at approximately the same time from the same station, and returned them together (also to the same station).

5% of events were of people returning the bicycle to the same spot they had taken it from. Of those events. 90% were people going alone. But the other 10% involved people going together. And, from those, patterns started to emerge.

The network has a power-law degree distribution, like most real-world networks have.

The person with 15 different friends to go for a ride with must be having a great time!

We can also check how people’s ages relate to friendship. It turns out, unsurprisingly, that people of the same age are more likely to hang out together:

Heat map for relations based on age and gender.

Maybe you were expecting to see families, but unfortunately it’s hard for kids to create a user for this service. In our experiment, the youngest person was 15.

What we can observe from the graph is a strong pattern of male-female relationships above 40, somethings that same-relationship friendships lack. Maybe, as heterosexual sexual relationships are statistically more abundant than the rest, what we are watching is married couples having fun together? I bet we are!

Communities

If we divide the network in its connected components, it turns out — as you might suspect — that lots of people just go out in pairs, but there are lots of groups, too! We found 300 groups with 5+ people. The size distribution of the connected components also follows a power law, with the biggest group being an outlier of size 195. Here it is:

Bicycle users and friendships.
  • Node color equals gender, with red being female and blue being male.
  • Node size is proportional to age.
  • Edge width is proportional to amount of travels shared.

Check out my notebook (coming soon) for other groups. OK, one more:

That pair are really good friends!

However, connected components are not a good way of detecting communities (maybe I’ll talk more about that in another post).

One good method of detecting communities is the Louvain algorithm. For this project, we used a simple and effective Python implementation. Here are the results — one can imagine the flocks of cyclists enjoying their free time all over Buenos Aires:

Cyclists’ communities — social interaction is everywhere

How are these communities geographically distributed? How do they evolve through time? More to come in new posts.

Addendum

One last thing. Federico is a social scientist and I am a mathematician. However, for this project, we exchanged hats. As you can see, he dealt with most of the numerical analysis of the dataset — he’s awesome at that — and I dealt with the hidden social patterns.

Never be afraid of changing hats and just going for a ride.

Credit: gastonroel

--

--

Mathematician. Data Scientist at fromAtoB. Machine Learning freelancer. Expat. I like bots.