{'fraction_non_alphanumeric': 0.032661604361370715, 'fraction_numerical': 0.005549065420560747, 'mean_word_length': 4.66289966923925, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Sequential Cost-Sensitive Feature Acquisition

We propose a reinforcement learning based approach to tackle the cost-sensitive learning problem where each input feature has a specific cost. The acquisition process is handled through a stochastic policy which allows features to be acquired in an adaptive way. The general architecture of our approach relies on representation learning to enable performing prediction on any partially observed sample, whatever the set of its observed features are. The resulting model is an original mix of representation learning and of reinforcement learning ideas. It is learned with policy gradient techniques to minimize a budgeted inference cost. We demonstrate the effectiveness of our proposed method with several experiments on a variety of datasets for the sparse prediction problem where all features have the same cost, but also for some cost-sensitive settings.


Introduction
We are concerned here with budgeted learning, where we want to design algorithms that perform optimal compromises between (small) test cost and (high) accuracy. Most of today's machine learning approaches usually assume that the input (i.e its features) is fully observable for free. However, it is often a strong assumption : indeed, each feature may have to be acquired and this acquisition usually has a cost, e.g computational or financial. Hence, in many applications (e.g personalized systems), the prediction performance may be seen as a trade-off between the said prediction accuracy (as in classical machine learning settings), and the cost of the information (i.e features) needed to perform this prediction 3 . A natural approach to optimize such a trade-off is to rely on feature selection through e.g L1 regularization [2] or dimensionality reduction. But it is likely that an optimal feature selection should be sample dependent. A better solution should then be adaptive, i.e the features should be acquired depending on what has been previously gathered and observed, which asks for a sequential acquisition process. Medical diagnosis illustrates this case, where a doctor, to set a diagnosis, only asks for the results of a few exams, which depend on the patient and his previous results on other exams. Moreover, it may happen that the acquisition cost varies from a feature to another, as in medical diagnosis again, where some medical results are cheap to acquire (e.g blood analysis), while other can be quite expensive (e.g fMRI exams). In this cost-sensitive case, lowering the acquisition cost is not only a matter of number of features gathered.
We consider the challenging setting that may be characterized by the following properties: (i) optimality is defined as a trade-off between prediction quality and acquisition cost, (ii) each feature may have a different acquisition cost, (iii) prediction may be made from a partially observed input -i.e with only a subset of its features-, (iv) the optimal subset of features to acquire (to perform accurate prediction) depends on the input sample.
We present in this paper a stochastic sequential method that relies on both reinforcement learning through the use of policy gradient inspired techniques and representation-learning to tie the prediction and acquisition tasks together. Section 2 describes our proposal. We first introduce the generic formulation of our sequential modeling framework and explain how it may be optimized through gradient descent. We then detail how it is mixed with representation learning to enable dealing with our setting. We next report in Section 3 experimental results gained in various settings. Finally section 4 situates our work with respect to the main approaches in the literature.

Cost Sensitive Classification as a Sequential Problem
We consider the classification problem of mapping an input space X to a set of classes Y, where examples x ∈ X have n features (x i denotes the i-th feature of x) (we focus on classification for clarity but our work may be applied straightforwardly to other tasks like regression or ranking). We consider that our model produces a score for each possible category (i.e positive scores for true categories, and negative scores for wrong ones), the quality of the prediction being measured through a loss function ∆ : R Y ×Y → R + (e.g. hinge loss), where we consider the prediction function to output a score for each class (with Y being the cardinality of Y), and we assume that this loss function is differentiable almost everywhere on its first component. This corresponds to the classical context of numerical classifiers like SVM or neural networks.
We focus on predictors that iteratively acquire new features of an input x and that finally perform prediction from the observed partial view of x. To do so, we consider sequential methods that acquire features from x through a series a = (a t ) t=1..T of T acquisition steps (T is a hyper-parameter of the approach) encoded as binary vectors a t ∈ {0; 1} n indicating which features are acquired at time t: a t,i = 1 iff feature i is acquired. The final prediction is made based on the set of features that have been acquired along the acquisition process that we note a = (a 1 , ..., a T ). Notingā ∈ {0; 1} n the vector whose i-th component equals a i = max(a 1,i , ...., a T,i ), i.e. it is 1 iff feature i has been acquired at any step of the process, the final prediction is noted as d(x[ā]) where d is the prediction function and x[ā] stands for the partial view acquired on x along acquisition sequence a. Note that this formalism allows the model to acquire many features at each timestep -while classical existing sequential features acquisition models usually only allow to get the features one by one as explained in Section 4, resulting in a high complexity.
Quite generally, we consider that feature acquisition is a stochastic process that we want to learn, and that every a t is sampled following an acquisition policy denoted π(a t |a 1 , ..., a t−1 , x), which corresponds to the probability of acquiring the features specified in a t , given all previously acquired features. This policy is jointly learned with the prediction function d. The inference algorithm goes like the one described in Algorithm 1. Many feature acquisitions approaches can be expressed within this formalism. For example, static (e.g not adaptive) feature selection corresponds to one step models (T = 1), while decision trees may be thought as acquiring a new feature one at a time that deterministically depend on the values of the features that were previously observed.
We now introduce our objective function. Considering that the feature acquisition cost might not be uniform, we note c i ≥ 0 the acquisition cost of feature i and c the vector of all features' costs. The overall acquisition cost for classifying an input x given an acquisition sequence a is then equal toā .c = n i=1ā i × c i . The cost-sensitive and sequential feature acquisition learning problem may then be cast as the minimization of the following loss function J , which depends on the prediction function d and on the policy π: where λ controls the trade-off between prediction quality and feature acquisition cost, p(x, y) is the unknown underlying data distribution, and E a∼π(a/x) [.] stands for the expectation on the sequence of acquisition a given a particular input sample x and the acquisition policy induced by π.

Policy-Gradient based Learning
In order to simultaneously learn the policy π and the prediction function d, we propose to define these two functions as differentiable parametric functions d θ and π γ , which allows us to use efficient stochastic gradient descent optimization methods. The parameter sets θ and γ are learned by optimizing the empirical cost in Eq. 2 (details on π and d are given later in this Section). We explain now how optimization is performed. Let us rewrite the empirical loss in Equation 2 for a single training example (x, y) (to improve readability), J emp (x, y, γ, θ): To overcome the non differentiability of the max operator inā we propose to upper boundā .c with T t=1 a t .c and to perform the gradient descent over this bound. This bound is exactly equal to J emp when a feature can be acquired only once along an acquisition sequence a. In our implementation we chose not to impose such a constraint which yields this rather tight and easier to optimize (smooth) upper bound. 4 The upper bound on the empirical risk may be rewritten as (omitting details): where π γ (a t,i = 1|x) is the probability of acquiring the i th feature at time-step t.
The first term stands for the prediction quality while the second term is the upper bound on the cost of the acquisition policy. The gradient of this upper bound can be written as follows: The gradient of the prediction quality term may be computed using policygradient based techniques [20,12] (we do not provide details here for space constraint, the final form is detailed later in Eq. 7) and the gradient of the acquisition Algorithm 2 Inference algorithm with representation-based components policy term can be evaluated as follow by using Monte-Carlo approximation over M trail histories, where a is sampled w.r.t π γ (a|x) :

Representing Partially Acquired Data
The last component that completes our proposal (and makes it fully learnable with gradient descent) is a mechanism allowing to iteratively build a representation of an input along the acquisition process, starting with z 1 , then z 2 , up to z T +1 . The successive representations {z t } of x all belong to a common representation space ∀t, z t ∈ Z = R p (with p ≈ 20 in our experiments). This representation space allows expressing any partially observed input x. The inference process -see Algorithm 2 -starts with a null representation of x at step 1, z 1 = 0. Then this representation is refined every iteration t according to z t = Ψ β (z t−1 , x[a t−1 ]), i.e an aggregation between the previous representation and the newly acquired features. The final prediction is performed from the finally obtained representation of x:ŷ = d θ (z T +1 ). Doing so one may define a prediction function operating on Z, d : Z → R Y which is then callable on any partially observed input. We operate the same way for the acquisition policy and we define π γ (a t |a 1 , . . . , a t−1 , When reintroducing these functions and the representations z t into the loss, we get the following gradient estimator: with a t sampled w.r.t. f γ (z t ), and f γ,i is the i-th component of the output of f γ . Note that this gradient can be efficiently computed using back-propagation techniques as it is usually done when using recurrent neural networks for example.
Various instances of the proposed framework can be described, depending on the choices of the f γ , Ψ β and d θ functions. We tested two non-linear functions as aggregation function Ψ β , RNN cells and Gated Recurrent Units (GRUs [6]), and used linear functions for d θ . Regarding f γ , we propose to use a Bernouillibased sampling model (B-REAM) : it samples a t as a set of a bernoulli distribution, i.e each component i of f γ corresponds to the probability of sampling feature x i . This allows to sample multiple features at each time-step, which is an interesting and original property regarding state of the art, and can be implemented using linear functions followed by a sigmoid activation function. Note that one can learn a unique function f γ or one can learn a distinct function f γ for every step (i.e. with its own set of parameters γ t ), which is what we did in our experiments. With our implementation choices, the final representations, hence the final prediction, which are obtained after a sequence of T acquisition steps, are thus highly nonlinear function of the input, giving this model a deep network's like capacity.

Experiments
We present in this section a series of experiments on feature-selection problems and on cost-sensitive setting, conducted on a variety of datasets on the monolabel classification problem.
Experimental protocol: Due to the bi-objective nature of the problem (maximizing accuracy while minimizing the acquisition cost), it is not possible to do cross-validation on multiple batches. We use the following experimental validation protocol, where each dataset has been split in training, validation and testing sets, each split corresponding to one third of the examples: (1) A set of models is learned on the training set with various hyper-parameters values.
(2) We select the models that are on the Pareto front of the accuracy/cost points inferred on the validation set from the previously learned models. (3) We compute accuracy and cost for each of the "Pareto" models on the test set, which are the results reported here.
We have launched a variety of experiments to evaluate our stochastic bernouillibased acquisition model B-REAM. We used a least-square loss function ∆. The experimental results have been obtained with the software provided at http://github.com/ludc/csream and are fully reproducible.
Our method is compared with three state-of-the-art features selection approaches: (i) SVM L 1 is a L 1 regularized linear SVM. (ii) Decision Trees can be seen as particular cases of sequential adaptive predictive models 5 (iii)  Table 1: Accuracy at different cost levels i.e the amount (%) of features used. The accuracy is obtained through a linear interpolation on accuracy/cost curves. The same subset of train/validation/test data have been used for all models for each dataset. Acquiring 25% of the features is equivalent for these datasets to using from 4 features (on letter ) to 41 features (on musk ).
Greedy Miser [23] is a recent cost-sensitive model that relies on several weak classifiers (Decision Trees) where the acquisition cost is integrated as a local and a global constraint. 6 .
Feature Selection Problem: In this setting, we consider that all the features have the same cost, i.e ∀i, c i = 1. We therefore express the cost directly as the percentage of feature gathered regarding the total number of features. It thus corresponds to a problem of adaptive sparse classification. The results obtained on different UCI datasets are summarized in Table 1 for various percentages amount of acquisition. Conjointly, Figure 1 presents the associated accuracy/cost curves on two of these datasets for better illustration. For example, on dataset cardio (Figure 1b  accuracy for the same amount of features. Overall, the results provided in Table 1 illustrate the competitiveness of our approaches in regard to state of the art models (GreedyMiser and other baselines). Yet it is interesting to note that naive baseline such as a Decision Tree can achieve quite good results on few datasets (e.g letter ), and may remain competitive nonetheless on the others. But, on average, B-REAM exhibits a high ability to adaptively select the "good" features, and to simultaneously use the gathered information for prediction.
Cost-sensitive setting: This section focuses on the cost-sensitive setting, where each feature is associated with a particular cost. We propose to study the ability of our approach to tackle such problems on two artificially generated costsensitive datasets (from UCI) and on two cost-sensitive datasets of the literature [15]. Figure 2 illustrates the performance on these 4 different datasets. The Xaxis corresponds to the acquisition cost which is the sum of the costs of the acquired features during inference on the test set. On the 4 datasets, one can see that our B-REAM approach obtain similar results or outperforms GreedyMiser (to which we compare our work since it has been designed for cost sensitive feature acquisition as well). We can observe an interesting behaviour on the two real medical datasets: there exist cost thresholds to reach a given level of accuracy (e.g Figure 2d, when cost ≈ 23, or Figure 2c when cost ≈ 14). This phenomenon is due to the presence of expensive features that clearly bring relevant information. A similar behaviour is observed with GreedyMiser and with B-REAM, but the latter seems more agile and able to better benefit from relevant expensive features 7 . We suppose that this is due to the use of reinforcement-learning in-

Related Work
The feature acquisition problem has been studied by different approaches in the literature. The first propositions were static methods (feature selection), where there is only one step of acquisition and the subset acquired is therefore common to all inputs. [8] presents various methods in this settings such as filter models (e.g variable ranking), and wrapper approaches like [11]. Integration of the feature selection in the learning process has been proposed for example in [2] and [19,18], by using resp. l 1 -norm and l 0 -norm in SVM. Adaptive acquisition approaches were then proposed, for example by estimating the "usefulness" (information value) of the features, as in [3] which present a specific data structure over different runs because resulting accuracy/cost curves are composed of points at different cost/accuracy levels and cannot be matched easily. Yet these curves show significative trends in our opinion.
to do so. Using an estimation of the gain a feature would yield has also been proposed in [4] with greedy strategies to learn a naive Bayes classifier. Reinforcement learning has also been proposed in this setting, to learn a value-function of the information gain [17]. In parallel, several methods relying on decision trees have been presented as they provide efficient adaptive acquisition properties. They are for example used as weak classifiers learned with constraints on the features used in [23,21]. Cascade architecture, e.g [16] or more recently [22], are another important part of the feature acquisition literature, and they usually enable the possibility of early-stopping in the acquisition. The objective is then to learn which features to acquire at each stage of the cascade using for example additive regression method [5]. Block acquisition has been proposed in [13] but the groups of features are pre-assigned. Closer to our work, several methods using a Markov Decision Process formalization or reinforcement learning techniques have been presented. Partiallyobservable MDP with a myopic algorithm is presented in [10], while [1] propose a Markov Decision Directed Acyclic Graph to design a controller that decides between evaluating (a feature), skipping it or classifying. [14] also present a MDPbased model that choose between classifying or acquiring the "next feature" at each step. Regarding reinforcement methods, algorithms to learn acquisition policies have been proposed for example using imitation policies [9], however this requires an oracle to guide learning. [7] presents a method where the "state" of the process is represented as a vector of the acquired features (built following a pre-defined heuristic), this representation state is then used to learn and follow the acquisition policy. Visual attention models such as [12], which often rely on policy-gradient, are also close to our work, while being specific to a particular type of inputs (images). They generally follow a recurrent architecture and aim at predicting locations of a patch of pixels to acquire, instead of a subset of features. Regarding these various methods, our approach differs on several aspects. It is one of the only method, to the best of our knowledge, that relies on representation-learning and reinforcement learning and provides adaptive and batch cost-sensitive acquisition of features without suffering from the combinatorial problem, and without making assumption on the nature of the (partially observed) input.

Conclusion
We presented a generic framework to tackle the problem of adaptive cost-sensitive acquisition. The B-REAM model is based on both reinforcement learning and representation learning techniques, resulting in a stochastic cost-sensitive acquisition model able to acquire block of features. We also showed that the model performs well on different problem settings. This framework allows us to imagine different research directions. We are currently investigating the integration of real-world budgets like CPU consumption or energy footprint. Moreover, it would be an interesting line of future work to see if this type of approach can be learned in a unsupervised way -like auto-encoders -allowing to transfer the features acquisition policy to multiple tasks.