Concepts / Feature Construction for Linear Function Approximation

Feature Construction for Linear Function Approximation

Each OrderN polynomial basis function multiplies one powered term for every state variable.

  • Programming

From State to Features

A reinforcement learning system does not have to learn directly from an undifferentiated description of a state. It can first transform the state into a collection of features. A linear value approximator then combines those feature values with weights to produce an estimated value. This makes feature construction a central design decision: the learning method matters, but the representation supplied to it matters as well.

For an OrderN polynomial basis, begin with a state containing d real-valued variables. Each basis function chooses one integer exponent for every state variable. The function then raises each variable to its chosen exponent and multiplies all of those powered terms together. The full basis contains every function formed from the allowed exponent choices.

s₁state variablecᵢ,₁integer power×combine termss₂state variablecᵢ,₂integer powerφᵢ(s)one basis featureraise to cᵢ,₁sets powerraise to cᵢ,₂ and multiplysets powerproduces
How does each exponent vector determine one polynomial feature by multiplying powered terms from all state variables?

Exponent Vectors

Definition

For the ith polynomial basis function, cᵢ,ⱼ denotes the integer exponent selected for state variable j. The complete exponent vector for that function contains one such exponent for each of the d state variables.

In an OrderN basis, every exponent may be any integer from 0 through N. The exponent choices are independent across the state variables: choose one allowed power for the first variable, one for the second, and continue until every variable has a power. Each complete set of choices identifies one basis function.

Worked example

A Two-Variable Basis Function

Construct the function determined by the exponent pair (1, 2) for state variables s₁ and s₂.

  1. 1
    Choose the first exponent

    The first exponent is 1, so the first state variable contributes s₁¹.

  2. 2
    Choose the second exponent

    The second exponent is 2, so the second state variable contributes s₂².

  3. 3
    Multiply the powered terms

    The basis function multiplies the contribution from every state variable.

Result

The resulting function is s₁s₂².

Variable 1N + 1 choicesVariable 2N + 1 choicesVariable dN + 1 choicesOrderN basis(N + 1)^d functionscombine choicescombine choicescombine choices
How do the allowed exponent combinations map to the total number of polynomial basis functions?

Counting the Basis

Formula, step by step
  1. 1
    Each of the d state variables has N + 1 allowed exponent choices: 0, 1, and every integer through N.
  2. 2
    One basis function requires one exponent choice for every state variable.
  3. 3
    Combining the choices across all d variables gives (N + 1)d different exponent vectors.
  4. 4
    Each exponent vector produces one polynomial basis function.
Worked example

A Small Two-Variable Basis

Determine how many functions are in an Order2 polynomial basis for d = 2 state variables, then list the exponent pairs.

  1. 1
    Count choices for each variable

    Because N = 2, each exponent can be 0, 1, or 2. Each variable therefore has 3 choices.

  2. 2
    Count all pairs

    There are 3 choices for the first exponent and 3 choices for the second, giving 3 × 3 = 9 exponent pairs.

  3. 3
    List the pairs

    The pairs are (0,0), (0,1), (0,2), (1,0), (1,1), (1,2), (2,0), (2,1), and (2,2).

  4. 4
    Translate pairs into products

    Each pair supplies the powers for s₁ and s₂ in one product.

Result

The basis contains 9 functions: 1, s₂, s₂², s₁, s₁s₂, s₁s₂², s₁², s₁²s₂, and s₁²s₂².

The two-variable case can be pictured as a grid of exponent pairs. Moving across the grid changes the exponent for one variable, while moving in the other direction changes the exponent for the other variable. The important counting rule remains the same: every allowed combination is included, not only products in which both variables appear with positive powers.

Weighted Value Estimates

After a state has been converted into feature values, a linear function approximator combines those values with weights through a weighted sum. The features describe the representation supplied to the approximator; the weights determine how strongly the approximator uses those features in its value estimate.

Feature 1φ₁(s)Feature 2φ₂(s)Feature mφₘ(s)Weightsw₁, w₂, ..., wₘWeighted sumcombine productsEstimated valueV̂(s)multiply by w₁multiply by w₂multiply by wₘset coefficientsproduces
How do feature values flow into a weighted sum to produce the estimated value of a state?
Worked example

Combining Three Features

A state is represented by three feature values, and the approximator has three corresponding weights. Describe how the estimate is formed.

  1. 1
    Represent the state

    Evaluate the selected features for the state.

  2. 2
    Pair features with weights

    Each feature value is combined with its corresponding weight.

  3. 3
    Add the weighted contributions

    The linear approximator sums the contributions to form one value estimate.

Result

The estimate is a weighted sum of the three feature values.

Representation as Prior Knowledge

Feature selection is a way to place prior domain knowledge into a reinforcement learning system. Instead of presenting the learning method with an undifferentiated description, the designer chooses a representation that emphasizes useful patterns in the problem. A linear approximator can therefore be useful when its features are chosen appropriately; judging the learning method without considering the representation can give the wrong impression about what it can learn.

Polynomialspowered productsFourier basisfeature representationCoarse codingfeature representationTile codingfeature representationRadial basisfunctionsfeature representationTask representationchosen by the designerone possible choiceone possible choiceone possible choiceone possible choiceone possible choice
What is the high-level difference among the representation families named in the source?
RepresentationHigh-level role supported by the source
Polynomial basisConstructs features by multiplying powered terms from the state variables.
Fourier basis featuresProvides an alternative way to represent a task.
Coarse codingProvides an alternative way to represent a task.
Tile codingProvides an alternative way to represent a task.
Radial basis functionsProvides an alternative way to represent a task.

