# Q-learning with Nearest Neighbors

We consider the problem of model-free reinforcement learning for infinite-horizon discounted Markov Decision Processes (MDPs) with a continuous state space and unknown transition kernels, when only a single sample path of the system is available. We focus on the classical approach of Q-learning where the goal is to learn the optimal Q-function. We propose the Nearest Neighbor Q-Learning approach that utilizes nearest neighbor regression method to learn the Q function. We provide finite sample analysis of the convergence rate using this method. In particular, we establish that the algorithm is guaranteed to output an ϵ-accurate estimate of the optimal Q-function with high probability using a number of observations that depends polynomially on ϵ and the model parameters. To establish our results, we develop a robust version of stochastic approximation results; this may be of interest in its own right.

## Authors

• 45 publications
• 12 publications
• ### Finite-Sample Analysis for SARSA and Q-Learning with Linear Function Approximation

Though the convergence of major reinforcement learning algorithms has be...
02/06/2019 ∙ by Shaofeng Zou, et al. ∙ 0

• ### Metrics for Finite Markov Decision Processes

We present metrics for measuring the similarity of states in a finite Ma...
07/11/2012 ∙ by Norman Ferns, et al. ∙ 0

• ### Finite-Sample Analysis of Fixed-k Nearest Neighbor Density Functional Estimators

We provide finite-sample analysis of a general framework for using k-nea...
06/05/2016 ∙ by Shashank Singh, et al. ∙ 0

• ### From Predictions to Prescriptions in Multistage Optimization Problems

In this paper, we introduce a framework for solving finite-horizon multi...
04/26/2019 ∙ by Dimitris Bertsimas, et al. ∙ 0

• ### A Hierarchical Multi-Output Nearest Neighbor Model for Multi-Output Dependence Learning

Multi-Output Dependence (MOD) learning is a generalization of standard c...
10/17/2014 ∙ by Richard G. Morris, et al. ∙ 0

• ### On Reinforcement Learning Using Monte Carlo Tree Search with Supervised Learning: Non-Asymptotic Analysis

Inspired by the success of AlphaGo Zero (AGZ) which utilizes Monte Carlo...
02/14/2019 ∙ by Devavrat Shah, et al. ∙ 0

• ### Nonparametric Nearest Neighbor Random Process Clustering

We consider the problem of clustering noisy finite-length observations o...
04/20/2015 ∙ by Michael Tschannen, et al. ∙ 0

##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

Markov Decision Processes (MDPs) are natural models for a wide variety of sequential decision-making problems. It is well-known that the optimal control problem in MDPs can be solved, in principle, by standard algorithms such as value and policy iterations. These algorithms, however, are often not directly applicable to many practical MDP problems for several reasons. First, they do not scale computationally as their complexity grows quickly with the size of the state space and especially for continuous state space. Second, in problems with complicated dynamics, the transition kernel of the underlying MDP is often unknown, or an accurate model thereof is lacking. To circumvent these difficulties, many model-free Reinforcement Learning (RL) algorithms have been proposed, in which one estimates the relevant quantities of the MDPs (e.g., the value functions or the optimal policies) from observed data generated by simulating the MDP.

A popular model-free Reinforcement Learning (RL) algorithm is the so called Q-learning Qlearning , which directly learns the optimal action-value function (or Q function) from the observations of the system trajectories. A major advantage of Q-learning is that it can be implemented in an online, incremental fashion, in the sense that Q-learning can be run as data is being sequentially collected from the system operated/simulated under some policy, and continuously refines its estimates as new observations become available. The behaviors of standard Q-learning in finite state-action problems have by now been reasonably understood; in particular, both asymptotic and finite-sample convergence guarantees have been established Tsitsiklis1994Qlearning ; Jaakkola1994Qlearning ; Szepesy1997Qlearning ; Even-Dar2004Qlearning .

In this paper, we consider the general setting with continuous state spaces. For such problems, existing algorithms typically make use of a parametric function approximation method, such as a linear approximation Melo2008QLearningLinear

, to learn a compact representation of the action-value function. In many of the recently popularized applications of Q-learning, much more expressive function approximation method such as deep neural networks have been utilized. Such approaches have enjoyed recent empirical success in game playing and robotics problems

Silver2016AlphaGo ; Mnih2015Atari ; Duan2016Robotics . Parametric approaches typically require careful selection of approximation method and parametrization (e.g., the architecture of neural networks). Further, rigorous convergence guarantees of Q-learning with deep neural networks are relatively less understood. In comparison, non-parametric approaches are, by design, more flexible and versatile. However, in the context of model-free RL with continuous state spaces, the convergence behaviors and finite-sample analysis of non-parametric approaches are less understood.

Summary of results. In this work, we consider a natural combination of the Q-learning with Kernel-based nearest neighbor regression for continuous state-space MDP problems, denoted as Nearest-Neighbor based Q-Learning (NNQL). As the main result, we provide finite sample analysis of NNQL for a single, arbitrary sequence of data for any infinite-horizon discounted-reward MDPs with continuous state space. In particular, we show that the algorithm outputs an -accurate (with respect to supremum norm) estimate of the optimal Q-function with high probability using a number of observations that depends polynomially on , the model parameters and the “cover time” of the sequence of the data or trajectory of the data utilized. For example, if the data was sampled per a completely random policy, then our generic bound suggests that the number of samples would scale as where is the dimension of the state space. We establish effectively matching lower bound stating that for any policy to learn optimal function within approximation, the number of samples required must scale as . In that sense, our policy is nearly optimal.

