This topic describes the DeepFM algorithm.
Overview
Deep Factorization Machine (DeepFM) combines the strengths of the deep neural network (DNN) and factorization machine (FM) models. It can capture both lower-order explicit feature interactions and higher-order implicit feature interactions, eliminating the need for manual feature engineering. DeepFM is often used in recommendation or advertising systems.
The input features to a DeepFM model can be broadly categorized into two types:
Categorical feature: represented as strings, such as gender (male or female) and commodity category (such as clothing, toys, or electronics).
Numerical feature: represented as integers or floating-point numbers, such as user activity or commodity prices.
Floating-point numbers between 0 and 1 are often returned, which indicates the probability that the value is 1. They can be used for sorting or binary classification.
Scenarios
In most cases, DeepFM is used in classification and sorting scenarios, particularly effective in scenarios in which features are manually built but do not directly reflect results. In recommendation scenarios, low-order feature interactions or high-order feature interactions affect the final behaviors of users. However, you may not be able to identify feature interactions. DeepFM can automatically capture the interactions.
For example, in most personalized commodity recommendation scenarios, click estimation models are required. Historical user behaviors such as clicks, unclicks, and purchases can be used as training data to predict the probability of user clicks or purchases. If users have a substantial history of behaviors that cannot directly indicate their future clicks or purchases, DeepFM can combine user behaviors and converts sparse features into high-dimensional dense features.
Parameters
The values of the parameters described in the following table are the same as those of the model_parameter
parameter specified in the CREATE MODEL
statement that is used to create a model. You can configure the parameters based on your business requirements.
Parameter | Description |
metrics | The metrics used to evaluate the model. Valid values:
|
loss | The learning task and the learning objectives of the task. Valid values:
|
optimizer | The optimizer. Valid values:
|
validation_split | The ratio of cross-validation data. Default value: 0.2. |
epochs | The number of iterations. Default value: 6. |
batch_size | The length of the batch. A short batch is prone to overfitting. Default value: 64. |
task | The type of the task. Valid values:
|
Examples
Create a model and an offline training task.
/*polar4ai*/
CREATE MODEL airline_deepfm WITH
(model_class = 'deepfm',
x_cols = 'Airline,Flight,AirportFrom,AirportTo,DayOfWeek,Time,Length',
y_cols='Delay',model_parameter=(epochs=6))
AS (SELECT * FROM db4ai.airlines);
Evaluate the model.
/*polar4ai*/
SELECT Airline FROM EVALUATE(MODEL airline_deepfm,
SELECT * FROM db4ai.airlines LIMIT 20) WITH
(x_cols = 'Airline,Flight,AirportFrom,AirportTo,DayOfWeek,Time,Length',y_cols='Delay',metrics='acc');
Use the model for prediction.
/*polar4ai*/
SELECT Airline FROM PREDICT(MODEL airline_deepfm,
SELECT * FROM db4ai.airlines limit 20) WITH
(x_cols = 'Airline,Flight,AirportFrom,AirportTo,DayOfWeek,Time,Length');