The source identifies these as different representation choices. It does not specify their internal construction in this section.

LSTD Trade-offs

The source characterizes LSTD as favoring data efficiency while having a higher computational scaling cost than the other linear methods described. This is a practical trade-off: LSTD can make better use of available data, but the additional computational cost must be considered when choosing an approximation method.

LSTDlinear methodOther linear methodscomparison groupData efficiencyLSTD favoredComputational scalingcostLSTD higherfavorsrequires morerelative comparisonlower relative scaling cost
How does LSTD trade additional computation for improved data efficiency compared with simpler incremental updates?

Linear and Nonlinear Directions

Linear approximation and nonlinear approximation represent two different modeling directions. In the linear case, selected features and weights are combined through a weighted sum. The source reports that the linear case is especially well understood theoretically and that semi-gradient methods can obtain good results in this setting when the features are appropriate.

Nonlinear methods include artificial neural networks trained by backpropagation and variations of stochastic gradient descent. Their popularity in reinforcement learning has led to the term deep reinforcement learning. The essential contrast for this topic is that linear approximation relies on a chosen feature representation and a weighted sum, whereas these nonlinear methods use neural-network training methods.

StateStateSelected featuresrepresentationArtificial neuralnetworktrained by backpropagationWeightsweighted sumStochastic gradientdescenttraining variationValue estimateValue estimatetransformcombineproduceinputtrained withsupports
How does information flow through a feature-weight model compared with a nonlinear method used in deep reinforcement learning?

Mistakes to Avoid

  • Common mistake

    Counting only the products in which every state variable appears with a positive power.

    What it looks like

    For two variables and Order2, excluding exponent 0 would omit pairs such as (2,0).

    Why it fails

    The allowed exponent range includes 0 through N.

    Do this instead

    Include every exponent combination, including combinations with one or more zero exponents.

  • Common mistake

    Using Nd instead of (N + 1)d.

    What it looks like

    For Order2, the choices are 0, 1, and 2, which gives 3 choices per variable rather than 2.

    Why it fails

    There are N + 1 integer choices from 0 through N.

    Do this instead

    Count the endpoints as well as the values between them.

  • Common mistake

    Treating one exponent pair as the whole basis.

    What it looks like

    The pair (1,2) produces one function, s₁s₂², not the complete two-variable basis.

    Why it fails

    A complete basis combines all allowed exponent choices.

    Do this instead

    Use one exponent vector to construct one function, then enumerate all allowed vectors for the full basis.

  • Common mistake

    Assuming a linear approximator is automatically too simple to be useful.

    What it looks like

    A linear approximator can use polynomial features chosen to emphasize useful patterns.

    Why it fails

    The source says that linear approximation can work well when its features are chosen appropriately.

    Do this instead

    Evaluate the representation and the learning method together.

  • Common mistake

    Describing every named representation with details not established in this section.

    What it looks like

    The section names Fourier basis features, coarse coding, tile coding, and radial basis functions as alternatives but does not define their internal constructions here.

    Why it fails

    The source only establishes that they provide different ways to represent a task.

    Do this instead

    Use the stated high-level distinction unless a source covering their construction is available.

Practice

MEDIUM

A state has d = 3 variables and you choose an Order1 polynomial basis. How many basis functions are included? Then describe the function produced by the exponent vector (1, 0, 1). Finally, explain in words how the resulting feature values would be combined with weights to form a value estimate.

Hints
  • Each variable has N + 1 allowed exponent choices.
  • Use one powered term for each of the three state variables.
  • A linear value estimate is a weighted sum of the feature values.
Worked example

Practice Check

Resolve the three-variable Order1 task.

  1. 1
    Count the basis

    Each of the three variables has 2 choices, 0 or 1, so the complete basis contains 23 functions.

  2. 2
    Construct the selected function

    The vector (1,0,1) assigns power 1 to the first variable, power 0 to the second, and power 1 to the third. The product is s₁s₃.

  3. 3
    Form the estimate

    Evaluate the selected basis features for the state and combine their values with their corresponding weights through a weighted sum.

Result

The basis contains 8 functions, the selected exponent vector produces s₁s₃, and the value estimate is the weighted sum of the resulting feature values.

Key Takeaways

  1. 1
    An OrderN polynomial feature is formed by choosing one exponent from 0 through N for every state variable and multiplying the powered terms.
  2. 2
    The exponent vector identifies one basis function, while the complete set of allowed vectors forms the basis.
  3. 3
    With d state variables, the complete OrderN basis contains (N + 1)d functions.
  4. 4
    A linear value approximator combines feature values and weights through a weighted sum.
  5. 5
    Feature selection supplies prior domain knowledge; LSTD favors data efficiency at higher computational scaling cost, while nonlinear neural-network methods use backpropagation and stochastic-gradient-descent variations.

At a glance

  • Each polynomial basis function is determined by an exponent choice for every state variable.
  • The exponent range 0 through N gives N + 1 choices per variable, so d variables produce (N + 1)d functions.
  • A linear value estimate is a weighted sum over the constructed features.
  • Feature selection places prior domain knowledge into the representation and strongly affects learning and generalization.
  • LSTD favors data efficiency at increased computational scaling cost, while nonlinear neural-network methods follow a different modeling direction.

Related concepts

More concepts starting with F