Our analysis consists of viewing our algorithm as a special case of a general biased

stochastic approximation procedure, for which we establish non-asymptotic convergence guarantees. Key to our analysis is a careful characterization of the bias effect induced by nearest-neighbor approximation of the population Bellman operator, as well as the statistical estimation error due to the variance of finite, dependent samples. Specifically, the resulting Bellman nearest neighbor operator allows us to connect the update rule of NNQL to a class of stochastic approximation algorithms, which have

biased

Robbins1951stochastic ; Tsitsiklis1994Qlearning . A key step in our analysis involves decomposing the update into two sub-updates, which bears some similarity to the technique used by Jaakkola1994Qlearning . Our results make improvement in characterizing the finite-sample convergence rates of the two sub-updates.

In summary, the salient features of our work are

• [itemsep=0mm,leftmargin=*]

• Unknown system dynamics: We assume that the transition kernel and reward function of the MDP is unknown. Consequently, we cannot exactly evaluate the expectation required in standard dynamic programming algorithms (e.g., value/policy iteration). Instead, we consider a sample-based approach which learns the optimal value functions/policies by directly observing data generated by the MDP.

• Single sample path: We are given a single, sequential samples obtained from the MDP operated under an arbitrary policy. This in particular means that the observations used for learning are dependent. Existing work often studies the easier settings where samples can be generated at will; that is, one can sample any number of (independent) transitions from any given state, or reset the system to any initial state. For example, Parallel Sampling in Kearns1999PQL . We do not assume such capabilities, but instead deal with the realistic, challenging setting with a single path.

• Online computation: We assume that data arrives sequentially rather than all at once. Estimates are updated in an online fashion upon observing each new sample. Moreover, as in standard Q-learning, our approach does not store old data. In particular, our approach differs from other batch methods, which need to wait for all data to be received before starting computation, and require multiple passes over the data. Therefore, our approach is space efficient, and hence can handle the data-rich scenario with a large, increasing number of samples.

• Non-asymptotic, near optimal guarantees: We characterize the finite-sample convergence rate of our algorithm; that is, how many samples are needed to achieve a given accuracy for estimating the optimal value function. Our analysis is nearly tight in that we establish a lower bound that nearly matches our generic upper bound specialized to setting when data is generated per random policy or more generally any policy with random exploration component to it.

While there is a large and growing literature on Reinforcement Learning for MDPs, to the best of our knowledge, ours is the first result on Q-learning that simultaneously has all of the above four features. We summarize comparison with relevant prior works in Table 1. Detailed discussion can be found in Appendix A.

## 2 Setup

In this section, we introduce necessary notations, definitions for the framework of Markov Decision Processes that will be used throughout the paper. We also precisely define the question of interest.

Notation. For a metric space endowed with metric , we denote by the set of all bounded and measurable functions on . For each let be the supremum norm, which turns into a Banach space . Let denote the set of Lipschitz continuous functions on with Lipschitz bound , i.e.,

 Lip(E,M)={f∈C(E)||f(x)−f(y)|≤Mρ(x,y),∀x,y∈E}.

The indicator function is denoted by . For each integer , let

Markov Decision Process. We consider a general setting where an agent interacts with a stochastic environment. This interaction is modeled as a discrete-time discounted Markov decision process (MDP). An MDP is described by a five-tuple , where and are the state space and action space, respectively. We shall utilize to denote time. Let be state at time . At time , the action chosen is denoted as . Then the state evolution is Markovian as per some transition probability kernel with density (with respect to the Lebesgue measure on ). That is,

 Pr(xt+1∈B|xt=x,at=a) =∫Bp(y|x,a)λ(dy) (1)

for any measurable set . The one-stage reward earned at time

is a random variable

with expectation , where is the expected reward function. Finally, is the discount factor and the overall reward of interest is The goal is to maximize the expected value of this reward. Here we consider a distance function so that forms a metric space. For the ease of exposition, we use for the joint state-action space

###### Assumption 1 (MDP Regularity).

We assume that: (A1.) The continuous state space is a compact subset of ; (A2.) is a finite set of cardinality ; (A3.) The one-stage reward is non-negative and uniformly bounded by , i.e., almost surely. For each for some . (A4.) The transition probability kernel satisfies

 ∣∣p(y|x,a)−p(y|x′,a)∣∣≤Wp(y)ρ(x,x′),∀a∈A,∀x,x′,y∈X,

where the function satisfies

The first two assumptions state that the state space is compact and the action space is finite. The third and forth stipulate that the reward and transition kernel are Lipschitz continuous (as a function of the current state). Our Lipschitz assumptions are identical to (or less restricted than) those used in the work of Rust1997 , Chow1991TACmultigrid , and Dufour2015StochasticsMDP . In general, this type of Lipschitz continuity assumptions are standard in the literature on MDPs with continuous state spaces; see, e.g., the work of  Dufour2012AnalAppl ; Dufour2013LP , and Bertsekas1975TACdiscretization .

A Markov policy gives the probability of performing action given the current state . A deterministic policy assigns each state a unique action. The value function for each state under policy , denoted by is defined as the expected discounted sum of rewards received following the policy from initial state i.e., . The action-value function under policy is defined by . The number is called the Q-value of the pair , which is the return of initially performing action at state and then following policy Define

 β≜1/(1−γ)andVmax≜βRmax.

Since all the rewards are bounded by , it is easy to see that the value function of every policy is bounded by  Even-Dar2004Qlearning ; Stehl2006PAC . The goal is to find an optimal policy that maximizes the value from any start state. The optimal value function is defined as , The optimal action-value function is defined as . The Bellman optimality operator is defined as

 (FQ)(x,a) =r(x,a)+γE[maxb∈AQ(x′,b)|x,a]=r(x,a)+γ∫Xp(y|x,a)maxb∈AQ(y,b)λ(dy).

It is well known that is a contraction with factor on the Banach space  (Bertsekas1995DPOC, , Chap. 1). The optimal action-value function is the unique solution of the Bellman’s equation in In fact, under our setting, it can be show that is bounded and Lipschitz. This is stated below and established in Appendix  B.

###### Lemma 1.

Under Assumption 1, the function satisfies that and that for each .

## 3 Reinforcement Learning Using Nearest Neighbors

In this section, we present the nearest-neighbor-based reinforcement learning algorithm. The algorithm is based on constructing a finite-state discretization of the original MDP, and combining Q-learning with nearest neighbor regression to estimate the

-values over the discretized state space, which is then interpolated and extended to the original continuous state space. In what follows, we shall first describe several building blocks for the algorithm in Sections

3.13.4, and then summarize the algorithm in Section 3.5.

### 3.1 State Space Discretization

Let be a pre-specified scalar parameter. Since the state space is compact, one can find a finite set of points in such that

 mini∈[Nh]ρ(x,ci)

The finite grid is called an -net of and its cardinality can be chosen to be the -covering number of the metric space Define . Throughout this paper, we denote by the ball centered at with radius ; that is,

### 3.2 Nearest Neighbor Regression

Suppose that we are given estimated Q-values for the finite subset of states , denoted by . For each state-action pair we can predict its Q-value via a regression method. We focus on nonparametric regression operators that can be written as nearest neighbors averaging in terms of the data of the form

 (ΓNNq)(x,a)=∑ni=1K(x,ci)q(ci,a),∀x∈X,a∈A, (2)

where is a weighting kernel function satisfying Equation (2) defines the so-called Nearest Neighbor (NN) operator , which maps the space into the set of all bounded function over . Intuitively, in (2) one assesses the Q-value of by looking at the training data where the action has been applied, and by averaging their values. It can be easily checked that the operator is non-expansive in the following sense:

 ∥∥ΓNNq−ΓNNq′∥∥∞ ≤∥∥q−q′∥∥∞,∀q,q′∈C(Xh×A). (3)

This property will be crucially used for establishing our results. is assumed to satisfy

 K(x,y)=0  if  ρ(x,y)≥h,∀x∈X,y∈Xh, (4)

where is the discretization parameter defined in Section 3.1.111This assumption is not absolutely necessary, but is imposed to simplify subsequent analysis. In general, our results hold as long as decays sufficiently fast with the distance . This means that the values of states located in the neighborhood of are more influential in the averaging procedure (2). There are many possible choices for . In Section C we describe three representative choices that correspond to -Nearest Neighbor Regression, Fixed-Radius Near Neighbor Regression and Kernel Regression.

### 3.3 A Joint Bellman-NN Operator

Now, we define the joint Bellman-NN (Nearest Neighbor) operator. As will become clear subsequently, it is this operator that the algorithm aims to approximate, and hence it plays a crucial role in the subsequent analysis.

For a function we denote by the nearest-neighbor average extension of to ; that is,

 ~Q(x,a)=(ΓNNq)(x,a),∀(x,a)∈Z.

The joint Bellman-NN operator on is defined by composing the original Bellman operator with the NN operator and then restricting to ; that is, for each ,

 (Gq)(ci,a)≜(FΓNNq)(ci,a) =(F~Q)(ci,a)=r(ci,a)+γE[maxb∈A(ΓNNq)(x′,b)|ci,a]. (5)

It can be shown that is a contraction operator with modulus mapping to itself, thus admitting a unique fixed point, denoted by ; see Appendix E.2.

### 3.4 Covering Time of Discretized MDP

As detailed in Section 3.5 to follow, our algorithm uses data generated by an abritrary policy for the purpose of learning. The goal of our approach is to estimate the Q-values of every state. For there to be any hope to learn something about the value of a given state, this state (or its neighbors) must be visited at least once. Therefore, to study the convergence rate of the algorithm, we need a way to quantify how often samples from different regions of the state-action space .

Following the approach taken by Even-Dar2004Qlearning and Azar2011SQL , we introduce the notion of the covering time of MDP under a policy . This notion is particularly suitable for our setting as our algorithm is based on asynchronous Q-learning (that is, we are given a single, sequential trajectory of the MDP, where at each time step one state-action pair is observed and updated), and the policy may be non-stationary. In our continuous state space setting, the covering time is defined with respect to the discretized space , as follows:

###### Definition 1 (Covering time of discretized MDP).

For each and , a ball-action pair is said to be visited at time if and . The discretized state-action space is covered by the policy if all the ball-action pairs are visited at least once under the policy . Define , the covering time of the MDP under the policy , as the minimum number of steps required to visit all ball-action pairs starting from state at time-step Formally, is defined as

 min{s≥0:xt=x, ∀i≤Nh,a∈A, ∃ti,a∈[t,t+s],~{}such~{}that~{}xti,a∈Bi and ati,a=a,~{}under~{}π},

