Introduction

In this notebook we show how to ingest Airbnb reviews data.
(The data can be used for exemplifying relevant Machine Learning algorithms.)

Sources:

MathematicaForPrediction at GitHub​
​MathematicaForPrediction at WordPress

Downloading the data

The data was downloaded from this site : http://insideairbnb.com/get-the-data.html .
In[]:=
WebImage["http://insideairbnb.com/get-the-data.html"]
Out[]=

Load data

In this section the data is imported. (You have to download the data first, and replace the corresponding names.)
In[]:=
lsFileNames=FileNames["~/Datasets/AirBnB/*reviews.csv"]
Out[]=
{~/Datasets/AirBnB/AirBnB-Austin-Texas-United-States-reviews.csv,~/Datasets/AirBnB/AirBnB-Broward-County-Florida-United-States-reviews.csv}
AbsoluteTiming​​dsReviews=Join@@MapResourceFunction
ResourceObject[
]
,lsFileNames;​​
Out[]=
{18.0559,Null}
In[]:=
Dimensions[dsReviews]
Out[]=
{524759,6}
In[]:=
SeedRandom[342];​​RandomSample[dsReviews,12]
Out[]=
listing_id
id
date
reviewer_id
reviewer_name
comments
32761299
459784643
2019-05-27
260673176
Rachel
This place and location was perfect! We were able to have walking distance to th ⋱
5477413
82235987
2016-06-26
31965194
Melody
Large, lovely home with great 10-min walking access to the beach and broadwalk, ⋱
19721357
515312924
2019-08-22
758794
Alex
Absolutely wonderful experience--beautiful, clean place to stay in a great locat ⋱
17123406
351968299
2018-11-24
182520327
Clint
The place is clean,spacious and located close to restaurants and shopping. Gabri ⋱
2396602
308041001
2018-08-15
56276177
Robbie
This home was the perfect accommodations for us! Everything was clean, spacious, ⋱
69810
202962752
2017-10-13
28368446
Alexandria
We were thrilled with the birds nest, the response, and the thoughtful touch. Th ⋱
32743526
425639227
2019-03-18
1417982
Robert
The place was pristine and very well appointed. Everything seemed new. The self ⋱
17109314
135012128
2017-03-02
72579420
Abraham
Lovely place great location nice hosts highly recommended,
22266927
318868306
2018-09-04
113565142
Tawna
Perfect place for our first trip to Austin! Easy to find, clean, really cute dec ⋱
17109314
226398361
2018-01-10
110497390
Jess
Honestly we thought the place was great and the location was great, but the fact ⋱
646392
14607779
2014-06-23
9920923
Joel
My wife and I spent 5 nights at Kathleen's BNB. The room was very clean when we ⋱
32920994
455451884
2019-05-19
36158427
Bre
This was my second time staying with James in one of his campers. This stay was ⋱

Summaries

Summary of all records:
In[]:=
ResourceFunction["RecordsSummary"][dsReviews]
Out[]=

1 listing_id
Min
2265
1st Qu
5558324
Mean
1.52976×
7
10
Median
15944361
3rd Qu
2.28841×
7
10
Max
38727516
,
2 id
Min
865
1st Qu
1.59769×
8
10
Mean
2.88211×
8
10
Median
291297296
3rd Qu
4.26657×
8
10
Max
533532956
,
3 date
2019-05-27
1928
2019-07-07
1841
2019-03-31
1800
2019-03-17
1769
2019-04-14
1690
2019-04-28
1671
(Other)
514060
,
4 reviewer_id
Min
3
1st Qu
2.467×
7
10
Median
67455091
Mean
9.02347×
7
10
3rd Qu
1.45028×
8
10
Max
296165050
,
5 reviewer_name
Michael
5133
David
4405
John
3836
Sarah
3535
Chris
3199
Jessica
3050
(Other)
501601
,
6 comments
Great place!
729
Great place
638
Great place to stay!
407
.
406
Great location!
384
312
(Other)
521883

Summary of counts per unique “listing_id” value:
In[]:=
ResourceFunction["RecordsSummary"][Query[GroupBy[#["listing_id"]&],Length]@dsReviews]
Out[]=

1 column 1
Min
1
1st Qu
3
Median
12
Mean
32.0385
3rd Qu
37
Max
856

Summary of counts per unique “reviewer_id” value:
In[]:=
ResourceFunction["RecordsSummary"][Query[GroupBy[#["reviewer_id"]&],Length]@dsReviews]
Out[]=

1 column 1
1st Qu
1
3rd Qu
1
Median
1
Min
1
Mean
1.15054
Max
80

Summary of counts per unique “id” value:
In[]:=
ResourceFunction["RecordsSummary"][Query[GroupBy[#["id"]&],Length]@dsReviews]
Out[]=

1 column 1
1st Qu
1
3rd Qu
1
Max
1
Mean
1
Median
1
Min
1


Pareto Principle adherence

Here we see a typical Pareto principle manifestation for the number of reviews distribution per listing ID:
ResourceFunction
ResourceObject[
]
[Values[Normal[Query[GroupBy[#["listing_id"]&],Length]@dsReviews]]]
Out[]=
Here we see that many reviewers do one review only (within that dataset):
ResourceFunction
ResourceObject[
]
[Values[Normal[Query[GroupBy[#["reviewer_id"]&],Length]@dsReviews]]]

Contingency matrix

Here we compute the contingency matrix for listings vs reviewers:

Latent Semantic Analysis

The Latent Semantic Analysis (LSA) computations are mostly done in order to compute different text derived statistics. (See [AA1, AA2].)

Text data

In this sub-section we extract the text data from the dataset into an association with text values and keys that correspond to the review ID’s.

Monad objects

Here we import the package [AA2]:

All reviews

Tighter reviews

For faster LSA computations -- and better results -- we want to use a tighter set of reviews.
Here we select review with string length between 80 and 400 symbols:

Document × term statistics -- all reviews

Document × term statistics -- tight reviews

Topics extraction (over tighter reviews)

Statistical thesaurus

References

[AA1] Anton Antonov, A monad for Latent Semantic Analysis workflows, (2019), MathematicaForPrediction at GitHub.
[AA2] Anton Antonov, Monadic Latent Semantic Analysis Mathematica package, (2017), MathematicaForPrediction at GitHub.​
URL: https://github.com/antononcube/MathematicaForPrediction/blob/master/MonadicProgramming/MonadicLatentSemanticAnalysis.m .