Skip to content

Instantly share code, notes, and snippets.

@elcinerkin
Forked from gromajus/food_recommendation_system.adoc
Last active October 21, 2015 08:33
Show Gist options
  • Save elcinerkin/ab259f78e0b4f1a01e38 to your computer and use it in GitHub Desktop.
Save elcinerkin/ab259f78e0b4f1a01e38 to your computer and use it in GitHub Desktop.
Location based meet-up recommendations for like minded people on Twitter

Location based meet-up recommendations for like minded people on Twitter

Inspiration

For avid users of Twitter, meeting individuals that has common Twitter friends (people you follow), and that you actually haven’t met in person, can be good opportunity to spend quality time. We are working on an app that makes friend recommendations to app users, based on their current locations and common friends.

Team

This app is being build by a team of three aspiring software engineers, as a part of their Hack Reactor short project curriculum. Team members are Aaron Rice (email:[email protected]), Marco Au (email:[email protected]), and Elcin Erkin (email:[email protected])

Data Model

Tweet Up

The data model consists of two domains:

  • Person (attributes: name, screen_name, description, etc..) e.g. ElcinErkin, 'Elcin Erkin', etc..

  • Location (attributes: name) e.g. San Francisco (The location property will be obtained by app user’s current gps coordinates).

The following facts can be observed:

  • Person FOLLOWS another Person, e.g. ElcinErkin FOLLOWS AaronRice

  • Person CURRENT_LOCATION is a Location, e.g. MarcoAu CURRENT_LOCATION SanFrancisco

A query console

This console allows you to play with the described model - you can ask Cypher queries to check it. It also desplays the result of last executed Cypher query from the list presented below.

Graph data upload

Firstly, the test data is added to the database.

The initial database has been populated with the following sample information (The app will scrape the actual data from Twitter API):

People:

  • Elcin is friends with Aaron, Fred and Phillip. Elcin lives in San Francisco.

  • Marco is also friends with Aaron, Fred and Phillip. He also lives in San Francisco.

  • Joe is friends with Fred and Phillip. Joe lives in New York.

Location:

  • San Francisco.

  • New York.

//Person
CREATE (elcin:Person {screen_name:'ElcinErkin'}),
       (aaron:Person {screen_name:'RICEaaron'}),
       (marco:Person {screen_name:'MarcoAu'}),
       (phillip:Person {screen_name:'epic_scene'}),
       (fred:Person {screen_name:'FredZirdung'}),
       (joe:Person {screen_name:'JoeDoe'})

//Location
CREATE (sanfrancisco:Location {name:'San Francisco'}),
       (newyork:Location {name:'New York'})

//Friendship
CREATE (elcin)-[:FOLLOWS]->(aaron),
       (elcin)-[:FOLLOWS]->(fred),
       (elcin)-[:FOLLOWS]->(phillip),
       (marco)-[:FOLLOWS]->(aaron),
       (marco)-[:FOLLOWS]->(fred),
       (marco)-[:FOLLOWS]->(phillip),
       (joe)-[:FOLLOWS]->(fred),
       (joe)-[:FOLLOWS]->(phillip)


//People's locations
CREATE (elcin)-[:CURRENT_LOCATION]->(sanfrancisco),
       (aaron)-[:CURRENT_LOCATION]->(sanfrancisco),
       (marco)-[:CURRENT_LOCATION]->(sanfrancisco),
       (fred)-[:CURRENT_LOCATION]->(sanfrancisco),
       (phillip)-[:CURRENT_LOCATION]->(sanfrancisco),
       (joe)-[:CURRENT_LOCATION]->(newyork)

Use cases

The basic application of the model is making friend recommendations based on the current location and common friends on Twitter (Cypher queries below):

  • Recommendations:

    • I want to go out and meet new people tonight. I would prefer to meet people I have common interests with. Who would be interested in a meet-up?

Determine if user is already in db, add if not

MERGE (p:Person {screen_name:'ElcinErkin'})
ON CREATE SET p.screen_name={screen_name}
RETURN p;

Insert users into graph with relevant relations

MATCH (p:Person {screen_name:'ElcinErkin'}),
(friend:Person {screen_name:'RICEaaron'})
CREATE UNIQUE (p)-[:FOLLOWS]->(friend)

Find people that has common friends with the user and lives in the same location

MATCH (p:Person {screen_name:'ElcinErkin'})-[:FOLLOWS]->()<-[:FOLLOWS]-(f:Person)
WHERE (p)-[:CURRENT_LOCATION]->()<-[:CURRENT_LOCATION]-(f)
RETURN DISTINCT f

How to enhance the model

The presented graph model can be enhanced by doing semantic analysis on user’s tweets.

TweetUp

The following properties can be added:

Keyword:

  • Elcin is tweeting about Neo4j, Angular and Javascript. Elcin lives in San Francisco. Elcin is friends with Aaron and Fred.

  • Marco is tweeting about Neo4j, Ionic and Angular. He also lives in San Francisco and friends with Aaron, Phillip and Fred.

Summary

This presented model is designed for a simple recommendation app. Added semantics analysis would help building towards more accurate recommendation results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment