<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Use XGBOOST to Predict the Rental Based on Airbnb Open Data</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Suhang Yao</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>School of International College, Beijing University of Posts and Telecommunications</institution>
          ,
          <addr-line>Beijing 100876</addr-line>
          ,
          <country country="CN">China</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>XGBOOST is a considerably effective method for machine learning, which performs well in all kinds of competition. Using a dataset from Airbnb Open data, the paper examines extent of factors affecting the rental and what is the future trend of rental by applying XGBOOST and other machine learning methods. The various features of data are visualized for further procession, and knowledge transfers between the statistic of hyperparameters of XGBOOST and test error has been cognized, which are illustrates by the merging and collapsing of different hyperparameters. Results show that the data pre-processing significantly influence on the precision of prediction. Also, variation of distinct hyperparameters impacts test error on this dataset in varying degrees, and the most appropriate figure of them has been confirmed by making comparisons recursively. Finally, general ideas of data preprocessing and hyperparameters tuning are proposed.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;Machine Learning</kwd>
        <kwd>XGBOOST</kwd>
        <kwd>Data Preprocessing</kwd>
        <kwd>Visualization</kwd>
        <kwd>Prediction on Rental</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        Since 2008, guests and hosts have used global home stay short rent and reservation platform Airbnb
(AirBed and Breakfast) to enjoy the home-like customized living experience and offer international
housing resources for investment. There are quantities of factors () influencing the rental in Airbnb,
which has been a great concern of the users and investors. XGBOOST is a useful tool for massively
parallel booted trees [
        <xref ref-type="bibr" rid="ref1 ref2 ref3">1-3</xref>
        ]. It is the fastest and best open source booted tree toolkit at the moment.
Therefore, the research is developed to analyze and predict the rental base on the XGBOOST
technologyand the dataset of the listing activity and metrics in NYC, NY for 2019.
      </p>
      <p>The project refers number of papers, and the main sources of them come from various areas,
including xgboost, K-fold cross validation, Pandas, Robust covariance and Scatter matrix, Numpy, and
IPython, Boosting, Decision tree and Heatmap. What's more, I come to kaggle to learn other's code and
imagination, finally make my project down. In this report, I absorb these paper's and website's thought,
but I don't use their concrete sentence.</p>
      <p>This report is intended for executing XGBOOST algorithm to predict the rental in Airbnb. The
second and third paragraph are written to introduce the Airbnb dataset and XGBOOST algorithms
respectively. The fourth paragraph presents the process of preprocessing the data set, EDA, choosing
and tuning hyperparameter, etc. The conclusion and the list of references will be shown on the last
paragraph.</p>
      <p>This data file includes comprehensive and diggable information about hosts, geographical
availability, necessary metrics to make predictions and draw conclusions. It has 16 columns and 48577
rows. Table 1 shows the concrete features of dataset:
listing ID
name of the listing</p>
      <p>host ID
name of the host
city</p>
      <p>Latitude
Longitude
room_type</p>
      <p>Price
minimum_nights
number_of_reviews</p>
      <p>last_review
reviews_per_month
calculated_host_listings_count
availability_365
area
latitude coordinates
longitude coordinates
listing space type</p>
      <p>price in dollars
amount of nights minimum
number of reviews</p>
      <p>latest review
Num of reviews per month
amount of listing per host
number of days when listing is available for booking</p>
    </sec>
    <sec id="sec-2">
      <title>2. Analysis base on XGBOOST Algorithm</title>
      <p>XGBOOST algorithm is the used tool for the article. The algorithm I use is XGBOOST, and below
is my acknowledgement about XGBOOST. Above all, there are two significant concepts need to be
acknowledged before this. The first one is decision tree, which is a common method for classification
and regression. Decision tree algorithm is the process of classifying instances according to the input
features, that is, through the tree model, judge the eigenvalues at each layer of the tree, and then reach
the leaf node of the decision tree, which completes the classification process. I will conclude that
XGBOOST is the integration of many cart regression trees. In fact, the essence of classification and
regression is the same. They are both the mapping between feature and label, while the result of
classification is discrete value and regression is continuous. Therefore, the output of the regression tree
is in the form of numerical value as well. For example, the housing loan to someone may be a continuous
value, which can be any value between 0 and 0.5 million dollars. The second is boosting ensemble
learning, which refers to joint decision-making by multiple decision trees with correlation. What’s for
correlation? For instance, there is a sample is [(2, 4, 5) -&gt; 4] ([data -&gt; label]), and the first decision
tree’s output trained with this sample predicts 3.3. Then the input of the second decision tree to be
trained will be [(2, 4, 5) - &gt; 0.7], and 0.7=4-3.3, which means the input sample of the next decision tree
will be related to the training and prediction of the previous decision tree.</p>
      <p>
        On the previous basis, I will conclude the goal of XGBOOST [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] are to establish K regression trees
to make the predicted value close to the real value as far as possible and have the best ability of
generalization. Therefore, XGBOOST built a model like this:
      </p>
      <p>L(ϕ) = ∑l(ω − yi) + γ + 21 λ‖ω‖2 ()</p>
      <p>It can be seen that if the loss function l(ω − yi)here uses square error, and the above function can
be simplified into a quadratic function to find the minimum, that is, quadratic optimization. If the loss
function is not a square error, we can approximate it into a square error by some mathematical methods
like Taylor expansion. Therefore, the idea of XGBOOST algorithm is to select a feature to split,
calculate the minimum value of loss function, and iterate until a stop condition. There are 3 condition
for stopping: a. when the gain caused by the introduced splitting is less than a threshold; b. set a super
parameter max_ depth, stop when the tree reaches the maximum depth c. set the minimum sample
weight ‘min_ child_ weight’, when the sample weight sum is less than the set threshold, XGBOOST
will stop.</p>
      <p>Every machine learning algorithm has multiple hyperparameters, XGBOOST is no exception as
well. I’m going to introduce some parameters for tree booster. There are the lists: 1.eta, control the
weight reduction of each learning, shrinks the feature weights to make the boosting process more
conservative. 2.gamma, minimum loss reduction required to make a further partition on a leaf node of
the tree. The larger gamma is, the more conservative the algorithm will be. 3.max_depth, the maximum
depth of the tree. Increasing this value will make the model more complex and more likely to overfit.
4.min_child_weight, minimum sum of instance weight (hessian) needed in a child, if it is set to a
positive value, it can help making the update step more conservative. 5.subsample, subsample ratio of
the training instances. Setting it to 0.5 means that XGBOOST would randomly sample half of the
training data prior to growing trees. and this will prevent overfitting. Subsampling will occur once in
every boosting iteration. 6.colsample_bytree, the subsample ratio of columns when constructing each
tree. Subsampling occurs once for every tree constructed. 7.alpha, L1 regularization term on weights.
Increasing this value will make model more conservative. Above these is also the hyperparameters I
tuned in my project.</p>
    </sec>
    <sec id="sec-3">
      <title>3. Preprocessing and Visualization</title>
      <p>I’m going to describe this preprocessing with seven parts, which contains all main features.
Moreover, visualization are made on each features I concerned by using sklearn and pandas as tools
[46].</p>
    </sec>
    <sec id="sec-4">
      <title>3.1. Preliminary exploratory data analysis on the data set.</title>
      <p>The purpose of preliminary exploratory data analysis for the precision and accuracy on the further
analysis, which can be achieved by missing value analysis, useless features deletion and filling the
empty of significant features. Visualization of the remaining dataset is also applied for explore.</p>
      <p>Firstly, count the concrete number of each feature in the dataset and analyze the missing values. The
statistic result of counting is shown as figure 1. It can be observed that majority of the columns has
48895 columns, while three rows (reviews_per_month, last_review, name and host_name) with fewer
not-null amount are identified to have missing values. These rows with missing value are dropped on
the purpose of eliminate influence on further analysis.</p>
      <p>Secondly, there are relatively few missing in name and host_name. Considering they make little
contribution to data modeling; these two columns are deleted.</p>
      <p>Third, two features with generous missing values (reviews_per_month, last_review) are not deleted
despite the account for 20% of the total samples, in the consideration to reserve the diggable information
in the dataset. Due to the reason that review_per_month and last_review would maintain empty if there
is no review, the action is taken to fill reviews_ per_ month with 0 and fill in last_review with the
earliest comment time of the whole data set.</p>
      <p>As for deeper analysis, I visualize the distribution of some features and performed correlation analysis. The
amount for host_id accounting for 76% of the total number of samples in the data set, and the host_ ID belongs
to discrete data which has little contribution or even introduce the negative contribution of modelling. Therefore,
consider deleting this feature. The feature id is deleted for the same purpose.</p>
    </sec>
    <sec id="sec-5">
      <title>3.2. The procession and visualization of each particular feature</title>
      <p>The purpose of inner procession of particular feature of the remaining data is to filter out the edge/not
common value and make classical analysis.</p>
    </sec>
    <sec id="sec-6">
      <title>3.2.1. Neighborhood group</title>
      <p>The data of neighborhood group are counted as output. The analysis only reserves three of five
neighborhood groups because there are limited rooms distributed in Staten Island and the Bronx. After
this step, remaining data visualization is applied as figure 2.</p>
    </sec>
    <sec id="sec-7">
      <title>3.2.2. Longitude and latitude distribution</title>
      <p>Longitude and latitude are somewhat correlated with each other. This is because the locations of
properties tend to come from clusters. Which can be observed in the figure 3 and figure 4 is that house
with the feature that longitude close to - 73.9 ~ - 74.0 and latitude close to 40.7 are more welcomed by
tourists.
3.2.3. room_type</p>
      <p>There are three categories of the room source after exploring the statistics of room type. The data of
shared room could be outlier due to the limited amount, so it is cancelled. The following figure 5 shows
the count of private room and entire room respectively.</p>
    </sec>
    <sec id="sec-8">
      <title>3.2.4. minimum_nights</title>
      <p>As figure 6 shows, the data presents a very severe skewed distribution, and the minimum day value
required for most rooms is very small. For severely skewed data, log1p() function in numpy can be used
to process it (figure 7).
3.2.5. Ability_365</p>
      <p>The statistics of bookable days of multiple samples in dataset shows a larger probability to be booked
within 15 days, but the distribution does not show intermittent skewness</p>
      <p>Meanwhile, the majority of Ability_365 of the sample within 15 days, and the number of other days is small,
but the distribution does not show intermittent skewness. (figure8)
3.2.6. Price</p>
      <p>The figure 9 of price shows a very significant skew distribution, which is quite similar comparing to
minimum nights. The distribution of room price data can be transformed into an approximate Gaussian
distribution by using np.log1p function, and it is presented in figure 10.</p>
      <p>Due to the reason that outlier of the importance as a super parameter and the serious skew distribution
of price, this hyperparameter is focused on for deeper analysis. By checking the percentage distribution
of the price, we can get the price value and extreme value corresponding to several important
percentages. 95% of price is less than 369.00, 99% of price is less than 799.00, and the maximum value
is 10000.00.</p>
    </sec>
    <sec id="sec-9">
      <title>4. Correlation Analysis</title>
      <p>This part makes the correlation analysis of the main features based on the Heatmap and scatter
matrix.</p>
      <p>
        Figure 11 is Heatmap [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] of main features, which is also called Pearson correlation matrix. The
figure shows the number of reviews per month is fair (40%) correlated with the total number of reviews
and the total number of reviews is correlated (30%) with the availability of the property. Both of these
correlations make sense. It's also interesting that the longitude is anticorrelated (20%) with the price.
That also makes sense - property in the Bronx and in Queens is cheaper than Manhattan and Brooklyn.
      </p>
      <p>
        Pearson correlation coefficient can only reflect the linear correlation degree between the two
features. Therefore, figure 12 as the scatter matrix [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ] more intuitively explore the correlation between
the features. It is used to visualize the features between the two. The scatter matrix of price with
longitude and latitude and it with number_ of_ reviews are separately here.
      </p>
      <p>Figure 11: heatmap of main features</p>
      <p>As for the final preprocessing before data modeling, the First stage is encoding the categorical
features. Before modeling, the data type and the classified data needs to be processed with dummy
variables first. Get using pandas_ Dummies module can quickly encode all classification variables by
one-hot.</p>
      <p>
        Secondly, splice the dummy variables in the first step with all numerical data in the original data set.
The data is split into a test set and a training set, where training set compose 80% and test set compose
20%. Next, hold out the test set until the very end and use the error on those data as an unbiased estimate
of how my models did. Finally, I now scale the design matrix with RobustScaler() in sklearn[
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] so that
each predictor has zero mean and unit variance. This helps the convergence of machine learning
algorithms such as linear regression. Above these, consequently, I had the final data modeling and used
it for tuning hyperparameters.
      </p>
      <p>In terms of the hyperparameters, I mainly considered seven ones, separately are learning rate,
gamma, alpha, subsample, colsample_bytree, max_depth and min_child_weight. I tuned these
hyperparameters through the values of mean crossover error, crossover error standard deviation and
training error.</p>
    </sec>
    <sec id="sec-10">
      <title>5. Evaluation and DATA mODELING</title>
      <p>After modification and evaluation, the for best predicted model is shown in table 2.</p>
    </sec>
    <sec id="sec-11">
      <title>5.1. Training error and test error analysis</title>
      <p>Mean squared error of test data is used as the final performance evaluation of the model, which is
called training error here. It can be seen that the value of test error is 0.127254, which is at a relatively
low level, indicating that this model has high prediction ability. However, the value of training error is
lower because some of them participate in model training as validation sets. Therefore, as the untrained
data, the mean square error of test set will increase to a certain extent.</p>
    </sec>
    <sec id="sec-12">
      <title>5.2. Data cleaning</title>
      <p>The main factor of test error is data cleaning in this predicting model, followed by tuning
hyperparameter. As for data cleaning, the maximum 5% price is treated as the outsider and apply the
delete operation. If the outsider of price is not cleaned, the test error will be very high, reaching about
19%, indicating that the prediction model doesn’t perform well. Deleting a greater proportion of prices
(8% or 10% of the total amount) is also an attempt, the predicting model of which will produce even a
lower test error at 11%. However, in this circumstance, the deleted sample size is extremely large, which
is not applicable to the real situation. Under the above considerations, I chose a price of 5% as the
outsider, which can satisfy the condition of both ensuring a lower test error and better conforming to
the actual situation simultaneously.</p>
    </sec>
    <sec id="sec-13">
      <title>5.3. Evaluation</title>
      <p>After finishing data cleaning, I compared the distribution of actual prices and predicted values by
means of scatter matrix. It can be seen that the predicted values fit the real house prices better under
most conditions, but large error can still be observed when predicting the edge prices. Meanwhile, due
to the deletion of outlier, overpriced houses do not exist in this data set and cannot be predicted.</p>
    </sec>
    <sec id="sec-14">
      <title>5.4. K-fold cross validation</title>
      <p>
        K-fold cross validation [
        <xref ref-type="bibr" rid="ref10 ref9">9, 10</xref>
        ] can robustly evaluate the performance of the model on unknown data,
but larger computational complexity, longer time and more computational resources are consumed due
to the large amount of data in this data set. I divide my previous training set into k parts, of which k-1
is used as the new training set and the remaining 1 is used as the verification set. In this way, I execute
K rounds to obtain mean cross validation error as the evaluation of the overall performance of
hyperparameter. The specific process is to verify the super parameters on the training set and
verification set, and select the super parameters with the minimum average error. After selecting the
appropriate super parameters, the training set and verification set can be combined, and the model can
be trained again to obtain the final model.
      </p>
    </sec>
    <sec id="sec-15">
      <title>5.5. Predicted result</title>
      <p>In the last stage, table 3 shows my final price prediction results. It can be seen that when the selected
data concentrates on the center, the prediction results of the model are more accurate with smaller error,
which I pointed out before. This is because there are few data distributions at the edge, which is not
able to generate a decisive impact on the data modeling; On the contrary, data modeling mostly depends
on the data located in most intervals, which is the reason for the high prediction accuracy of this model
for most data.</p>
    </sec>
    <sec id="sec-16">
      <title>6. Conclusion</title>
      <p>In this paper, I use XGBOOST to finish the prediction of rental in Airbnb. Result has exposed best
performed prediction and the conditions for approaching it. Furthermore, the work proposes a general
idea for the preprocess of dataset and for further improvement of this model, a better result may be
produced by repeatedly using distinct random grouping data for cross validation and reducing the
variance of a single cross validation scheme to increase the prediction accuracy outside the sample.</p>
    </sec>
    <sec id="sec-17">
      <title>7. References</title>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <surname>Myles</surname>
            <given-names>A J</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Feudale</surname>
            <given-names>R N</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Liu</surname>
            <given-names>Y</given-names>
          </string-name>
          , et al.
          <article-title>An introduction to decision tree modeling[J]</article-title>
          .
          <source>Journal of Chemometrics: A Journal of the Chemometrics Society</source>
          ,
          <year>2004</year>
          ,
          <volume>18</volume>
          (
          <issue>6</issue>
          ):
          <fpage>275</fpage>
          -
          <lpage>285</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <surname>Svetnik</surname>
            <given-names>V</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Wang</surname>
            <given-names>T</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Tong</surname>
            <given-names>C</given-names>
          </string-name>
          , et al.
          <article-title>Boosting: An ensemble learning tool for compound classification and QSAR modeling[J]</article-title>
          .
          <source>Journal of chemical information and modeling</source>
          ,
          <year>2005</year>
          ,
          <volume>45</volume>
          (
          <issue>3</issue>
          ):
          <fpage>786</fpage>
          -
          <lpage>799</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <surname>Chen</surname>
            <given-names>T</given-names>
          </string-name>
          ,
          <string-name>
            <surname>He</surname>
            <given-names>T</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Benesty</surname>
            <given-names>M</given-names>
          </string-name>
          , et al.
          <article-title>Xgboost: extreme gradient boosting</article-title>
          [J].
          <source>R package version 0</source>
          .4-
          <issue>2</issue>
          ,
          <year>2015</year>
          ,
          <volume>1</volume>
          (
          <issue>4</issue>
          ):
          <fpage>1</fpage>
          -
          <lpage>4</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <surname>Feurer</surname>
            <given-names>M</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Klein</surname>
            <given-names>A</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Eggensperger</surname>
            <given-names>K</given-names>
          </string-name>
          , et al.
          <source>Auto-sklearn: efficient and robust automated machine learning[M]//Automated Machine Learning</source>
          . Springer, Cham,
          <year>2019</year>
          :
          <fpage>113</fpage>
          -
          <lpage>134</lpage>
          . MLA
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <surname>McKinney</surname>
            <given-names>W.</given-names>
          </string-name>
          <article-title>pandas: a foundational Python library for data analysis</article-title>
          and statistics[J].
          <source>Python for high performance and scientific computing</source>
          ,
          <year>2011</year>
          ,
          <volume>14</volume>
          (
          <issue>9</issue>
          ):
          <fpage>1</fpage>
          -
          <lpage>9</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <surname>McKinney</surname>
            <given-names>W. Python</given-names>
          </string-name>
          <article-title>for data analysis: Data wrangling with Pandas, NumPy, and</article-title>
          <string-name>
            <surname>IPython[M]. " O'Reilly Media</surname>
          </string-name>
          ,
          <source>Inc."</source>
          ,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <surname>Metsalu</surname>
            <given-names>T</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Vilo</surname>
            <given-names>J.</given-names>
          </string-name>
          <article-title>ClustVis: a web tool for visualizing clustering of multivariate data using Principal Component Analysis and heatmap</article-title>
          [J].
          <source>Nucleic acids research</source>
          ,
          <year>2015</year>
          ,
          <volume>43</volume>
          (
          <issue>W1</issue>
          ):
          <fpage>W566</fpage>
          -
          <lpage>W570</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <surname>Chen</surname>
            <given-names>M</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gao</surname>
            <given-names>C</given-names>
          </string-name>
          , Ren Z.
          <article-title>Robust covariance and scatter matrix estimation under Huber's contamination model</article-title>
          [J].
          <source>The Annals of Statistics</source>
          ,
          <year>2018</year>
          ,
          <volume>46</volume>
          (
          <issue>5</issue>
          ):
          <fpage>1932</fpage>
          -
          <lpage>1960</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <surname>Fushiki</surname>
            <given-names>T.</given-names>
          </string-name>
          <article-title>Estimation of prediction error by using K-fold cross-validation</article-title>
          [J].
          <source>Statistics and Computing</source>
          ,
          <year>2011</year>
          ,
          <volume>21</volume>
          (
          <issue>2</issue>
          ):
          <fpage>137</fpage>
          -
          <lpage>146</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <surname>Refaeilzadeh</surname>
            <given-names>P</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Tang</surname>
            <given-names>L</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Liu</surname>
            <given-names>H.</given-names>
          </string-name>
          <string-name>
            <surname>Cross-validation</surname>
          </string-name>
          [J].
          <source>Encyclopedia of database systems</source>
          ,
          <year>2009</year>
          ,
          <volume>5</volume>
          :
          <fpage>532</fpage>
          -
          <lpage>538</lpage>
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>