with notation that minimum over empty set is .

We shall assume that there exists a policy with bounded expected cover time, which guarantees that, asymptotically, all the ball-action pairs are visited infinitely many times under the policy

###### Assumption 2.

There exists an integer such that , Here the expectation is defined with respect to randomness introduced by Markov kernel of MDP as well as the policy .

In general, the covering time can be large in the worst case. In fact, even with a finite state space, it is easy to find examples where the covering time is exponential in the number of states for every policy. For instance, consider an MDP with states , where at any state , the chain is reset to state 1 with probability regardless of the action taken. Then, every policy takes exponential time to reach state starting from state , leading to an exponential covering time.

To avoid the such bad cases, some additional assumptions are needed to ensure that the MDP is well-behaved. For such MDPs, there are a variety of polices that have a small covering time. Below we focus on a class of MDPs satisfying a form of the uniform ergodic assumptions, and show that the standard -greedy policy (which includes the purely random policy as special case by setting ) has a small covering time. This is done in the following two Propositions. Proofs can be found in Appendix D.

###### Proposition 1.

Suppose that the MDP satisfies the following: there exists a probability measure on , a number and an integer such that for all all and all policies ,

 Prμ(xm+t∈⋅|xt=x) ≥φν(⋅). (6)

Let , where we recall that is the cardinality of the discretized state space. Then the expected covering time of -greedy is upper bounded by .

###### Proposition 2.

Suppose that the MDP satisfies the following: there exists a probability measure on , a number and an integer such that for all all , there exists a sequence of actions ,

 Pr(xm+t∈⋅|xt=x,at=^a1,…,at+m−1=^am) ≥φν(⋅). (7)

Let , where we recall that is the cardinality of the discretized state space. Then the expected covering time of -greedy is upper bounded by .

### 3.5 Q-learning using Nearest Neighbor

We describe the nearest-neighbor Q-learning (NNQL) policy. Like Q-learning, it is a model-free policy for solving MDP. Unlike standard Q-learning, it is (relatively) efficient to implement as it does not require learning the Q function over entire space . Instead, we utilize the nearest neighbor regressed Q function using the learned Q values restricted to . The policy assumes access to an existing policy (which is sometimes called the “exploration policy”, and need not have any optimality properties) that is used to sample data points for learning.

The pseudo-code of NNQL is described in Policy 1. At each time step , action is performed from state as per the given (potentially non-optimal) policy , and the next state is generated according to Note that the sequence of observed states take continuous values in the state space .

The policy runs over iteration with each iteration lasting for a number of time steps. Let denote iteration count, denote time when iteration starts for . Initially, , , and for , the policy is in iteration . The iteration is updated from to when starting with , all ball-action pairs have been visited at least once. That is, In the policy description, the counter records how many times the ball-action pair has been visited from the beginning of iteration till the current time ; that is, By definition, the iteration ends at the first time step for which .

During each iteration, the policy keeps track of the Q-function over the finite set . Specifically, let denote the approximate Q-values on within iteration . The policy also maintains , which is a biased empirical estimate of the joint Bellman-NN operator applied to the estimates . At each time step within iteration , if the current state falls in the ball , then the corresponding value is updated as

 (Gkqk)(ci,at) =(1−ηN)(Gkqk)(ci,at)+ηN(Rt+γmaxb∈A(ΓNNqk)(Yt+1,b)), (8)

where . We notice that the above update rule computes, in an incremental fashion, an estimate of the joint Bellman-NN operator applied to the current for each discretized state-action pair , using observations that fall into the neighborhood of . This nearest-neighbor approximation causes the estimate to be biased.

At the end of iteration , i.e., at time step , a new is generated as follows: for each ,

 qk+1(ci,a) =(1−αk)qk(ci,a)+αk(Gkqk)(ci,a). (9)

At a high level, this update is similar to standard Q-learning updates — the Q-values are updated by taking a weighted average of , the previous estimate, and , an one-step application of the Bellman operator estimated using newly observed data. There are two main differences from standard Q-learning: 1) the Q-value of each is estimated using all observations that lie in its neighborhood — a key ingredient of our approach; 2) we wait until all ball-action pairs are visited to update their Q-values, all at once.

Given the output of Policy 1, we obtain an approximate Q-value for each (continuous) state-action pair via the nearest-neighbor average operation, i.e., here the superscript emphasizes that the algorithm is run for time steps with a sample size of .

## 4 Main Results

As a main result of this paper, we obtain finite-sample analysis of NNQL policy. Specifically, we find that the NNQL policy converges to an -accurate estimate of the optimal with time that has polynomial dependence on the model parameters. The proof can be found in Appendix E.

###### Theorem 1.

Suppose that Assumptions 1 and 2 hold. With notation and , for a given , define Let be the -covering number of the metric space For a universal constant , after at most

 T=C0Lh∗V3maxβ4ε3log(2δ)log(Nh∗|A|V2maxβ4δε2)

steps, with probability at least , we have

The theorem provides sufficient conditions for NNQL to achieve accuracy (in sup norm) for estimating the optimal action-value function . The conditions involve the bandwidth parameter and the number of time steps , both of which depend polynomially on the relevant problem parameters. Here an important parameter is the covering number : it provides a measure of the “complexity” of the state space , replacing the role of the cardinality in the context of discrete state spaces. For instance, for a unit volume ball in the corresponding covering number scales as  (cf. Proposition 4.2.12 in vershynin_hdpbook ). We take note of several remarks on the implications of the theorem.

Sample complexity: The number of time steps , which also equals the number of samples needed, scales linearly with the covering time of the underlying policy to sample data for the given MDP. Note that depends implicitly on the complexities of the state and action space as measured by and . In the best scenario, , and hence as well, is linear in (up to logarithmic factors), in which case we achieve (near) optimal linear sample complexity. The sample complexity also depends polynomially on the desired accuracy and the effective horizon of the discounted MDP — optimizing the exponents of the polynomial dependence remains interesting future work.

Space complexity: The space complexity of NNQL is , which is necessary for storing the values of . Note that NNQL is a truly online algorithm, as each data point is accessed only once upon observation and then discarded; no storage of them is needed.

Computational complexity: In terms of computational complexity, the algorithm needs to compute the NN operator and maximization over in each time step, as well as to update the values of for all and in each iteration. Therefore, the worst-case computational complexity per time step is , with an overall complexity of . The computation can be potentially sped up by using more efficient data structures and algorithms for finding (approximate) nearest neighbors, such as k-d trees Bentley1979kdtree , random projection trees Dasgupta2008random , Locality Sensitive Hashing Indyk1998LSH and boundary trees Mathy2015boundary .

Choice of : NNQL requires as input a user-specified parameter , which determines the discretization granularity of the state space as well as the bandwidth of the (kernel) nearest neighbor regression. Theorem 1 provides a desired value , where we recall that is the Lipschitz parameter of the optimal action-value function (see Lemma 1). Therefore, we need to use a small if we demand a small error , or if fluctuates a lot with a large .

### 4.1 Special Cases and Lower Bounds

Theorem 1, combined with Proposition 1, immediately yield the following bound that quantify the number of samples required to obtain an -optimal action-value function with high probability, if the sample path is generated per the uniformly random policy. The proof is given in Appendix F.

###### Corollary 1.

Suppose that Assumptions 1 and 2 hold, with Assume that the MDP satisfies the following: there exists a uniform probability measure over , a number and an integer such that for all all and all policies , After at most

 T=κ1εd+3log3(1δε)

steps, where is a number independent of and , we have with probability at least .

Corollary 1 states that the sample complexity of NNQL scales as We will show that this is effectively necessary by establishing a lower bound on any algorithm under any sampling policy! The proof of Theorem 2 can be found in Appendix G.

###### Theorem 2.

For any reinforcement learning algorithm and any number , there exists an MDP problem and some number such that

 Pr[∥∥^QT−Q∗∥∥∞≥C(logTT)12+d]≥δ,for all T≥Tδ,

where is a constant. Consequently, for any reinforcement learning algorithm and any sufficiently small , there exists an MDP problem such that in order to achieve

 Pr[∥∥^QT−Q∗∥∥∞<ε]≥1−δ,

one must have

 T≥C′d(1ε)2+dlog(1ε),

where is a constant.

## 5 Conclusions

In this paper, we considered the reinforcement learning problem for infinite-horizon discounted MDPs with a continuous state space. We focused on a reinforcement learning algorithm NNQL that is based on kernelized nearest neighbor regression. We established nearly tight finite-sample convergence guarantees showing that NNQL can accurately estimate optimal Q function using nearly optimal number of samples. In particular, our results state that the sample, space and computational complexities of NNQL scale polynomially (sometimes linearly) with the covering number of the state space, which is continuous and has uncountably infinite cardinality.

In this work, the sample complexity analysis with respect to the accuracy parameter is nearly optimal. But its dependence on the other problem parameters is not optimized. This will be an important direction for future work. It is also interesting to generalize approach to the setting of MDP beyond infinite horizon discounted problems, such as finite horizon or average-cost problems. Another possible direction for future work is to combine NNQL with a smart exploration policy, which may further improve the performance of NNQL. It would also be of much interest to investigate whether our approach, specifically the idea of using nearest neighbor regression, can be extended to handle infinite or even continuous action spaces.

## Acknowledgment

This work is supported in parts by NSF projects CNS-1523546, CMMI-1462158 and CMMI-1634259 and MURI 133668-5079809.

## References

• [1] A. Antos, C. Szepesvári, and R. Munos. Learning near-optimal policies with Bellman-residual minimization based fitted policy iteration and a single sample path. Machine Learning, 71(1):89–129, 2008.
• [2] M. G. Azar, R. Munos, M. Ghavamzadeh, and H. J. Kappen. Reinforcement learning with a near optimal rate of convergence. Technical Report, 2011.
• [3] M. G. Azar, R. Munos, M. Ghavamzadeh, and H. J. Kappen. Speedy Q-learning. In NIPS, 2011.
• [4] A. Barreto, D. Precup, and J. Pineau. Practical kernel-based reinforcement learning. The Journal of Machine Learning Research, 17(1):2372–2441, 2016.
• [5] J. L. Bentley. Multidimensional binary search trees in database applications. IEEE Transactions on Software Engineering, (4):333–340, 1979.
• [6] D. Bertsekas. Convergence of discretization procedures in dynamic programming. IEEE Transactions on Automatic Control, 20(3):415–419, 1975.
• [7] D. P. Bertsekas. Dynamic programming and optimal control, volume II. Athena Scientific, Belmont, MA, 3rd edition, 2007.
• [8] Jalaj Bhandari, Daniel Russo, and Raghav Singal. A finite time analysis of temporal difference learning with linear function approximation. In Sébastien Bubeck, Vianney Perchet, and Philippe Rigollet, editors, Proceedings of the 31st Conference On Learning Theory, volume 75 of Proceedings of Machine Learning Research, pages 1691–1692. PMLR, 06–09 Jul 2018.
• [9] N. Bhat, V. F. Farias, and C. C. Moallemi. Non-parametric approximate dynamic programming via the kernel method. In NIPS, 2012.
• [10] C.-S. Chow and J. N. Tsitsiklis. The complexity of dynamic programming. Journal of Complexity, 5(4):466–488, 1989.
• [11] C.-S. Chow and J. N. Tsitsiklis. An optimal one-way multigrid algorithm for discrete-time stochastic control. IEEE Transactions on Automatic Control, 36(8):898–914, 1991.
• [12] Gal Dalal, Balázs Szörényi, Gugan Thoppe, and Shie Mannor. Finite sample analysis for TD(0) with linear function approximation. arXiv preprint arXiv:1704.01161, 2017.
• [13] S. Dasgupta and Y. Freund. Random projection trees and low dimensional manifolds. In

Proceedings of the Fortieth Annual ACM Symposium on Theory of Computing

, pages 537–546. ACM, 2008.
• [14] Y. Duan, X. Chen, R. Houthooft, J. Schulman, and P. Abbeel. Benchmarking deep reinforcement learning for continuous control. In International Conference on Machine Learning, pages 1329–1338, 2016.
• [15] F. Dufour and T. Prieto-Rumeau. Approximation of Markov decision processes with general state space. Journal of Mathematical Analysis and applications, 388(2):1254–1267, 2012.
• [16] F. Dufour and T. Prieto-Rumeau.

Finite linear programming approximations of constrained discounted Markov decision processes.

SIAM Journal on Control and Optimization, 51(2):1298–1324, 2013.
• [17] F. Dufour and T. Prieto-Rumeau. Approximation of average cost Markov decision processes using empirical distributions and concentration inequalities. Stochastics: An International Journal of Probability and Stochastic Processes, 87(2):273–307, 2015.
• [18] E. Even-Dar and Y. Mansour. Learning rates for Q-learning. JMLR, 5, December 2004.
• [19] W. B. Haskell, R. Jain, and D. Kalathil. Empirical dynamic programming. Mathematics of Operations Research, 41(2), 2016.
• [20] H. V. Hasselt. Double Q-learning. In NIPS. 2010.
• [21] P. Indyk and R. Motwani.

Approximate nearest neighbors: towards removing the curse of dimensionality.

In Proceedings of the Thirtieth Annual ACM Symposium on Theory of Computing, pages 604–613. ACM, 1998.
• [22] T. Jaakkola, M. I. Jordan, and S. P. Singh. On the convergence of stochastic iterative dynamic programming algorithms. Neural Comput., 6(6), 1994.
• [23] M. Kearns and S. Singh. Finite-sample convergence rates for Q-learning and indirect algorithms. In NIPS, 1999.
• [24] S. H. Lim and G. DeJong. Towards finite-sample convergence of direct reinforcement learning. In Proceedings of the 16th European Conference on Machine Learning, pages 230–241. Springer-Verlag, 2005.

Proceedings of the Thirty-First Conference on Uncertainty in Artificial Intelligence

, pages 504–513. AUAI Press, 2015.
• [26] C. Mathy, N. Derbinsky, J. Bento, J. Rosenthal, and J. S. Yedidia.

The boundary forest algorithm for online supervised and unsupervised learning.

In Twenty-Ninth AAAI Conference on Artificial Intelligence, pages 2864–2870, 2015.
• [27] F. S. Melo, S. P. Meyn, and M. I. Ribeiro. An analysis of reinforcement learning with function approximation. In Proceedings of the 25th international conference on Machine learning, pages 664–671. ACM, 2008.
• [28] Francisco S Melo and M Isabel Ribeiro. Q-learning with linear function approximation. In

International Conference on Computational Learning Theory

