liveBook · Manning

Feature engineering

As explained in Applied Reinforcement Learning

Feature engineering is the construction or transformation of input features into representations suitable for a model or learning algorithm.

Feature engineering transforms raw state information into a compact representation a tabular learner can use. For a gas station, the state keeps current inventory, total pending fuel, and the soonest delivery time instead of recording every order separately. section 6.6

Listing 6.5 State representation with feature engineering\
@dataclass
class EnvironmentState:
    """State representation for the gas station environment."""
    current_inventory: int                #A
    pending_orders: List[Tuple[int, int]] #B
    
    def to_tuple(self) -> Tuple:
        """Convert state to tuple for Q-table indexing."""
        inventory = self.current_inventory #C
        
        pending_sum = sum(quantity for quantity, days_left 
                         in self.pending_orders) #D
        
        if self.pending_orders:
            next_arrival_time = min(days_left for _, days_left 
                                   in self.pending_orders) #E
        else:
            next_arrival_time = 0 #F
        
        return (inventory, pending_sum, next_arrival_time) #G

See how the gas station state is converted into a tuple for Q-table indexing. section 6.6

How Applied Reinforcement Learning covers it

How deep it goes
Works through an implementation that aggregates pending orders into total quantity and next arrival time.
Examples
Uses a gas station state with current inventory, pending fuel, and delivery arrival time.
What you can do after
Apply feature engineering to compact a tabular learner’s state while retaining information needed for decisions.
How it connects
Connects state representation to tabular learning and Q-table indexing.

Also explained in

Compare how 24 books explain feature engineering →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Applied Reinforcement Learning. The section links point to the parts of the book it draws on.