# US 12,182,122 B2 · One-hot encoder using lazy evaluation of relational statements

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 12,182,122 B2
- Document ID: US12182122B2
- Status: Granted
- Kind: B2
- Application number: 17/964,084
- Filed: 2022-10-12
- Published: 2024-04-18
- Granted: 2024-12-31
- Earliest claimed: 2022-10-12
- Assignees: Oracle International Corporation
- Applicants: Oracle International Corporation
- Inventors: Felix Schmidt; Matteo Casserini; Milos Vasic; Marija Nikolic
- Web page: https://patentgrep.com/patent/US12182122B2

## CPC

- G06F 16/22: Indexing; Data structures therefor; Storage structures
- G06F 16/24544: {Join order optimisation}
- G06F 16/2471: {Distributed queries}
- G06N 3/044: Recurrent networks, e.g. Hopfield networks
- G06N 3/045: Combinations of networks
- G06N 5/01: Dynamic search techniques; Heuristics; Dynamic trees; Branch-and-bound
- G06N 20/00: Machine learning
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- G06N: COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS

## Abstract

A method and one or more non-transitory storage media are provided to train and implement a one-hot encoder. During a training phase, computation of an encoder state is performed by executing a set of relational statements to extract unique categories in a first training data set, associate each unique category with a unique index, and generate a one-hot encoding for each unique category. The set of relational statements are executed by a query optimization engine. Execution of the set of relational statements is postponed until a result of each relational statement is needed, and the query optimization engine implements one or more optimizations when executing the set of relational statements. During an encoding phase, a set of categorical features in a second training data set are encoded based on the encoder state to form a set of encoded categorical features.

## Claims

### Claim 1

A method, in a computing system comprising one or more processors and one or more memories, the one or more memories comprising instructions executed by the one or more processors to cause the one or more processors to train and implement a one-hot encoder, the method comprising:
during a training phase, performing computation of an encoder state by executing a set of relational statements to extract unique categories in a first training data set, associate each unique category with a unique index, and generate a one-hot encoding for each unique category, wherein:
the set of relational statements are executed by a query optimization engine;
execution of the set of relational statements is postponed until a result of each relational statement is needed; and
the query optimization engine implements one or more optimizations when executing the set of relational statements; and
during an encoding phase, encoding a set of categorical features in a second training data set based on the encoder state to form a set of encoded categorical features.

### Claim 2 (depends on 1)

The method of claim 1, wherein the second training data set includes the first training data set.

### Claim 3 (depends on 1)

The method of claim 1, wherein the set of relational statements are executed to generate a one-hot encoder dictionary by:
determining a plurality of unique categories in the first training data set;
assigning monotonically increasing indexes to the plurality of unique categories; and
converting the monotonically increasing indexes to consecutive indexes.

### Claim 4 (depends on 3)

The method of claim 3, wherein the one-hot encoding for a given category comprises a sparse vector having a length based on a number of unique categories in the plurality of unique categories and a value of one in an element of the sparse vector according to an index of the given category.

### Claim 5 (depends on 1)

The method of claim 1, wherein the encoder state comprises an encoder state table including a category column storing the unique categories and a one-hot vector column storing a sparse vectors corresponding to each unique category.

### Claim 6 (depends on 5)

The method of claim 5, wherein the encoder state table further includes at least one of an index column storing consecutive indexes corresponding to the unique categories or a length column storing a length of the sparse vector.

### Claim 7 (depends on 5)

The method of claim 5, wherein:
the set of relational statements are further executed to generate a one-hot encoder dictionary by determining a number of observations in the first training data set for each unique category; and
the encoder state table further includes a count column storing a number of observations corresponding to each unique category.

### Claim 8 (depends on 5)

The method of claim 5, wherein encoding the set of categorical features comprises:
generating an input data frame for the set of categorical features in the second training data set; and
performing a distributed join operation between the input data frame and the encoder state table using a value of the categorical features as a join key.

### Claim 9 (depends on 8)

The method of claim 8, wherein performing the distributed join operation comprises executing a plurality of lookup operations in parallel.

### Claim 10 (depends on 8)

The method of claim 8, wherein:
the distributed join operation is performed by the query optimization engine;
performing the distributed join operation comprises executing a plurality of lookup operations;
execution of the plurality of lookup operations is postponed until a result of each lookup operation is needed; and
the query optimization engine implements one or more optimizations when executing the plurality of lookup operations.

### Claim 11 (depends on 1)

The method of claim 1, further comprising training a machine learning model using the second training data set based on the set of encoded categorical features.

### Claim 12

One or more non-transitory storage media storing instructions which, when executed by one or more computing devices, cause the one or more computing devices to train and implement a one-hot encoder, wherein the instructions further cause the one or more computing devices to perform a method comprising:
during a training phase, performing computation of an encoder state by executing a set of relational statements to extract unique categories in a first training data set, associate each unique category with a unique index, and generate a one-hot encoding for each unique category, wherein:
the set of relational statements are executed by a query optimization engine;
execution of the set of relational statements is postponed until a result of each relational statement is needed; and
the query optimization engine implements one or more optimizations when executing the set of relational statements; and
during an encoding phase, encoding a set of categorical features in a second training data set based on the encoder state to form a set of encoded categorical features.

### Claim 13 (depends on 12)

The one or more non-transitory storage media of claim 12, wherein the second training data set includes the first training data set.

### Claim 14 (depends on 12)

The one or more non-transitory storage media of claim 12, wherein the set of relational statements are executed to generate a one-hot encoder dictionary by:
determining a plurality of unique categories in the first training data set;
assigning monotonically increasing indexes to the plurality of unique categories; and
converting the monotonically increasing indexes to consecutive indexes.

### Claim 15 (depends on 14)

The one or more non-transitory storage media of claim 14, wherein the one-hot encoding for a given category comprises a sparse vector having a length based on a number of unique categories in the plurality of unique categories and a value of one in an element of the sparse vector according to an index of the given category.

### Claim 16 (depends on 12)

The one or more non-transitory storage media of claim 12, wherein the encoder state comprises an encoder state table including a category column storing the unique categories and a one-hot vector column storing a sparse vectors corresponding to each unique categories.

### Claim 17 (depends on 16)

The one or more non-transitory storage media of claim 16, wherein the encoder state table further includes at least one of an index column storing consecutive indexes corresponding to the unique categories or a length column storing a length of the sparse vector.

### Claim 18 (depends on 16)

The one or more non-transitory storage media of claim 16, wherein encoding the set of categorical features comprises:
generating an input data frame for the set of categorical features in the second training data set; and
performing a distributed join operation between the input data frame and the encoder state table using a value of the categorical features as a join key.

### Claim 19 (depends on 18)

The one or more non-transitory storage media of claim 18, wherein:
the distributed join operation is performed by the query optimization engine;
performing the distributed join operation comprises executing a plurality of lookup operations;
execution of the plurality of lookup operations is postponed until a result of each lookup operation is needed; and
the query optimization engine implements one or more optimizations when executing the plurality of lookup operations.

### Claim 20 (depends on 12)

The one or more non-transitory storage media of claim 12, wherein the instructions further cause the one or more computing devices to train a machine learning model using the second training data set based on the set of encoded categorical features.