, pages 308–322. Springer, 2007.
• [29] V. Mnih, K. Kavukcuoglu, D. Silver, A. A. Rusu, J. Veness, M. G. Bellemare, A. Graves, M. Riedmiller, A. K Fidjeland, and G. Ostrovski. Human-level control through deep reinforcement learning. Nature, 518(7540):529–533, 2015.
• [30] R. Munos and C. Szepesvári. Finite-time bounds for fitted value iteration. Journal of Machine Learning Research, 9(May):815–857, 2008.
• [31] E. A. Nadaraya. On estimating regression. Theory of Probability & Its Applications, 9(1):141–142, 1964.
• [32] D. Ormoneit and P. Glynn. Kernel-based reinforcement learning in average-cost problems. IEEE Trans. Automatic Control, 47(10), 2002.
• [33] D. Ormoneit and Ś. Sen. Kernel-based reinforcement learning. Mach. Learning, 49(2-3), 2002.
• [34] Jason Pazis and Ronald Parr. PAC optimal exploration in continuous space Markov decision processes. In Proceedings of the Twenty-Seventh AAAI Conference on Artificial Intelligence, pages 774–781. AAAI Press, 2013.
• [35] H. Robbins and S. Monro. A stochastic approximation method. The Annals of Mathematical Statistics, pages 400–407, 1951.
• [36] J. Rust. Using randomization to break the curse of dimensionality. Econometrica, 65(3), 1997.
• [37] N. Saldi, S. Yuksel, and T. Linder. On the asymptotic optimality of finite approximations to markov decision processes with borel spaces. Math. of Operations Research, 42(4), 2017.
• [38] D. Silver, A. Huang, C. J. Maddison, A. Guez, L. Sifre, G. Van Den Driessche, J. Schrittwieser, I. Antonoglou, V. Panneershelvam, and M. Lanctot. Mastering the game of go with deep neural networks and tree search. Nature, 529(7587):484–489, 2016.
• [39] Charles J. Stone. Optimal global rates of convergence for nonparametric regression. The Annals of Statistics, pages 1040–1053, 1982.
• [40] A. L Strehl, L. Li, E. Wiewiora, J. Langford, and M. L. Littman. PAC model-free reinforcement learning. In ICML, 2006.
• [41] C. Szepesvári. The asymptotic convergence-rate of Q-learning. In NIPS, 1997.
• [42] C. Szepesvári and W. D. Smart. Interpolation-based Q-learning. In Proceedings of the Twenty-First International Conference on Machine learning, page 100. ACM, 2004.
• [43] J. N. Tsitsiklis. Asynchronous stochastic approximation and Q-learning. Mach. Learning, 16(3), 1994.
• [44] J. N. Tsitsiklis and B. Van Roy. An analysis of temporal-difference learning with function approximation. IEEE Trans. Automatic Control, 42(5), 1997.
• [45] Alexandre B. Tsybakov. Introduction to Nonparametric Estimation. Springer Series in Statistics. Springer, 2009.
• [46] Roman Vershynin. High-Dimensional Probability: An Introduction with Applications in Data Science. Cambridge University Press, 2017.
• [47] C. J. C. H. Watkins and P. Dayan. Q-learning. Mach. learning, 8(3-4), 1992.
• [48] G. S. Watson.

Smooth regression analysis.

Sankhyā: The Indian Journal of Statistics, Series A, pages 359–372, 1964.

## Appendix A Related works

Given the large body of relevant literature, even surveying the work on Q-learning in a satisfactory manner is beyond the scope of this paper. Here we only mention the most relevant prior works, and compare them to ours in terms of the assumptions needed, the algorithmic approaches considered, and the performance guarantees provided. Table 1 provides key representative works from the literature and contrasts them with our result.

Q-learning has been studied extensively for finite-state MDPs. [43] and [22] are amongst the first to establish its asymptotic convergence. Both of them cast Q-learning as a stochastic approximation scheme — we utilize this abstraction as well. More recent work studies non-asymptotic performance of Q-learning; see, e.g., [41], [18], and [24]. Many variants of Q-learning have also been proposed and analyzed, including Double Q-learning [20], Speedy Q-learning [3], Phased Q-learning [23] and Delayed Q-learning [40].

A standard approach for continuous-state MDPs with known transition kernels, is to construct a reduced model by discretizing state space and show that the new finite MDP approximates the original one. For example, Chow and Tsitsiklis establish approximation guarantees for a multigrid algorithm when the state space is compact [10, 11]. This result is recently extended to average-cost problems and to general Borel state and action spaces in [37]. To reduce the computational complexity, Rust proposes a randomized version of the multigrid algorithm and provides a bound on its approximation accuracy [36]. Our approach bears some similarities to this line of work: we also use state space discretization, and impose similar continuity assumptions on the MDP model. However, we do not require the transition kernel to be known, nor do we construct a reduced model; rather, we learn the action-value function of the original MDP directly by observing its sample path.

The closest work to this paper is by Szepesvari and Smart [42], wherein they consider a variant of Q-learning combined with local function approximation methods. The algorithm approximates the optimal Q-values at a given set of sample points and interpolates it for each query point. Follow-up work considers combining Q-learning with linear function approximation [28]. Despite algorithmic similarity, their results are distinct from ours: they establish asymptotic convergence of the algorithm, based on the assumption that the data-sampling policy is stochastic stationary. In contrast, we provide finite-sample bounds, and our results apply for arbitrary sample paths (including non-stationary policies). Consequently, our analytical techniques are also different from theirs.

Some other closely related work is by Ormoneit and coauthors on model-free reinforcement learning for continuous state with unknown transition kernels [33, 32]. Their approach, called KBRL, constructs a kernel-based approximation of the conditional expectation that appears in the Bellman operator. Value iteration can then be run using the approximate Bellman operator, and asymptotic consistency is established for the resulting fixed points. A subsequent work demonstrates applicability of KBRL to practical large-scale problems [4]. Unlike our approach, KBRL is an offline, batch algorithm in which data is sampled at once and remains the same throughout the iterations of the algorithm. Moreover, the aforementioned work does not provide convergence rate or finite-sample performance guarantee for KBRL. The idea of approximating the Bellman operator by an empirical estimate, has also been used in the context of discrete state-space problems [19]. The approximate operator is used to develop Empirical Dynamic Programming (EDP) algorithms including value and policy iterations, for which non-asymptotic error bounds are provided. EDP is again an offline batch algorithm; moreover, it requires multiple, independent transitions to be sampled for each state, and hence does not apply to our setting with a single sample path.

In terms of theoretical results, most relevant is the work in [30], who also obtain finite-sample performance guarantees for continuous space problems with unknown transition kernels. Extension to the setting with a single sample path is considered in [1]. The algorithms considered therein, including fitted value iteration and Bellman-residual minimization based fitted policy iteration, are different from ours. In particular, these algorithms perform updates in a batch fashion and require storage of all the data throughout the iterations.

