Using DLI to Analyze E-commerce BI Reports
Application Scenarios
- Description
As a self-operated e-commerce company in China, the X mall has developed hundreds of millions of loyal users and accumulated massive amounts of authentic data while maintaining high-speed development. How to use the BI tool to find business opportunities from historical data is a key issue in the precision marketing of big data applications. It is also the core technology required for intelligent upgrade of all e-commerce platforms.
This case uses the public cloud DLI, DWS, and Yonghong BI to analyze data features of users and offerings based on the real user, offering, and comment data (anonymized) of the mall, providing high-quality information for marketing decision-making, advertising recommendation, credit rating, brand monitoring, and user behavior prediction.
- Data Types
To protect user privacy and data security, all sampled data is anonymized.
- User data
Table 1 User data Field Name
Field Type
Description
Value Range
user_id
int
User ID
Anonymized
age
int
Age group
-1 indicates that the user age is unknown.
sexuality
int
Gender
- 0: Male
- 1: Female
- 2: Confidential
rank
Int
User level
Sequenced list of user level. The higher the user level, the larger the number.
register_time
string
User registration date
Unit: day
- Product data
Table 2 Product data Field Name
Field Type
Description
Value Range
product_id
int
Product No.
Anonymized
a1
int
Attribute 1
Enumerated value. The value -1 indicates unknown.
a2
int
Attribute 2
Enumerated value. The value -1 indicates unknown.
a3
int
Attribute 3
Enumerated value. The value -1 indicates unknown.
category
int
Category ID
Anonymized
brand
int
Brand ID
Anonymized
- Evaluation data
Table 3 Evaluation data Field Name
Field Type
Description
Value Range
deadline
string
End time
Unit: day
product_id
int
Product No.
Anonymized
comment_num
int
Segments of accumulated comment count
- 0: No comment
- 1: One comment
- 2: 2 to 10 comments
- 3: 11-50 comments
- 4: More than 50 comments
has_bad_comment
int
Whether there is negative feedback.
0: No; 1: Yes.
bad_comment_rate
float
Dissatisfaction rate
Proportion of the negative feedback.
- Behavior data
Table 4 Behavior data Field Name
Field Type
Description
Value Range
user_id
int
User ID
Anonymized
product_id
int
Product No.
Anonymized
time
string
Time of action
-
model_id
string
Module ID
Anonymized
type
string
- Browse (refers to the offering details page)
- Add to Cart
- Remove from cart
- Place an order
- Follow
- Click
-
- User data
Analysis Process
To use DLI to analyze e-commerce data, perform the following steps:
Step 1: Registering an Account. Before the data analysis, register a public cloud account and perform real name authentication.
Step 2: Uploading Data. Upload the data to OBS for data analysis using DLI.
Step 3: Analyzing Data. Use DLI to query the data for analysis.
Step 1: Registering an Account
Register a public cloud account and perform real name authentication.
For details about how to register an account, see Registering a HUAWEI ID and Enabling HUAWEI CLOUD Services.
For details about real-name authentication, see Real-Name Authentication Entry.
If you have registered a public cloud account and completed real-name authentication, skip this step.
Step 2: Uploading Data
- Download OBS Browser+. For details about the download address, see the Object Storage Service Tools Guide.
- Install OBS Browser+. For details about the installation process, see the Object Storage Service Tools Guide.
- Log in to OBS Browser+. OBS Browser+ supports two login modes: AK login (using access keys) or authorization code login. For details about the login process, see the Object Storage Service Tools Guide.
- Upload data using the OBS Browser+.
On the OBS Browser+ page, click Create Bucket. Select a region and enter a bucket name (for example, DLI_demo). After the bucket is created, return to the bucket list and click DLI_demo. OBS Browser+ supports upload by dragging. You can drag one or more files or folders from a local path to the object list of a bucket or a parallel file system on OBS Browser+. You can even drag a file or folder directly to a specified folder on OBS Browser+.
Data has been uploaded to OBS. The procedure for uploading data can be omitted.
Step 3: Analyzing Data
- Creating a Database and a Table
- On the homepage of the HUAWEI CLOUD management console, choose Service List > EI Enterprise Intelligence > Data Lake Insight.
- Create a demo database. On the DLI console, click SQL Jobs to go to the SQL Editor page.
- In the left pane of the SQL Editor, select
Database and click
to create a database. For details, see Figure 1.
The default database is a built-in database. You cannot create a database named default.
- Choose the demo database, and enter the following SQL statement in the editing box:
create table user( user_id int, age int, sexuality int, rank int, register_time string ) USING csv OPTIONS (path "obs://yonghong/data/JData_User")
The file path in the preceding SQL statement is the actual OBS path for storing data.
- Click Execute to create the user information table user.
- Create the offering table, evaluation table, and behavior table in the same way.
- Product table
create table product( product_id int, a1 int, a2 int, a3 int, category int, brand int ) USING csv OPTIONS (path "obs://yonghong/data/JData_Product")
- Evaluation Table
create table comment( deadline string, product_id int, comment_num int, has_bad_comment int, bad_comment_rate float ) USING csv OPTIONS (path "obs://yonghong/data/JData_Comment")
- Behavior table
create table action( user_id int, product_id int, time string, model_id string, type string ) USING csv OPTIONS (path "obs://yonghong/data/JData_Action");
- Product table
- Querying Data
You can save common query statements as templates on the Template Management page for later use. For details, see SQL Template Management in the Data Lake Insight User Guide.
- Analyze the top 10 products with the most likes.
- Run the following SQL statement to analyze the top 10 products with the most likes.
SELECT product.brand as brand, COUNT(product.brand) as like_count from action JOIN product ON (action.product_id = product.product_id) WHERE action.type = 'like' group by brand ORDER BY like_count desc limit 10
- Click Execute. The execution results are displayed, as shown in Figure 2.
- Click Graphical Result to display the result in a chart. Figure 3 Graphical results
- Run the following SQL statement to analyze the top 10 products with the most likes.
- Analyze the top 10 worst-rated products.
- Run the following SQL statement to analyze the top 10 worst-rated products:
SELECT DISTINCT product_id, comment_num, bad_comment_rate from comment where comment_num > 3 order by bad_comment_rate desc limit 10
- Click Execute. The execution results are displayed, as shown in Figure 4.
- Click Graphical Result to display the result in a chart. Figure 5 Graphical result
- Run the following SQL statement to analyze the top 10 worst-rated products:
- You can also analyze the age distribution, gender ratio, offering evaluation, purchase number, and browsing statistics of users.
Click the following link to download the sample data and detailed SQL statements:
https://dli-demo-ce3.obs.cn-east-3.myhuaweicloud.com:443/Best_Practice_4/Best_Practice_4.zip
- Analyze the top 10 products with the most likes.
Last Article: Using DLI to Convert Data Format from CSV to Parquet



Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.