This topic describes how to recommend products based on object features.
A workspace is created. For more information, see Create a workspace.
In the pipeline that is used in this topic, a prediction model is trained based on e-commerce data from April and May and evaluated based on shopping data from June. An optimal model is deployed as a RESTful API to be called in business scenarios.
The pipeline is based on masked real data that is collected from an e-commerce platform. The data is not intended for commercial purposes.
The data and entire workflow of the pipeline are preset in the pipeline template of Machine Learning Designer. You can implement recommendations based on collaborative filtering in a fast manner by dragging the components to the canvas in Machine Learning Designer. In addition, Machine Learning Designer supports model deployment with a few clicks. This allows you to deploy a model as a RESTful API with ease.
General process of product recommendation based on object features
Import data to MaxCompute to generate supervised, structured data.
Perform feature engineering, including operations such as data preprocessing and feature derivation. Feature derivation expands dimensions for data, so that the data can better demonstrate business characteristics.
Split the data into two datasets. Use a classification algorithm to train a binary classification model based on one dataset. Use a prediction component to predict the quality of the model based on the other dataset.
Use an evaluation component to evaluate the quality of the model.
The pipeline that is used in this topic uses a dataset that is provided by the Tianchi Big Data Competition. The dataset includes the shopping behavior in April and May and that in June. The following table describes the fields in the dataset.
The ID of the user.
The ID of the item.
The date on which the user purchased the item.
The following figure shows the sample raw data that is used in the pipeline.
Go to the Machine Learning Designer page.
Log on to the Machine Learning Platform for AI console.
In the left-side navigation pane, click Workspaces. On the Workspaces page, click the name of the workspace that you want to manage.
In the left-side navigation pane, choose to go to the Machine Learning Designer page.
Create a pipeline
On the Visualized Modeling (Designer) page, click the Preset Templates tab.
In the Preset Pipelines tab, click Create in the Recommendation Based on Object Characteristics section.
In the Create Pipeline dialog box, configure the parameters. You can use their default values.
The value specified for the Pipeline Data Path parameter is the Object Storage Service (OSS) bucket path of the temporary data and models generated during the runtime of the pipeline.
It requires about 10 seconds to create the pipeline.
In the Pipelines tab, double-click Recommendation Based on Object Characteristics to enter the pipeline.
View the components of the pipeline on the canvas as shown in the following figure. The system automatically creates the pipeline based on the preset template.
The components in this section perform feature engineering. The raw data includes only four fields. Feature engineering is performed to expand the dimensions of the raw data. The features in this pipeline include the features of the items and the users to whom these items are recommended.
The dimensions that are expanded for each user include the number of purchases, the number of clicks, and the click-to-purchase ratio of the user. The click-to-purchase ratio is calculated by dividing the number of clicks by the purchase rate. The ratio describes the purchase intention of the user.
The dimensions that are expanded for each item include the number of purchases, the number of clicks, and the purchase-to-click ratio of the item. The purchase-to-click ratio is calculated by dividing the number of purchases by the click-through rate.
After feature engineering, the dataset is expanded from 4 fields to 10 fields, as shown in the following figure.
The pipeline uses a logical regression algorithm for model training.
You can click the Logistic Regression for Binary Classification component, select the Fields Setting tab in the upper-right corner of the canvas, and then select Whether To Generate PMML. This allows PMML models to be generated.
The components in this section evaluate the quality of the model. The reserved data that is not used to train the model is used to evaluate the quality of the model. Pipelines on recommendation are binary classification pipelines. In such a pipeline, you can use a confusion matrix and a binary classification evaluation component to evaluate the quality of the model.
Run the pipeline and view the results.
In the upper-left corner of the canvas, click Run.
After the pipeline stops running, right-click Logistic Regression for Binary Classification on the canvas and choose to export the recommendation based on object features model that is trained.
Right-click Prediction on the canvas and choose to view the prediction results of the model.
View the evaluation report of the model.
Right-click Binary Classification Evaluation on the canvas and click Visual Analysis.
In the Evaluate section, click the Evaluation Chart tab to view the receiver operating characteristic (ROC) curve.
The blue area represents the area under curve (AUC) value. A larger blue area indicates higher model quality.
Right-click Confusion Matrix on the canvas and click Visual Analysis.
In the Confusion Matrix section, click the Confusion Matrix tab to view the evaluation results.
Deploy the model.
If the model meets your expectations, you can click Models in the upper part of the canvas to deploy the model as an online service. For more information, see Deploy a model as an online service.