<!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>Learning on a Stream of Features with Random Forest</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Jan Motl</string-name>
          <email>jan.motl@fit.cvut.cz</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Pavel Kordík</string-name>
          <email>pavel.kordik@fit.cvut.cz</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Czech Technical University in Prague</institution>
          ,
          <addr-line>Thákurova 9, 160 00 Praha 6</addr-line>
          ,
          <country country="CZ">Czech Republic</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>We study an interesting and challenging problem, supervised learning on a stream of features, in which the size of the feature set is unknown, and not all features are available for learning while leaving the number of observations constant. In this problem, the features arrive one at a time, and the learner's task is to train a model equivalent to a model trained from "scratch". When a new feature is inserted into the training set, a new set of trees is trained and added into the current forest. However, it is desirable to correct the selection bias: older features has more opportunities to get selected into trees than the new features. We combat the selection bias by adjusting the feature selection distribution. However, while this correction improves accuracy of the random forest, it may require training of many new trees. In order to keep the count of the new trees small, we furthermore put more weight on more recent trees than on the old trees.</p>
      </abstract>
      <kwd-group>
        <kwd>random forest</kwd>
        <kwd>incremental learning</kwd>
        <kwd>online learning</kwd>
        <kwd>sequential learning</kwd>
        <kwd>stream learning</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        Motivation Our original need for learning on a stream
of features was due to our interest into
propositionalization [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]. Propositionalization is a data preprocessing step,
which converts relational data into a single data. And one
of the persistent problems of propositionalization is that it
generates a wast quantity of redundant and/or unpredictive
features (e.g.: [
        <xref ref-type="bibr" rid="ref2 ref3">3, 2</xref>
        ]). Would not it be interesting to
intelligently guide the propositionalization in order to avoid
wasteful generation of these irrelevant features? Our
previous research [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] answered this question positively — based
on univariate feature selection on a stream of features, we
obtained 10-fold acceleration of the propositionalization
(while maintaining the accuracy of the downstream model
      </p>
      <p>Copyright ©2019 for this paper by its authors. Use permitted under
Creative Commons License Attribution 4.0 International (CC BY 4.0).
comparable to accuracy obtained on exhaustive
propositionalization). However, our former research had evident
weakness: it neglected to take into account possible
interactions between features. This paper attempts to address
this weakness.</p>
      <p>Why not a feature selection filter? Features that are
currently unpredictive may become predictive, as new features
appear. For example, consider XOR problem, in which the
binary label is determined by two binary features f1 and
f2: y = xor( f1; f2). Features f1 and f2 are individually
unpredictive. But together, they define the label. Univariate
feature selection filters (e.g.: based on information gain
ratio) cannot correctly identify the change or the first feature
relevance as the second feature is added in XOR problem.
But models capable of modeling feature interactions (like
random forests) can eventually identify these features as
important.</p>
      <p>Application Beside propositionalization, learning on a
stream of features has another interesting use-case: Kaggle
competitions. In these challenges, competitors are given a
dataset and the team with the best model wins1. Based on
the analysis of solutions of the past winners2, one of the
common differentiating factors is extensive feature
engineering. However, competitive feature engineering is
generally not a one-time task but rather an iterative process:
1. formulate a hypothesis (e.g.: log transformation of
features will improve the accuracy of the downstream
model),
2. test the hypothesis (e.g.: evaluate the change of
accuracy of the downstream model),
where the choice of the next round of hypotheses is
influenced based on the success of the previously evaluated
hypotheses. Traditionally, the evaluation of the hypothesis
required retraining of the model from scratch. Our solution
is to update the current model. The benefit is evident: the
update of the current model takes less time than retraining
the model from scratch. And consequently, that gives us
the freedom to test more hypotheses.</p>
      <p>
        Random forest We take random forest [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] as a starting
model to expand into an online implementation because
it can deal with dirty data (e.g.: missing values, outliers,
mix of numerical and nominal attributes,...) and given an
implementation of a decision tree, it is easy to implement
and reason about.
      </p>
      <p>
        The key idea behind random forest classifier is that we
make an ensemble of decision trees. In order to create
diversity between the trees, it employs two strategies: bagging
and random feature selection. Bagging is based on a
random sampling of training instances with repetition. While
random feature selection is without repetition. The count of
features to select is one of the most tunable parameters of
random forests [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] and multiple heuristics for the optimal
value were provided in the literature. For simplicity of the
following analysis, we assume that the count of the selected
features is a fixed ratio of the count of all the features. We
call the ratio mtry.
      </p>
      <p>1See a list of all possible challenges at https://www.kaggle.com/
competitions</p>
      <p>2http://blog.kaggle.com/category/
winners-interviews/</p>
    </sec>
    <sec id="sec-2">
      <title>1 Implementation</title>
      <p>Bias Whenever a new feature xnew arrives, we may train n
new trees. And add the newly trained trees into the current
random forest. Unfortunately, with this approach, the new
features would be underrepresented in the forest in
comparison to old features simply because the old features had
multiple opportunities to get used in a tree while the new
feature had only one opportunity to get used in a tree.</p>
      <p>Consequently, earlier features would have a bigger
impact (weight) in the forest than the newer features. This
presents a bias, which is generally undesirable.</p>
      <p>Variable count of trees The first intuitive improvement is
to make sure that the new feature is actually always passed
to the new trees (instead of leaving it on the chance). And
instead of generating an arbitrary count of the trees, we can
calculate the optimal count n that minimizes the random
feature selection bias.</p>
      <p>First, we introduce the notation. Let c be the count of
how many times a feature x was passed to decision trees.</p>
      <p>And let old subscript describe some old feature and new
subscript to describe the new feature. If we want to avoid
the random feature selection bias, following should hold:
(1)
(2)
(3)
(4)
(5)
Since
because the new feature is always selected and
cnew = cold :</p>
      <p>cnew = n
where dold is the count of the old features, we get:
cold = mtry dold + mtry n;</p>
      <p>n = mtry dold + mtry n:
Hence, we get the optimal n with:
n = mtry dold :</p>
      <p>1 mtry</p>
      <p>The issue with this approach is that if we keep adding
d features one-by-one, the total count of the trees in the
ensemble grows quadratically.</p>
      <p>Tree weighting If we want to avoid the quadratic growth of
the random forest, we may weight the late trees more than
the former trees. While we could have calculated the tree
weight analytically, we provide an algorithmic solution in
Algorithm 1. In praxis, the advantage of the algorithmic
solution is that it is self-correcting — if some of the
assumptions are not fully fulfilled (e.g.: When we have 11
features and the feature selection ratio is 0.5, we can either
Algorithm 1: Random forest update, when a new feature arrives. Function featureCnt() returns count of features to
sample.</p>
      <p>Input: X : training data, y: training label, col: index of the new feature, treeCnt: cnt of trees to train,
weightedFeatureU seCnt: bookkeeping vector initialized to zeros, ensemble: collection of trees.</p>
      <p>Output: ensemble, treeWeight, weightedFeatureU seCnt.
1 f eatureU seCnt = zeros (col);
2 for i=1:treeCnt do
3 oldFeatures = choice (1:col-1, featureCnt (col-1), replacement=False);
4 f eatures = [oldFeatures, col];
5 samples = choice (nrow (x), nrow (x), replacement=True);
6 tree = fitTree (X [samples, f eatures], y[samples]);
7 ensemble = [ensemble, tree];
8 f eatureU seCnt[ f eatures]++ ;
9 end
10 treeWeight = avg (weightedFeatureU seCnt[1:col-1]) / ( f eatureU seCnt[col] - avg ( f eatureU seCnt[1:col-1]));
11 weightedFeatureU seCnt = weightedFeatureU seCnt + treeWeight* f eatureU seCnt;
select 5 or 6 features but not 5.5.), the error is not ignored
(as it would be in a closed-form analytical solution) but is
encoded in weightedFeatureUseCount. And each call
of Algorithm 1 directly minimizes the error.</p>
      <p>When scoring new samples, we evaluate trees in the
ensemble and calculate the weighted average of the
predictions (each generation of trees share the same treeWeight).
2</p>
    </sec>
    <sec id="sec-3">
      <title>Experiments</title>
      <p>We compare two online random forest implementations:
baseline and challenger. In baseline, features are selected
with uniform probability (like in ordinary random forest).
In the challenger model, the new feature is always selected
while the old features are selected with uniform
probability3. Furthermore, we train an offline random forest with
the same meta-parameters as the online random forest in
order to depict the value of the online learning.
Protocol For each data set, we performed the following
procedure 10 times: We randomly split the data set into
training/testing subsets with stratified sampling with 2:1
ratio. Then we randomly permutate the feature order in the
data set (because our proposal should work regardless of
the feature ordering). Finally, on online random forests we
perform incremental learning feature-by-feature (i.e.: first
we train the random forest on the first feature, then we add
the second feature into the forest,... and continue until the
last feature is added into the forest). After adding the last
feature, the final model is evaluated on the testing set with
3This probability is smaller in the challenger model than in the
baseline model in order to keep the final count of features in challengers’ trees
identical to the count of features in baselines’ trees.</p>
      <p>AUC (Area Under the Receiver Operating Characteristics).
In the case of the offline random forest, we train the random
forest just once on all the features.</p>
      <p>
        Meta-parameters At each generation (addition of a new
feature), we train 30 new trees. This value is recommended
by Breiman [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] and we decided to go with it. For feature
selection ratio, we used 2⁄3.
      </p>
      <p>
        Data sets We used all 232 data sets (see Appendix A) from
OpenML [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] that have a binary label (because we evaluate
the models with AUC), less than 200000 samples (because
of runtime) and less than 15 features (again, because of the
runtime).
      </p>
      <p>Results In 87% (201/232), the challenger model had higher
average testing AUC than the baseline. Sign test on this
statistic gives one-tail P-value &lt; 10 29. The average
difference of the testing AUC across all the data sets was 2.10
percent point. Furthermore, in 71% (164/232), the
challenger model had higher average testing AUC than the
offline model (P-value &lt; 10 8). The table with the results
and the code that generated the table is available from
https://github.com/janmotl/rf.
3</p>
    </sec>
    <sec id="sec-4">
      <title>Discussion</title>
      <p>Overhead Challenger model, in comparison to
baseline model, uses 3 more variables: featureUseCount,
weightedFeatureUseCount and treeWeight. Each of
these variables is (or fill in) a vector of length d, the count
of features. Ignoring the differences in the data types, the
total memory overhead is equivalent to 3 more training data
samples. The computational complexity of updating these
3 variables, when a new feature is added, is O (d) since
treeCount is a constant.</p>
      <p>Limitation Our experiment suffers from one limitation:
while we make sure that the feature selection rate is
uniform, we ignore interactions between the features. This
could be a topic of further research.</p>
      <p>Extension One of possible extensions of our work, which
we did not pursue further, is pruning of the oldest trees from
the ensemble. The idea is simple: the older generations of
the trees have so small weight, that they hardly influence
the final prediction.
4</p>
    </sec>
    <sec id="sec-5">
      <title>Conclusion</title>
      <p>We have extended random forest to work on a stream of
features. The idea was simple: when a new feature arrives,
extend the forest with a new set of trees. However, with this
strategy, older features end up used more frequently than
the new features. When we fix this feature selection bias, it
improves the testing AUC on average by 2 percent points.
The proposed algorithm for feature selection bias
correction is fast, easy to implement and robust. The code was
open-sourced at https://github.com/janmotl/rf.
5</p>
    </sec>
    <sec id="sec-6">
      <title>Acknowledgments</title>
      <p>We would like to thank the anonymous reviewers, their
comments helped to improve this paper. This research was
supported by the Grant Agency of the Czech Technical
University in Prague, grant No. SGS17/210/OHK3/3T/18.</p>
    </sec>
    <sec id="sec-7">
      <title>Used datasets</title>
      <p>2dplanes
