Fourcity TripAdvisor Dataset Analysis

Fact Sheet

The Fourcity TripAdvisor contains:

  • 2954 reviews
  • Made by 792 users
  • About 105 items
  • It has an approximated sparsity of 0.964478114478

Now we are going to analyze the number of reviews per user and per item


In [ ]:
import sys
sys.path.append('/Users/fpena/UCC/Thesis/projects/yelp/source/python')
from etl import ETLUtils

from etl.reviews_dataset_analyzer import ReviewsDatasetAnalyzer

# Load reviews
file_path = '/Users/fpena/tmp/filtered_reviews_multi_non_sparse_shuffled.json'
reviews = ETLUtils.load_json_file(file_path)

rda = ReviewsDatasetAnalyzer(reviews)

Users Reviews Analysis

  • The average number of reviews per user is 3.7297979798
  • The minimum number of reviews a user has is 1
  • The maximum number of reviews a user has is 48

In [ ]:
# Number of reviews per user
users_summary = rda.summarize_reviews_by_field('user_id')
print('Average number of reviews per user', float(rda.num_reviews)/rda.num_users)
users_summary.plot(kind='line', rot=0)

Items Reviews Analysis

  • The average number of reviews per item is 28.1333333333
  • The minimum number of reviews an item has is 20
  • The maximum number of reviews an item has is 57

In [ ]:
# Number of reviews per item
items_summary = rda.summarize_reviews_by_field('offering_id')
print('Average number of reviews per item', float(rda.num_reviews)/rda.num_items)
items_summary.plot(kind='line', rot=0)

Number of items 2 users have in common

In this section we are going to count the number of items two users have in common


In [ ]:
# Number of items 2 users have in common
common_item_counts = rda.count_items_in_common()
plt.plot(common_item_counts.keys(), common_item_counts.values())

In [ ]:
from pylab import boxplot
my_data = [key for key, value in common_item_counts.iteritems() for i in xrange(value)]
mean_common_items = float(sum(my_data))/len(my_data)
print('Average number of common items between two users:', mean_common_items)
boxplot(my_data)