There are other papers that provide finite-sample guarantees, such as  [25, 12]; however, their settings (availability of i.i.d. data), algorithms (TD learning) and proof techniques are very different from ours. The work by Bhandari et al.  [8] also provides a finite sample analysis of TD learning with linear function approximation, for both the i.i.d. data model and a single trajectory. We also note that the work on PAC-MDP methods [34] explores the impact of exploration policy on learning performance. The focus of our work is estimation of Q-functions rather than the problem of exploration; nevertheless, we believe it is an interesting future direction to study combining our algorithm with smart exploration strategies.

## Appendix B Proof of Lemma 1

###### Proof.

Let be the set of all functions such that Let be the set of all functions such that . Take any , and fix an arbitrary . For any , we have

 |(Fu)(x,a)|=∣∣∣r(x,a)+γE[maxb∈Au(Z,b)|x,a]∣∣∣≤Rmax+γVmax=Vmax,

where the last equality follows from the definition of . This means that . Also, for any , we have

 |(Fu)(x,a)−(Fu)(y,a)| ≤|r(x,a)−r(y,a)|+γ∣∣∣∫Xmaxb∈Au(z,b)(p(z|x,a)−p(z|y,a))λ(dz)∣∣∣ ≤Mrρ(x,y)+γ∫X∣∣∣maxb∈Au(z,b)(p(z|x,a)−p(z|y,a))∣∣∣λ(dz) ≤Mrρ(x,y)+γ∥u∥∞⋅∫X|p(z|x,a)−p(z|y,a)|λ(dz) ≤[Mr+γVmaxMp]ρ(x,y).

This means that , so . Putting together, we see that maps to , which in particular implies that maps to itself. Since is closed and is -contraction, both with respect to , the Banach fixed point theorem guarantees that has a unique fixed point . This completes the proof of the lemma. ∎

## Appendix C Examples of Nearest Neighbor Regression Methods

Below we describe three representative nearest neighbor regression methods, each of which corresponds to a certain choice of the kernel function in the averaging procedure (2).

• -nearest neighbor (-NN) regression: For each we find its nearest neighbors in the subset and average their Q-values, where is a pre-specified number. Formally, let denote the -th closest data point to amongst the set Thus, the distance of each state in to satisfies Then the -NN estimate for the Q-value of is given by This corresponds to using in (2) the following weighting function

 K(x,ci)=1k1{ρ(x,ci)≤ρ(x,c(k)(x))}.

Under the definition of in Section 3.1, the assumption (4) is satisfied if we use . For other values of , the assumption holds with a potentially different value of .

• Fixed-radius near neighbor regression: We find all neighbors of up to a threshold distance and average their Q-values. The definition of ensures that at least one point is within the threshold distance , i.e., such that . We then can define the weighting function function according to

 K(x,ci)=1{ρ(x,ci)≤h}∑nj=11{ρ(x,cj)≤h}.
• Kernel regression: Here the Q-values of the neighbors of are averaged in a weighted fashion according to some kernel function [31, 48]. The kernel function takes as input a distance (normalized by the bandwidth parameter ) and outputs a similarity score between and Then the weighting function is given by

 K(x,ci)=ϕ(ρ(x,ci)h)∑nj=1ϕ(ρ(x,cj)h).

For example, a (truncated) Gaussian kernel corresponds to . Choosing reduces to the fixed-radius NN regression described above.

## Appendix D Bounds on Covering time

### d.1 Proof of Proposition 1

###### Proof.

Without loss of generality, we may assume that the balls are disjoint, since the covering time will only become smaller if they overlap with each other. Note that under -greedy policy, equation (6) implies that

 Pr(xm+t∈⋅,am+t=a|xt=x)≥ε|A|ψν(⋅). (10)

First assume that the above assumption holds with . Let be the total number of ball-action pairs. Let be a fixed ordering of these pairs. For each integer , let be the number of ball-action pairs visited up to time . Let be the first time when all ball-action pairs are visited. For each , let be the the first time when pairs are visited, and let be the time to visit the -th pair after pairs have been visited. We use the convention that . By definition, we have

When pairs have been visited, the probability of visiting a new pair is at least

 minI⊆[M],|I|=M−k+1Pr((xTk−1+1,aTk−1+1)∈⋃i∈IPi|xTk−1) = minI⊆[M],|I|=M−k+1∑i∈IPr((xTk−1+1,aTk−1+1)∈Pi|xTk−1) ≥ (M−k+1)mini∈[M]Prπ((xTk−1+1,aTk−1+1)∈Pi|xTk−1) ≥ (M−k+1)⋅φνmin⋅ε|A|,

where the last inequality follows from Eq. (10). Therefore, is stochastically dominated by a geometric random variable with mean at most It follows that

 ET =M∑k=1EDk≤M∑k=1|A|(M−k+1)εφνmin=O(|A|εφνminlogM).

This prove the proposition for .

For general values of , the proposition follows from a similar argument by considering the MDP only at times

### d.2 Proof of Proposition 2

###### Proof.

We shall use a line of argument similar to that in the proof of Proposition 1. We assume that the balls are disjoint. Note that under -greedy policy , for all for all we have

 Prπ(at=^a1,…,at+m−1=^am|xt=x)≥(ε|A|