To demonstrate a new way of digital content consumption. The idea is to use people’s personal data to expose them to newer, “out of bubble” content, rather than serving personalized content. The approach is based on k-nearest neighbors classification algorithm. A user would get content based on the preferences of nearest k neighbors.
Daniel Shiffman’s KNN example:
On this canvas, there are three kinds of nodes, each has its own color and position. The color of all the other pixels is determined by which node is nearest to it. The first thought that came to my mind after looking at this was that this looks like a good way to draw congressional districts. This got me thinking of the canvas as a physical space and nodes as people with their preferences/thoughts etc. Each person influences the physical space she occupies and as people move in and out of these physical spaces they influence each other by their mere presence.
Although I am looking at this not as one application but as a way to organize any sort of application, I decided to make a quick music platform that works on this principle. Technically this is how the product will work:
- Each new user will answer a simple question about their preference in music. This simple “personal data” will be attached to the user as a proxy to all sorts of complex data that can be obtained by their social media accounts. Right now to keep things simple I will not make a permanent profile of any user, a temporary session ID will be enough to keep track of the single music preference data point generated above.
- Geolocation of every user will be monitored continuously.
- User will listen to music based on preference of their “k” nearest neighbors.
- The value of “k” is customizable.
- A web application that works on phone as well as desktop will be best to demonstrate this.
The end experience of the demo should be that music on my application should change in real time as I move around a space will lots of active users.
A working prototype of the above demo can be accessed here:
The idea of the project is to create a new system of content delivery. Re-use is highly encouraged. I am using node.js, socket.io, express and jQuery.
This project was much more challenging technically than I initially estimated. Following are the two main learnings:
- Web sockets are a must for such a project. I tried building this with a simple server and it just does not work. My initial idea was to use GET and POST requests to maintain geolocations of all users in a database. The delay was too much and it was very difficult to keep track of the active users. There are many ways in which a user can become inactive, for example closing the browser, closing the tab, refreshing the page etc. I was not practical to write events of all use cases. Web sockets solve all that. No GET/POST, no delays and fool-proof way to note active users.
- I tried using “watchPosition” callback on navigator.geolocation to monitor change in geolocation but it was just not working. I don’t know the reason yet but many people are disappointed with this unpredictable nature of watchPosition. Like this Facebook thread here. I ended up using setInterval to constantly query the user’s location.
- webm format does not work with safari. I spent hours on this one, changing the file paths, audio tag, play/pause feature. One of the most frustrating bugs to resolve.
- I am not sure about using geolocations to monitor positions of users because my users will preferably be close together. I doubt if there are better ways for this.