abalone
acute-inflammations
aids
Amazon_employee_access
analcatdata_apnea1
analcatdata_apnea2
analcatdata_apnea3
analcatdata_asbestos
analcatdata_bankruptcy
analcatdata_birthday
analcatdata_bondrate
analcatdata_boxing1
analcatdata_boxing2
analcatdata_broadway
analcatdata_broadwaymult
analcatdata_challenger
analcatdata_chlamydia
analcatdata_creditscore
analcatdata_cyyoung8092
analcatdata_cyyoung9302
analcatdata_dmft
analcatdata_draft
analcatdata_fraud
analcatdata_germangss
analcatdata_gsssexsurvey
analcatdata_gviolence
analcatdata_japansolvent
analcatdata_lawsuit
analcatdata_michiganacc
analcatdata_neavote
analcatdata_negotiation
analcatdata_olympic2000
analcatdata_reviewer
analcatdata_runshoes
arsenic-female-bladder
arsenic-female-lung
arsenic-male-bladder
arsenic-male-lung
autoMpg
badges2
balance-scale
balloon
banana
bank8FM
banknote-authentication
baskball
house_8L
houses
humandevel
hungarian
hutsof99_logis
ilpd
iris
irish
jEdit_4.0_4.2
jEdit_4.2_4.3
kdd_el_nino-small
kidney
kin8nm
lowbwt
lupus
machine_cpu
MagicTelescope
mammography
mbagrade
mfeat-morphological
mofn-3-7-10
monks-problems-1
monks-problems-2
monks-problems-3
mozilla4
mu284
mux6
mv
newton_hema
no2
nursery
page-blocks
parity5
parity5_plus_5
pc1_req
pollen
postoperative-patient-data
prnn_crabs
prnn_fglass
prnn_synth
profb
puma8NH
pwLinear
quake
qualitative-bankruptcy
rabe_131
rabe_148</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>Leo</given-names>
            <surname>Breiman</surname>
          </string-name>
          .
          <article-title>Random forest</article-title>
          . Mach. Learn.,
          <volume>45</volume>
          (
          <issue>5</issue>
          ):
          <fpage>1</fpage>
          -
          <lpage>35</lpage>
          ,
          <year>1999</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>Valentin</given-names>
            <surname>Kassarnig</surname>
          </string-name>
          and
          <string-name>
            <given-names>Franz</given-names>
            <surname>Wotawa</surname>
          </string-name>
          .
          <article-title>Evolutionary propositionalization of multi-relational data</article-title>
          .
          <source>Proc. 30th Int. Conf. Softw. Eng. Knowl. Eng.</source>
          ,
          <year>2018</year>
          :
          <fpage>629</fpage>
          -
          <lpage>690</lpage>
          ,
          <year>2018</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <surname>Mark-André Krogel</surname>
          </string-name>
          .
          <article-title>On Propositionalization for Knowledge Discovery in Relational Databases</article-title>
          .
          <source>PhD thesis</source>
          , Otto-vonGuericke
          <string-name>
            <surname>-Universität</surname>
            <given-names>Magdeburg</given-names>
          </string-name>
          ,
          <year>2005</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>Jan</given-names>
            <surname>Motl</surname>
          </string-name>
          and
          <string-name>
            <given-names>Pavel</given-names>
            <surname>Kordík</surname>
          </string-name>
          .
          <article-title>Do we need to observe features to perform feature selection? CEUR Workshop Proc</article-title>
          .,
          <volume>2203</volume>
          :
          <fpage>44</fpage>
          -
          <lpage>51</lpage>
          ,
          <year>2018</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>Philipp</given-names>
            <surname>Probst</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Marvin N.</given-names>
            <surname>Wright</surname>
          </string-name>
          , and Anne Laure Boulesteix.
          <article-title>Hyperparameters and tuning strategies for random forest</article-title>
          ,
          <year>2019</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>Joaquin</given-names>
            <surname>Vanschoren</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Jan N. van Rijn</given-names>
            ,
            <surname>Bernd Bischl</surname>
          </string-name>
          , and Luis Torgo.
          <article-title>OpenML: networked science in machine learning</article-title>
          .
          <source>ACM SIGKDD Explor. Newsl.</source>
          ,
          <volume>15</volume>
          (
          <issue>2</issue>
          ):
          <fpage>49</fpage>
          -
          <lpage>60</lpage>
          , jun
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>