# Analysis of Precision Service of Agricultural Product e-Commerce Based on Multimodal Collaborative Filtering Algorithm

Authors: FengQin ZhuanSun; JiaoJiao Chen; Wenlong Chen; Yan Sun
Journal: Mathematical Problems in Engineering
 (2022)

---

## Abstract

The times are advancing, the Internet is constantly advancing, and there are many examples of the combination of technology and life. The way people buy agricultural products is no longer limited to the physical market, but is being transformed into an agricultural product e-commerce website to achieve digital transformation. So far, a large number of agricultural products have been collected on the agricultural product e-commerce website, they come from all over the country, and different types and different regional agricultural products have appeared. On the other hand, users are faced with a large number of commodities on the Internet. If they simply use search engines, consumers need to spend a lot of time to find the commodities they are interested in by browsing. Searching from the recommended ones greatly reduces the product set and optimizes the performance of the e-commerce platform. Therefore, the generation of the personalized recommendation system meets the needs of the market. This research will improve the related recommendation algorithm by improving the user similarity calculation method based on artificial intelligence technology, improve the execution efficiency and accuracy of the improved algorithm, and use related technologies to develop an agricultural product e-commerce recommendation system. It has important theoretical and practical significance to save users’ browsing time, improve users’ shopping experience, and speed up the construction of agricultural product e-commerce.


---

## Body

## 1. Introduction

With the continuous advancement of the Internet, cloud computing, and big data technologies, human life has gradually shifted from a lack of information to an era of information overload. Faced with the constantly updated commodity data and massive user information in the agricultural product e-commerce platform, the market circulation of agricultural products does not match. The contradiction is becoming more and more prominent, and the original data mining technology can no longer meet the storage and analysis needs of effective information data in the agricultural product e-commerce platform. Nowadays, the varieties, packaging, and sales channels of agricultural products are becoming more and more diversified. However, most of these agricultural products are not popular in e-commerce platforms and cannot be found and satisfied by consumers in the first time. Therefore, in order to better achieve the precise service of agricultural product e-commerce, it is possible to discover long-tail commodities through intelligent recommendation technology and recommend them to consumers individually to increase commodity sales. How to quickly and accurately recommend the products that users are interested in to the user’s client, so as to generate interest and increase the desire to buy, is the primary task of current e-commerce intelligent recommendation research. At present, some agricultural product e-commerce platforms also provide functions such as on-site search, but problems such as low search efficiency and weak commodity correlation limit the efficiency of the platform to solve “information overload.” In addition, there are also agricultural product e-commerce platforms that use recommendation technology to recommend all products, but the recommendation effect is not ideal, and it is prone to repeated recommendations, low recommendation accuracy, and no recommendation based on the unique attributes of agricultural products, which wastes a lot of time and energy of users. Therefore, how to use advanced recommendation technology to develop an agricultural product e-commerce recommendation system and realize the accurate recommendation of users’’ agricultural products from massive information is an important problem that needs to be solved urgently.A good recommendation method can effectively help more users quickly find some high-quality information they need, thereby improving user experience. From the perspective of user needs, group user portraits can assist e-commerce platforms to grasp the high probability behavior of users in different service scenarios. After a period of changes, users’’ interests and preferences may change. In order to effectively help users find the products they are interested in, many scholars have applied information filtering technologies such as retrieval technology and recommendation technology to e-commerce. In particular, recommendation technology has gradually become the mainstream information filtering technology in e-commerce systems. Using corresponding recommendation algorithms such as collaborative filtering algorithms and content-based filtering algorithms, the recommendation technology does not need to specify user needs, but only needs to be characterized by various types of information such as user browsing records to establish a consumption or preference model based on the user, which may meet the requirements of the user. Potential products with a high degree of interest matching the user’s taste or consumption habits are recommended to the user, so as to achieve the purpose of product recommendation. At present, recommendation technology has been successfully applied in tourism, news, e-commerce, and other fields, and a series of recommendation systems have been developed, such as video recommendation system, news recommendation system, and takeaway recommendation system. Aiming at the shortcomings of traditional collaborative filtering algorithms, this study integrates user basic information and user preferences based on artificial intelligence technology, improves the efficiency of the existing algorithm in terms of user similarity, and conducts necessary experimental verification. Combined with the above improved collaborative filtering algorithm, the recommendation idea of this system is determined, and the agricultural product recommendation model including the construction of user preference model, the acquisition of key attributes based on rough sets, the search for similar users, and the recommendation of agricultural products is completed, and the agricultural product recommendation model is completed [1–6].


## 2. Related Work

In 2016, Google’s artificial intelligence Go program AlphaGo defeated Lee Sedol, a professional human Go Player and world Go champion, demonstrating the powerful advantages of artificial intelligence in complex intellectual work, causing continuous heated discussions around the world, and has always maintained a close relationship with ordinary people. Artificial intelligence with a “high-tech sense” distance has once again returned to the public’s field of vision. In fact, since 1956, after more than 60 years of practice and development, AI has entered human life from a scientific research stage and has been widely used in many social fields. The combination of AI and the e-commerce industry is one of the more mature fields of artificial intelligence commercial application. The application of computational advertising to big data technology and artificial intelligence algorithms has formed an industrial scale. Iglesias et al. proposed a method to automatically generate behavioral user portraits. By applying the clustering method, the cosine distance formula is used to find the cluster center for similar users and at the same time combine different user behavior characteristics to achieve the purpose of classification according to the user group behavior, but the log data of the experimental part of the paper are difficult to obtain. Nasraoui, Adomavicius, and others further constructed a dynamic user portrait model based on the log behavior of consumers and based on the dynamic user portrait model to achieve the purpose of real-time tracking of users. He Sheng et al. [6] extracted the explicit interests and implicit needs of users based on the massive data of university libraries. The researchers analyzed the data in the user log database, proposed an ontology-based user behavior portrait model according to the user’s explicit interests and implicit needs, and applied the model in the Hadoop big data platform to further personalize the library. service provider support. The data of Wang Renwu, Zhang Wenhui, and others come from the behavior data generated by users accessing academic resources and extract behavior tags and research interest tags from the data. These two tag systems are used to construct academic user portraits, so as to satisfy the recommendation service of the library. Hawalah et al. proposed a user portrait model based on user interest preferences, which can not only analyze user preferences from different perspectives, but also calculate user preference weights from the perspective of historical behavior and item popularity. In addition, the paper also provides a method based on long-term and short-term user preference, which is used to update user portraits and implement a dynamic recommendation algorithm. After verification on the data, the feasibility and effectiveness of the method are proved; Liu et al. constructed user portraits through the Dirichlet distribution model, which can find the user’s implicit interest to a certain extent. When the data are too small or the amount of fan data is not large, the results such as the accuracy rate of users’’ implicit interest mining are not good. Lin et al. constructed a group user portrait model with Weibo users as an example. The model uses the topic model method to extract topics of interest to users and then calculates the user similarity according to the probability distribution in the topic model technology. Group user portraits, by dividing users on Weibo into different groups, provide personalized recommendation services according to the different characteristics of different groups. Yanan et al. constructed user portraits for the behavior of researchers and proposed a method of mixing global information and local information to construct user behavior portraits. It not only extracted user features with the help of deep learning methods, but also carried out correlation experiments on scientific research social media. In the digital age, streaming media platforms focus more on data analysis to find the target audience that best meets product needs. Traditional algorithms draw user portraits by analyzing demographic attributes such as regional factors, age, and occupation, which traditional advertising relies on, as well as user behavior, but there are inevitably some unsolvable drawbacks. For example, by optimizing the click-through rate of the target audience, media buyers can attract a lot of audiences that match the user’s label to the traffic platform, but the click-through rate of these target groups, but for the advertiser, these users are not necessarily the potential to buy the product consumer [7–15]. In contrast, the recommendation strategy that uses artificial intelligence to identify and locate potential customers without prejudice has a higher probability of seeking real consumption, which is different from the segmented audience given by big data.


## 3. Related Theories and Methods

### 3.1. AI Recommender System

In the context of artificial intelligence, the massive amount of information makes people overwhelmed, and there is a phenomenon of “information overload.” In order to solve this problem, many scholars have begun to look for ways to help users capture key and interesting information from massive information, and recommender systems are one of the important solutions to this problem. The recommendation system is a tool to establish the connection between users and products. It can help users to mine interesting information from massive information according to user preferences, and accurately recommend products that meet relevant characteristics to users, so as to solve the problem of “information overload.”In recent years, with the rise of e-commerce platforms, traditional shopping guides have been unable to keep up with the trend of product recommendation, and users are more inclined to shop online from platforms with a wide variety of products. However, due to the large number of products on the platform, the difficulty for users to choose is also increasing, so most platforms choose different recommendation systems according to their own characteristics to improve the user’s shopping experience. In the shopping process, it is easier for the platform to use the built recommendation model to score, filter, and sort the products according to the user’s browsing records, favorites, attention, and other information, and then push to the user several products that may be of interest to the user, thereby improving the user’s reputation and loyalty. The working principle of the recommender system is shown in Figure1. In Figure 1, it can be seen that the recommendation system is mainly composed of three parts when it is working, namely, the data source, the recommendation system, and the product recommendation [16]:(i)
Data Source. When recommending products to users, the data sources of the recommendation system come from user behavior, user information, and product information. Among them, user behaviors can be divided into explicit behaviors and implicit behaviors. Explicit behaviors are behaviors that clearly reveal users’ likes and dislikes of a certain product, such as user ratings, collections, and attention. These behavioral data are often used for analysis and use; implicit behaviors are behaviors such as browsing records that cannot clearly indicate the user’s likes and dislikes of a certain product. Although the data volume of this behavior is small, it also hides some interesting and imperceptible user preference information.(ii)
Recommendation System. Due to the different types of users, the recommendation algorithms used by the recommendation systems are also different. Common recommendation algorithms include collaborative filtering algorithms, content-based recommendation algorithms, and association rule-based recommendation algorithms.(iii)
Commodity Recommendation. The recommendation system selects the appropriate data source, uses the corresponding recommendation algorithm to process the data, sorts the processed products according to their scores, selects several products to form a recommended product list, and finally recommends them to the target users to complete the personalized recommendation task.Figure 1
Schematic diagram of the recommendation system.To sum up, the recommendation system is to establish the connection between the user and the item, select the appropriate data source and recommendation algorithm, filter out the items that the user is not interested in, and recommend the items that the user is interested in to complete the personalized recommendation.


### 3.2. AI Collaborative Filtering Recommendation Algorithm

#### 3.2.1. Working Principle

After the collaborative filtering recommendation (CF) technology was proposed by Bob Goldberg et al., it has attracted the attention of scholars, achieved a series of research results, and successfully applied to multiple e-commerce platforms, becoming one of the most commonly used recommendation technologies for electronic commodity platforms one. The traditional collaborative filtering recommendation technology uses user behavior data to automatically mine user preferences, form a behavior pattern based on the user, and recommend suitable items for the user according to the pattern. To sum up, the recommendation process of collaborative filtering recommendation technology goes through three processes: collecting user evaluation information, using similarity to find neighbors, using neighbors to predict target user interests, and generating recommendation lists, as shown in Figure2 [17].Figure 2
Collaborative filtering recommendation process.(1) Obtain the Scoring Matrix. Let m and n be the number of users and products in the database, respectively, Ui and Ij are the i-th user and the j-th product (1 ≤i ≤ m, 1 ≤j ≤ n), respectively, and Rij is the user i. For the rating of commodity j (1 ≤ Rij ≤ 5, and Rij is an integer), the rating matrix M is formally defined as(1)M=Rijm×n.Definition formula (1) gives the definition of the rating matrix, in whichRij represents the user’s preference for a certain product. The higher the value, the more the user likes a certain product, otherwise, the less the user likes the product. The general representation of the scoring matrix is shown in Table 1.Table 1
Scoring matrix.
I1I2…In_U1 _33…3U244…5……………Um12…5(2) Select the Nearest Neighbor. In order to improve the recommendation accuracy, it is necessary to find the neighbor users by calculating the user similarity, and then sort and filter the appropriate neighbor set for analysis according to the similarity value. In the recommendation system, the calculation of the nearest neighbor is its core link. The nearest neighbor is generated by calculating the similarity between users (or products) (usually there are methods such as cosine similarity and Pearson similarity). The precision of the recommendation results has a significant impact. The common cosine similarity and Pearson similarity measurement methods are given below.Define formula (2). Letn be the number of items to be evaluated, u and v are any two users, Ru, c and Rv, c (1 ≤c ≤ n) are the scores of users u and v on item c respectively; let(2)simu,v=∑c=1nRu,cRv,c∑c=1nRu,c2∑c=1nRv,c2.Then, sim(u, v) is called the cosine similarity between users u and v.Define formula (3), letn be the number of items to be evaluated, u and v are any two users, Ru, c, Rv, c (1 ≤c ≤ n) are the scores of users u, v on item c, respectively, R¯U, R¯V are the mean scores of users u and v for all items, respectively, and let(3)simu,v=∑c∈Iu,vRu,c−RU¯Rv,c−Rv¯∑c∈Iu,vRu,c−RU¯2∑c∈Iu,vRv,c−Rv¯2.Then, sim(u,v) is called the Pearson similarity between users u and v.(3) Generate Recommendation. Select the nearest neighbor set according to the nearest neighbor set obtained by similarity, analyze the characteristics of the combination, and generate a list of recommended products most likely to meet the target user [18].Define formula (4). Let n be the number of items to be evaluated, u and v are any two users, Rv,i (1 <i ≤ n) is the rating of item i by user v, and the ratings R¯U of user u and v for all items, respectively. R¯V is the mean of item ratings, sim(u, v) is the similarity between users u and v, and let(4)pu,i=R¯U+∑v∈Vsimu,vRvi−R¯V∑v∈Vsimu,v.Then,Pu,i is called user u’s preference for item i.


#### 3.2.2. Classification of Artificial Intelligence Algorithms

At present, collaborative filtering algorithms are mainly divided into user-based collaborative filtering algorithms (UserCF), item-based collaborative filtering algorithms (ItemCF), and model-based collaborative filtering algorithms (ModelCF). The three types of algorithms are briefly introduced below. (1) User-based collaborative filtering algorithm (UserCF): This recommendation algorithm takes registered users of e-commerce platforms as research objects and analyzes the interests of each user by collecting data on user behavior (such as purchasing items, collecting, and following). Calculate the similarity between users, build a neighbor user set, and generate recommendation results [19]. In simple terms, if user A and user B have purchased a large number of the same items, that is, there is a high overlap of purchased items, it is considered that these two users have high similarity in preferences and belong to the same type of user. If user A buys an item now, the system will think that user B will also like it with a high probability, and recommend the item to user B. The recommendation process of the recommendation algorithm is shown in Figure 3.Figure 3
Schematic diagram of user-based collaborative recommendation algorithm.In Figure3, user A has purchased products “fruit 1” and “fruit 2,” user B has purchased products “fruit 3,” and user C has purchased products “fruit 2,” “fruit 3,” and “fruit 4.” It can be seen that user A and user C are similar users. Since user C also purchased the product “fruit 4,” but user A has not bought it, UserCF will recommend the product “fruit 4” to A [20].In [2] item-based collaborative filtering algorithm (ItemCF): This recommendation algorithm is similar to UserCF, except that items are used instead of users when calculating neighbors; that is, the similarity between new items and purchased items is calculated according to the user’s historical preferences, and the similarity is recommended. It can be seen that the recommendation algorithm judges the similarity between items according to the user’s behavior, which is different from UserCF’s judgment of the similarity between users. The recommendation process of the recommendation algorithm is shown in Figure 4.Figure 4
Schematic diagram of item-based collaborative recommendation algorithm.In Figure4, user A has purchased products “fruit 2” and “fruit 4,” user B has purchased products “fruit 2,” “fruit 3,” and “fruit 4,” and user C has purchased products “fruit 2.” It can be seen that the users (A, B) who have purchased “fruit 2” both purchased “fruit 4” at the same time, and obtained “fruit 2” and “fruit 4” as related items. User C has also purchased “fruit 2.” The recommendation algorithm will consider that user C is also very likely to purchase “fruit 4,” so “fruit 4” is recommended to user C [21].(3) Model-based collaborative filtering algorithm (ModelCF): Although recommendation algorithms such as UserCF and ItemCF have the advantages of simple theory and high accuracy of recommendation results, in practical applications, people often use model-based collaborative filtering algorithms (ModelCF) to improve recommended efficiency. The model-based collaborative filtering algorithm uses user behavior scores to design a parameter model to describe the implicit relationship between users and items, users and users, items and items, etc., and finally uses the model to give recommendation results. Simply put, ModelCF uses a parametric model to predict the relationship between blank users and items based on the rating data of some users (other users have blank ratings) and recommends the highest rated items to users. Compared with recommendation algorithms such as UserCF and ItemCF, ModelCF can be trained offline and use the deployed parameter model for online recommendation, which meets the online requirements of electronic commodity platforms. In addition, ModelCF has strong scalability and can be combined with clustering models, classification models, regression models, Bayesian network models, etc., to improve the recommendation accuracy of recommendation algorithms.


## 3.1. AI Recommender System

In the context of artificial intelligence, the massive amount of information makes people overwhelmed, and there is a phenomenon of “information overload.” In order to solve this problem, many scholars have begun to look for ways to help users capture key and interesting information from massive information, and recommender systems are one of the important solutions to this problem. The recommendation system is a tool to establish the connection between users and products. It can help users to mine interesting information from massive information according to user preferences, and accurately recommend products that meet relevant characteristics to users, so as to solve the problem of “information overload.”In recent years, with the rise of e-commerce platforms, traditional shopping guides have been unable to keep up with the trend of product recommendation, and users are more inclined to shop online from platforms with a wide variety of products. However, due to the large number of products on the platform, the difficulty for users to choose is also increasing, so most platforms choose different recommendation systems according to their own characteristics to improve the user’s shopping experience. In the shopping process, it is easier for the platform to use the built recommendation model to score, filter, and sort the products according to the user’s browsing records, favorites, attention, and other information, and then push to the user several products that may be of interest to the user, thereby improving the user’s reputation and loyalty. The working principle of the recommender system is shown in Figure1. In Figure 1, it can be seen that the recommendation system is mainly composed of three parts when it is working, namely, the data source, the recommendation system, and the product recommendation [16]:(i)
Data Source. When recommending products to users, the data sources of the recommendation system come from user behavior, user information, and product information. Among them, user behaviors can be divided into explicit behaviors and implicit behaviors. Explicit behaviors are behaviors that clearly reveal users’ likes and dislikes of a certain product, such as user ratings, collections, and attention. These behavioral data are often used for analysis and use; implicit behaviors are behaviors such as browsing records that cannot clearly indicate the user’s likes and dislikes of a certain product. Although the data volume of this behavior is small, it also hides some interesting and imperceptible user preference information.(ii)
Recommendation System. Due to the different types of users, the recommendation algorithms used by the recommendation systems are also different. Common recommendation algorithms include collaborative filtering algorithms, content-based recommendation algorithms, and association rule-based recommendation algorithms.(iii)
Commodity Recommendation. The recommendation system selects the appropriate data source, uses the corresponding recommendation algorithm to process the data, sorts the processed products according to their scores, selects several products to form a recommended product list, and finally recommends them to the target users to complete the personalized recommendation task.Figure 1
Schematic diagram of the recommendation system.To sum up, the recommendation system is to establish the connection between the user and the item, select the appropriate data source and recommendation algorithm, filter out the items that the user is not interested in, and recommend the items that the user is interested in to complete the personalized recommendation.


## 3.2. AI Collaborative Filtering Recommendation Algorithm

### 3.2.1. Working Principle

After the collaborative filtering recommendation (CF) technology was proposed by Bob Goldberg et al., it has attracted the attention of scholars, achieved a series of research results, and successfully applied to multiple e-commerce platforms, becoming one of the most commonly used recommendation technologies for electronic commodity platforms one. The traditional collaborative filtering recommendation technology uses user behavior data to automatically mine user preferences, form a behavior pattern based on the user, and recommend suitable items for the user according to the pattern. To sum up, the recommendation process of collaborative filtering recommendation technology goes through three processes: collecting user evaluation information, using similarity to find neighbors, using neighbors to predict target user interests, and generating recommendation lists, as shown in Figure2 [17].Figure 2
Collaborative filtering recommendation process.(1) Obtain the Scoring Matrix. Let m and n be the number of users and products in the database, respectively, Ui and Ij are the i-th user and the j-th product (1 ≤i ≤ m, 1 ≤j ≤ n), respectively, and Rij is the user i. For the rating of commodity j (1 ≤ Rij ≤ 5, and Rij is an integer), the rating matrix M is formally defined as(1)M=Rijm×n.Definition formula (1) gives the definition of the rating matrix, in whichRij represents the user’s preference for a certain product. The higher the value, the more the user likes a certain product, otherwise, the less the user likes the product. The general representation of the scoring matrix is shown in Table 1.Table 1
Scoring matrix.
I1I2…In_U1 _33…3U244…5……………Um12…5(2) Select the Nearest Neighbor. In order to improve the recommendation accuracy, it is necessary to find the neighbor users by calculating the user similarity, and then sort and filter the appropriate neighbor set for analysis according to the similarity value. In the recommendation system, the calculation of the nearest neighbor is its core link. The nearest neighbor is generated by calculating the similarity between users (or products) (usually there are methods such as cosine similarity and Pearson similarity). The precision of the recommendation results has a significant impact. The common cosine similarity and Pearson similarity measurement methods are given below.Define formula (2). Letn be the number of items to be evaluated, u and v are any two users, Ru, c and Rv, c (1 ≤c ≤ n) are the scores of users u and v on item c respectively; let(2)simu,v=∑c=1nRu,cRv,c∑c=1nRu,c2∑c=1nRv,c2.Then, sim(u, v) is called the cosine similarity between users u and v.Define formula (3), letn be the number of items to be evaluated, u and v are any two users, Ru, c, Rv, c (1 ≤c ≤ n) are the scores of users u, v on item c, respectively, R¯U, R¯V are the mean scores of users u and v for all items, respectively, and let(3)simu,v=∑c∈Iu,vRu,c−RU¯Rv,c−Rv¯∑c∈Iu,vRu,c−RU¯2∑c∈Iu,vRv,c−Rv¯2.Then, sim(u,v) is called the Pearson similarity between users u and v.(3) Generate Recommendation. Select the nearest neighbor set according to the nearest neighbor set obtained by similarity, analyze the characteristics of the combination, and generate a list of recommended products most likely to meet the target user [18].Define formula (4). Let n be the number of items to be evaluated, u and v are any two users, Rv,i (1 <i ≤ n) is the rating of item i by user v, and the ratings R¯U of user u and v for all items, respectively. R¯V is the mean of item ratings, sim(u, v) is the similarity between users u and v, and let(4)pu,i=R¯U+∑v∈Vsimu,vRvi−R¯V∑v∈Vsimu,v.Then,Pu,i is called user u’s preference for item i.


### 3.2.2. Classification of Artificial Intelligence Algorithms

At present, collaborative filtering algorithms are mainly divided into user-based collaborative filtering algorithms (UserCF), item-based collaborative filtering algorithms (ItemCF), and model-based collaborative filtering algorithms (ModelCF). The three types of algorithms are briefly introduced below. (1) User-based collaborative filtering algorithm (UserCF): This recommendation algorithm takes registered users of e-commerce platforms as research objects and analyzes the interests of each user by collecting data on user behavior (such as purchasing items, collecting, and following). Calculate the similarity between users, build a neighbor user set, and generate recommendation results [19]. In simple terms, if user A and user B have purchased a large number of the same items, that is, there is a high overlap of purchased items, it is considered that these two users have high similarity in preferences and belong to the same type of user. If user A buys an item now, the system will think that user B will also like it with a high probability, and recommend the item to user B. The recommendation process of the recommendation algorithm is shown in Figure 3.Figure 3
Schematic diagram of user-based collaborative recommendation algorithm.In Figure3, user A has purchased products “fruit 1” and “fruit 2,” user B has purchased products “fruit 3,” and user C has purchased products “fruit 2,” “fruit 3,” and “fruit 4.” It can be seen that user A and user C are similar users. Since user C also purchased the product “fruit 4,” but user A has not bought it, UserCF will recommend the product “fruit 4” to A [20].In [2] item-based collaborative filtering algorithm (ItemCF): This recommendation algorithm is similar to UserCF, except that items are used instead of users when calculating neighbors; that is, the similarity between new items and purchased items is calculated according to the user’s historical preferences, and the similarity is recommended. It can be seen that the recommendation algorithm judges the similarity between items according to the user’s behavior, which is different from UserCF’s judgment of the similarity between users. The recommendation process of the recommendation algorithm is shown in Figure 4.Figure 4
Schematic diagram of item-based collaborative recommendation algorithm.In Figure4, user A has purchased products “fruit 2” and “fruit 4,” user B has purchased products “fruit 2,” “fruit 3,” and “fruit 4,” and user C has purchased products “fruit 2.” It can be seen that the users (A, B) who have purchased “fruit 2” both purchased “fruit 4” at the same time, and obtained “fruit 2” and “fruit 4” as related items. User C has also purchased “fruit 2.” The recommendation algorithm will consider that user C is also very likely to purchase “fruit 4,” so “fruit 4” is recommended to user C [21].(3) Model-based collaborative filtering algorithm (ModelCF): Although recommendation algorithms such as UserCF and ItemCF have the advantages of simple theory and high accuracy of recommendation results, in practical applications, people often use model-based collaborative filtering algorithms (ModelCF) to improve recommended efficiency. The model-based collaborative filtering algorithm uses user behavior scores to design a parameter model to describe the implicit relationship between users and items, users and users, items and items, etc., and finally uses the model to give recommendation results. Simply put, ModelCF uses a parametric model to predict the relationship between blank users and items based on the rating data of some users (other users have blank ratings) and recommends the highest rated items to users. Compared with recommendation algorithms such as UserCF and ItemCF, ModelCF can be trained offline and use the deployed parameter model for online recommendation, which meets the online requirements of electronic commodity platforms. In addition, ModelCF has strong scalability and can be combined with clustering models, classification models, regression models, Bayesian network models, etc., to improve the recommendation accuracy of recommendation algorithms.


## 3.2.1. Working Principle

After the collaborative filtering recommendation (CF) technology was proposed by Bob Goldberg et al., it has attracted the attention of scholars, achieved a series of research results, and successfully applied to multiple e-commerce platforms, becoming one of the most commonly used recommendation technologies for electronic commodity platforms one. The traditional collaborative filtering recommendation technology uses user behavior data to automatically mine user preferences, form a behavior pattern based on the user, and recommend suitable items for the user according to the pattern. To sum up, the recommendation process of collaborative filtering recommendation technology goes through three processes: collecting user evaluation information, using similarity to find neighbors, using neighbors to predict target user interests, and generating recommendation lists, as shown in Figure2 [17].Figure 2
Collaborative filtering recommendation process.(1) Obtain the Scoring Matrix. Let m and n be the number of users and products in the database, respectively, Ui and Ij are the i-th user and the j-th product (1 ≤i ≤ m, 1 ≤j ≤ n), respectively, and Rij is the user i. For the rating of commodity j (1 ≤ Rij ≤ 5, and Rij is an integer), the rating matrix M is formally defined as(1)M=Rijm×n.Definition formula (1) gives the definition of the rating matrix, in whichRij represents the user’s preference for a certain product. The higher the value, the more the user likes a certain product, otherwise, the less the user likes the product. The general representation of the scoring matrix is shown in Table 1.Table 1
Scoring matrix.
I1I2…In_U1 _33…3U244…5……………Um12…5(2) Select the Nearest Neighbor. In order to improve the recommendation accuracy, it is necessary to find the neighbor users by calculating the user similarity, and then sort and filter the appropriate neighbor set for analysis according to the similarity value. In the recommendation system, the calculation of the nearest neighbor is its core link. The nearest neighbor is generated by calculating the similarity between users (or products) (usually there are methods such as cosine similarity and Pearson similarity). The precision of the recommendation results has a significant impact. The common cosine similarity and Pearson similarity measurement methods are given below.Define formula (2). Letn be the number of items to be evaluated, u and v are any two users, Ru, c and Rv, c (1 ≤c ≤ n) are the scores of users u and v on item c respectively; let(2)simu,v=∑c=1nRu,cRv,c∑c=1nRu,c2∑c=1nRv,c2.Then, sim(u, v) is called the cosine similarity between users u and v.Define formula (3), letn be the number of items to be evaluated, u and v are any two users, Ru, c, Rv, c (1 ≤c ≤ n) are the scores of users u, v on item c, respectively, R¯U, R¯V are the mean scores of users u and v for all items, respectively, and let(3)simu,v=∑c∈Iu,vRu,c−RU¯Rv,c−Rv¯∑c∈Iu,vRu,c−RU¯2∑c∈Iu,vRv,c−Rv¯2.Then, sim(u,v) is called the Pearson similarity between users u and v.(3) Generate Recommendation. Select the nearest neighbor set according to the nearest neighbor set obtained by similarity, analyze the characteristics of the combination, and generate a list of recommended products most likely to meet the target user [18].Define formula (4). Let n be the number of items to be evaluated, u and v are any two users, Rv,i (1 <i ≤ n) is the rating of item i by user v, and the ratings R¯U of user u and v for all items, respectively. R¯V is the mean of item ratings, sim(u, v) is the similarity between users u and v, and let(4)pu,i=R¯U+∑v∈Vsimu,vRvi−R¯V∑v∈Vsimu,v.Then,Pu,i is called user u’s preference for item i.


## 3.2.2. Classification of Artificial Intelligence Algorithms

At present, collaborative filtering algorithms are mainly divided into user-based collaborative filtering algorithms (UserCF), item-based collaborative filtering algorithms (ItemCF), and model-based collaborative filtering algorithms (ModelCF). The three types of algorithms are briefly introduced below. (1) User-based collaborative filtering algorithm (UserCF): This recommendation algorithm takes registered users of e-commerce platforms as research objects and analyzes the interests of each user by collecting data on user behavior (such as purchasing items, collecting, and following). Calculate the similarity between users, build a neighbor user set, and generate recommendation results [19]. In simple terms, if user A and user B have purchased a large number of the same items, that is, there is a high overlap of purchased items, it is considered that these two users have high similarity in preferences and belong to the same type of user. If user A buys an item now, the system will think that user B will also like it with a high probability, and recommend the item to user B. The recommendation process of the recommendation algorithm is shown in Figure 3.Figure 3
Schematic diagram of user-based collaborative recommendation algorithm.In Figure3, user A has purchased products “fruit 1” and “fruit 2,” user B has purchased products “fruit 3,” and user C has purchased products “fruit 2,” “fruit 3,” and “fruit 4.” It can be seen that user A and user C are similar users. Since user C also purchased the product “fruit 4,” but user A has not bought it, UserCF will recommend the product “fruit 4” to A [20].In [2] item-based collaborative filtering algorithm (ItemCF): This recommendation algorithm is similar to UserCF, except that items are used instead of users when calculating neighbors; that is, the similarity between new items and purchased items is calculated according to the user’s historical preferences, and the similarity is recommended. It can be seen that the recommendation algorithm judges the similarity between items according to the user’s behavior, which is different from UserCF’s judgment of the similarity between users. The recommendation process of the recommendation algorithm is shown in Figure 4.Figure 4
Schematic diagram of item-based collaborative recommendation algorithm.In Figure4, user A has purchased products “fruit 2” and “fruit 4,” user B has purchased products “fruit 2,” “fruit 3,” and “fruit 4,” and user C has purchased products “fruit 2.” It can be seen that the users (A, B) who have purchased “fruit 2” both purchased “fruit 4” at the same time, and obtained “fruit 2” and “fruit 4” as related items. User C has also purchased “fruit 2.” The recommendation algorithm will consider that user C is also very likely to purchase “fruit 4,” so “fruit 4” is recommended to user C [21].(3) Model-based collaborative filtering algorithm (ModelCF): Although recommendation algorithms such as UserCF and ItemCF have the advantages of simple theory and high accuracy of recommendation results, in practical applications, people often use model-based collaborative filtering algorithms (ModelCF) to improve recommended efficiency. The model-based collaborative filtering algorithm uses user behavior scores to design a parameter model to describe the implicit relationship between users and items, users and users, items and items, etc., and finally uses the model to give recommendation results. Simply put, ModelCF uses a parametric model to predict the relationship between blank users and items based on the rating data of some users (other users have blank ratings) and recommends the highest rated items to users. Compared with recommendation algorithms such as UserCF and ItemCF, ModelCF can be trained offline and use the deployed parameter model for online recommendation, which meets the online requirements of electronic commodity platforms. In addition, ModelCF has strong scalability and can be combined with clustering models, classification models, regression models, Bayesian network models, etc., to improve the recommendation accuracy of recommendation algorithms.


## 4. Construction of Precision Service Algorithm for e-Commerce of Agricultural Products Based on Artificial Intelligence

From the working principle of collaborative filtering algorithm, it can be seen that the recommendation process of this type of algorithm is divided into three parts: obtaining score matrix, selecting neighbors, and generating recommendation. Among them, the calculation of nearest neighbors is the core of this type of algorithm, and the selection of similar users (products) will greatly affect the efficiency of the recommendation algorithm. In order to better solve the problems such as cold start and data sparseness faced by traditional algorithms, this chapter will integrate basic user information and user preferences to improve the calculation method of user similarity, and propose a corresponding improved algorithm to quickly find the nearest neighbor set of the current user.


### 4.1. Problems Faced by Traditional Artificial Intelligence Collaborative Filtering Algorithms

When recommending products, although the traditional collaborative filtering algorithm has the advantages of easy implementation and concise recommendation process, it faces the following problems because it uses the user-rating matrix to complete the calculation of user similarity:(i)
Cold Start Problem. Since the collaborative filtering algorithm is recommended based on user behavior, if the recommendation system has a large number of new users registered, often because these users do not have purchase records, browsing records, and other information, the recommendation system will not be able to recommend new users effectively recommended effect.(ii)
Data Sparse Problem. When using the recommender system for shopping, most users rarely evaluate the purchased products, which makes the rating data sparse, and cannot provide the recommender system with the necessary data to calculate the user similarity, resulting in low recommendation efficiency.(iii)
Model Adaptability Problem. Since the recommender system needs to quickly process a large amount of user-item data to complete the nearest neighbor finding task, but with the increase of users and items, the calculation amount of the nearest neighbor increases sharply. At this time, the model adaptability of the recommender system becomes a constraint on its recommendation, one of the key factors of efficiency [22].


### 4.2. Improved Algorithm of Collaborative Filtering for Agricultural Product Users Based on Artificial Intelligence

Combined with the existing user-based collaborative filtering algorithms, this paper integrates user basic information and user preferences to calculate user similarity. Users with similar user preferences can be found, and the agricultural products browsed or purchased by these users are recommended to the current user according to the rules. This can not only increase the sales of agricultural products, but also save users’’ purchase time.


#### 4.2.1. User Basic Information Similarity under Agricultural Product e-Commerce

In the agricultural product e-commerce recommendation system in this paper, the calculation of user similarity sim(x, y) includes two parts: user basic information similarity sim base (x, y) and user preference similarity sim preference (x, y). Combined with the relevant literature, the definition of user similarity in this paper is given below [23].Define formula (5). Let x and y be two different users of the recommender system, Rx = {Rx1, Rx2,…,Rxn}, Ry = {Ry1, Ry2,…,Ryn}(n is a certain number of attributes of user basic information) are the discretized basic information attribute value sets of users x and yR¯x, R¯y, respectively, and are the mean value of the attribute values of x and y, respectively, and let(5)simbasex,y=∑i=1nRxi−Rx¯Ryi−Ry¯∑i=1nRxi−Rx¯2∑i=1nRyi−Ry¯2.Then, simbase(x, y) is called the similarity of user basic information of users x and y.


#### 4.2.2. User Preference Similarity under Agricultural Product e-Commerce

When calculating the similarity of user preferences, the traditional cosine similarity method cannot take into account the weight value of each user’s preference. Therefore, the similarity of different users about a preference is given below. Define formula 6. Letx and y be two different users of the recommender system, lxki and lyki are the i-th attribute value of the k-th preference in the user preference model of users x and yl¯xk, l¯yk, respectively.(6)sk=∑i=1nlxki−lxk¯∗lyki−lyk¯∑i=1nlxki−lxk¯2∑i=1nlyki−lyk¯2.Then,Sk is called the similarity between users x and y about the k-th preference in the user preference model.Next, the user preference weight is combined into the similarity of the user preference model.Define formula (7). Let x and y be two different users of the recommendation system, wxk and wyk are the weight values of the k-th preference of users x and y, respectively, and Sk is the k-th preference of usersx and y in the user preference model. Similarity of preferences is(7)simpreferencex,y=∑k=1nwxk∗wyk∗sk2.Then, simpreference (x, y) is called the similarity of user preference models of users x and y.


#### 4.2.3. User Similarity under e-Commerce of Agricultural Products

Combined with (6) and (7), the user similarity calculation formula proposed in this paper is as follows. In Formula (8), let x and y be two different users of the recommender system, sim base (x, y) is the similarity of user basic information of users x and y, and sim preference (x, y) is the similarity of user preference models of users x and y degree order.(8)simusersx,y=a∗simbasex,y+1−asimpreferencex,y.Then, simusers (x, y) is called the user similarity of users x and y, where α (0 < α ≤ 1) is the weight of simbase (x, y) in the entire user similarity, also known as the balance factor. By adjusting the value of α, the recommendation accuracy can be changed to complete accurate personalized recommendation. In particular, for new users, since the system cannot record their personal behavior information and build a corresponding user preference model, the user similarity can only be determined by sim base (x, y), where α = 1. However, sim users (x, y) is not suitable for all cases, so in order to prevent the correlation coefficient from being too large due to too little common basic information or preference information of users, it is necessary to improve sim users (x, y) and add a penalty factor, and its improvement method is shown in the definition formula (9). Define formula (9). Let x and y be two different users of the recommendation system, simusers(x, y) is the user similarity of users x and y, Noverlap is the number of items scored by the target user and known users together, and N penalty is the weight value factor fixed value; let(9)simusersx,y=simuserx,y×NoverlapNpenalty.Then, simusers (x, y) is called the corrected user similarity, where Npenalty is generally 50.


#### 4.2.4. Improved Collaborative Filtering Algorithm under the e-Commerce of Agricultural Products

The improved collaborative filtering algorithm divides the data set into training set and test set proportionally. In the training set, by calculating the user similarity that fuses user basic information and user preferences, users whose user similarity is greater than the similarity threshold are added to the nearest neighbor set, forming the nearest neighbor set. Then, read the test set data and generate a recommendation list based on the nearest neighbor set. The pseudo-code of the improved algorithm is shown in Table2 [24].Table 2
Pseudo-code of improved collaborative filtering recommendation algorithm.
Serial numberThe pseudo-code1Input: target userx, user similarity threshold γ2Split the data set, 75% of the data set is used as the training set TrainSets, and the rest is used as the test set TestSets3If TrainSets =θ, go to step 94Else take anyy ∈ TrainSets and calculate sim’ users (x, y)5For∀, ∀y ∈ TrainSets6If sim’users (x, y)≥γ7Nearest NeighborSets = NearestNeighborSets∪ {y}, TrainSets = TrainSets-y8Else TrainSets = TrainSets-y, go to step 39Read TestSets10According to the nearest neighbor set, generate the recommendation list RecommendationLists ofx11Algorithm ends


## 4.1. Problems Faced by Traditional Artificial Intelligence Collaborative Filtering Algorithms

When recommending products, although the traditional collaborative filtering algorithm has the advantages of easy implementation and concise recommendation process, it faces the following problems because it uses the user-rating matrix to complete the calculation of user similarity:(i)
Cold Start Problem. Since the collaborative filtering algorithm is recommended based on user behavior, if the recommendation system has a large number of new users registered, often because these users do not have purchase records, browsing records, and other information, the recommendation system will not be able to recommend new users effectively recommended effect.(ii)
Data Sparse Problem. When using the recommender system for shopping, most users rarely evaluate the purchased products, which makes the rating data sparse, and cannot provide the recommender system with the necessary data to calculate the user similarity, resulting in low recommendation efficiency.(iii)
Model Adaptability Problem. Since the recommender system needs to quickly process a large amount of user-item data to complete the nearest neighbor finding task, but with the increase of users and items, the calculation amount of the nearest neighbor increases sharply. At this time, the model adaptability of the recommender system becomes a constraint on its recommendation, one of the key factors of efficiency [22].


## 4.2. Improved Algorithm of Collaborative Filtering for Agricultural Product Users Based on Artificial Intelligence

Combined with the existing user-based collaborative filtering algorithms, this paper integrates user basic information and user preferences to calculate user similarity. Users with similar user preferences can be found, and the agricultural products browsed or purchased by these users are recommended to the current user according to the rules. This can not only increase the sales of agricultural products, but also save users’’ purchase time.


### 4.2.1. User Basic Information Similarity under Agricultural Product e-Commerce

In the agricultural product e-commerce recommendation system in this paper, the calculation of user similarity sim(x, y) includes two parts: user basic information similarity sim base (x, y) and user preference similarity sim preference (x, y). Combined with the relevant literature, the definition of user similarity in this paper is given below [23].Define formula (5). Let x and y be two different users of the recommender system, Rx = {Rx1, Rx2,…,Rxn}, Ry = {Ry1, Ry2,…,Ryn}(n is a certain number of attributes of user basic information) are the discretized basic information attribute value sets of users x and yR¯x, R¯y, respectively, and are the mean value of the attribute values of x and y, respectively, and let(5)simbasex,y=∑i=1nRxi−Rx¯Ryi−Ry¯∑i=1nRxi−Rx¯2∑i=1nRyi−Ry¯2.Then, simbase(x, y) is called the similarity of user basic information of users x and y.


### 4.2.2. User Preference Similarity under Agricultural Product e-Commerce

When calculating the similarity of user preferences, the traditional cosine similarity method cannot take into account the weight value of each user’s preference. Therefore, the similarity of different users about a preference is given below. Define formula 6. Letx and y be two different users of the recommender system, lxki and lyki are the i-th attribute value of the k-th preference in the user preference model of users x and yl¯xk, l¯yk, respectively.(6)sk=∑i=1nlxki−lxk¯∗lyki−lyk¯∑i=1nlxki−lxk¯2∑i=1nlyki−lyk¯2.Then,Sk is called the similarity between users x and y about the k-th preference in the user preference model.Next, the user preference weight is combined into the similarity of the user preference model.Define formula (7). Let x and y be two different users of the recommendation system, wxk and wyk are the weight values of the k-th preference of users x and y, respectively, and Sk is the k-th preference of usersx and y in the user preference model. Similarity of preferences is(7)simpreferencex,y=∑k=1nwxk∗wyk∗sk2.Then, simpreference (x, y) is called the similarity of user preference models of users x and y.


### 4.2.3. User Similarity under e-Commerce of Agricultural Products

Combined with (6) and (7), the user similarity calculation formula proposed in this paper is as follows. In Formula (8), let x and y be two different users of the recommender system, sim base (x, y) is the similarity of user basic information of users x and y, and sim preference (x, y) is the similarity of user preference models of users x and y degree order.(8)simusersx,y=a∗simbasex,y+1−asimpreferencex,y.Then, simusers (x, y) is called the user similarity of users x and y, where α (0 < α ≤ 1) is the weight of simbase (x, y) in the entire user similarity, also known as the balance factor. By adjusting the value of α, the recommendation accuracy can be changed to complete accurate personalized recommendation. In particular, for new users, since the system cannot record their personal behavior information and build a corresponding user preference model, the user similarity can only be determined by sim base (x, y), where α = 1. However, sim users (x, y) is not suitable for all cases, so in order to prevent the correlation coefficient from being too large due to too little common basic information or preference information of users, it is necessary to improve sim users (x, y) and add a penalty factor, and its improvement method is shown in the definition formula (9). Define formula (9). Let x and y be two different users of the recommendation system, simusers(x, y) is the user similarity of users x and y, Noverlap is the number of items scored by the target user and known users together, and N penalty is the weight value factor fixed value; let(9)simusersx,y=simuserx,y×NoverlapNpenalty.Then, simusers (x, y) is called the corrected user similarity, where Npenalty is generally 50.


### 4.2.4. Improved Collaborative Filtering Algorithm under the e-Commerce of Agricultural Products

The improved collaborative filtering algorithm divides the data set into training set and test set proportionally. In the training set, by calculating the user similarity that fuses user basic information and user preferences, users whose user similarity is greater than the similarity threshold are added to the nearest neighbor set, forming the nearest neighbor set. Then, read the test set data and generate a recommendation list based on the nearest neighbor set. The pseudo-code of the improved algorithm is shown in Table2 [24].Table 2
Pseudo-code of improved collaborative filtering recommendation algorithm.
Serial numberThe pseudo-code1Input: target userx, user similarity threshold γ2Split the data set, 75% of the data set is used as the training set TrainSets, and the rest is used as the test set TestSets3If TrainSets =θ, go to step 94Else take anyy ∈ TrainSets and calculate sim’ users (x, y)5For∀, ∀y ∈ TrainSets6If sim’users (x, y)≥γ7Nearest NeighborSets = NearestNeighborSets∪ {y}, TrainSets = TrainSets-y8Else TrainSets = TrainSets-y, go to step 39Read TestSets10According to the nearest neighbor set, generate the recommendation list RecommendationLists ofx11Algorithm ends


## 4.2.1. User Basic Information Similarity under Agricultural Product e-Commerce

In the agricultural product e-commerce recommendation system in this paper, the calculation of user similarity sim(x, y) includes two parts: user basic information similarity sim base (x, y) and user preference similarity sim preference (x, y). Combined with the relevant literature, the definition of user similarity in this paper is given below [23].Define formula (5). Let x and y be two different users of the recommender system, Rx = {Rx1, Rx2,…,Rxn}, Ry = {Ry1, Ry2,…,Ryn}(n is a certain number of attributes of user basic information) are the discretized basic information attribute value sets of users x and yR¯x, R¯y, respectively, and are the mean value of the attribute values of x and y, respectively, and let(5)simbasex,y=∑i=1nRxi−Rx¯Ryi−Ry¯∑i=1nRxi−Rx¯2∑i=1nRyi−Ry¯2.Then, simbase(x, y) is called the similarity of user basic information of users x and y.


## 4.2.2. User Preference Similarity under Agricultural Product e-Commerce

When calculating the similarity of user preferences, the traditional cosine similarity method cannot take into account the weight value of each user’s preference. Therefore, the similarity of different users about a preference is given below. Define formula 6. Letx and y be two different users of the recommender system, lxki and lyki are the i-th attribute value of the k-th preference in the user preference model of users x and yl¯xk, l¯yk, respectively.(6)sk=∑i=1nlxki−lxk¯∗lyki−lyk¯∑i=1nlxki−lxk¯2∑i=1nlyki−lyk¯2.Then,Sk is called the similarity between users x and y about the k-th preference in the user preference model.Next, the user preference weight is combined into the similarity of the user preference model.Define formula (7). Let x and y be two different users of the recommendation system, wxk and wyk are the weight values of the k-th preference of users x and y, respectively, and Sk is the k-th preference of usersx and y in the user preference model. Similarity of preferences is(7)simpreferencex,y=∑k=1nwxk∗wyk∗sk2.Then, simpreference (x, y) is called the similarity of user preference models of users x and y.


## 4.2.3. User Similarity under e-Commerce of Agricultural Products

Combined with (6) and (7), the user similarity calculation formula proposed in this paper is as follows. In Formula (8), let x and y be two different users of the recommender system, sim base (x, y) is the similarity of user basic information of users x and y, and sim preference (x, y) is the similarity of user preference models of users x and y degree order.(8)simusersx,y=a∗simbasex,y+1−asimpreferencex,y.Then, simusers (x, y) is called the user similarity of users x and y, where α (0 < α ≤ 1) is the weight of simbase (x, y) in the entire user similarity, also known as the balance factor. By adjusting the value of α, the recommendation accuracy can be changed to complete accurate personalized recommendation. In particular, for new users, since the system cannot record their personal behavior information and build a corresponding user preference model, the user similarity can only be determined by sim base (x, y), where α = 1. However, sim users (x, y) is not suitable for all cases, so in order to prevent the correlation coefficient from being too large due to too little common basic information or preference information of users, it is necessary to improve sim users (x, y) and add a penalty factor, and its improvement method is shown in the definition formula (9). Define formula (9). Let x and y be two different users of the recommendation system, simusers(x, y) is the user similarity of users x and y, Noverlap is the number of items scored by the target user and known users together, and N penalty is the weight value factor fixed value; let(9)simusersx,y=simuserx,y×NoverlapNpenalty.Then, simusers (x, y) is called the corrected user similarity, where Npenalty is generally 50.


## 4.2.4. Improved Collaborative Filtering Algorithm under the e-Commerce of Agricultural Products

The improved collaborative filtering algorithm divides the data set into training set and test set proportionally. In the training set, by calculating the user similarity that fuses user basic information and user preferences, users whose user similarity is greater than the similarity threshold are added to the nearest neighbor set, forming the nearest neighbor set. Then, read the test set data and generate a recommendation list based on the nearest neighbor set. The pseudo-code of the improved algorithm is shown in Table2 [24].Table 2
Pseudo-code of improved collaborative filtering recommendation algorithm.
Serial numberThe pseudo-code1Input: target userx, user similarity threshold γ2Split the data set, 75% of the data set is used as the training set TrainSets, and the rest is used as the test set TestSets3If TrainSets =θ, go to step 94Else take anyy ∈ TrainSets and calculate sim’ users (x, y)5For∀, ∀y ∈ TrainSets6If sim’users (x, y)≥γ7Nearest NeighborSets = NearestNeighborSets∪ {y}, TrainSets = TrainSets-y8Else TrainSets = TrainSets-y, go to step 39Read TestSets10According to the nearest neighbor set, generate the recommendation list RecommendationLists ofx11Algorithm ends


## 5. Experimental Results and Analysis

### 5.1. Experimental Evaluation Indicators

The main task of the recommender system is to establish the connection between users and items, realize information filtering, and improve the user’s shopping experience. Note that due to the different types of recommender systems, items can be commodities, news, advertisements, etc. A good recommendation system can not only obtain user information normally, but also improve user adhesion through item recommendation and enhance users’’ goodwill toward the website. The commonly used evaluation indicators in recommender systems are recall rate, accuracy rate, mean absolute error, and other indicators. Define formula (10). Let u be a certain commodity, U be the set of all commodities in the database, and T (u) and P (u) are the test commodity set and the recommended commodity set, respectively. If(10)recall=∑u∈Upu∩​Tu∑u∈UTu,(11)precision=∑u∈Upu∩​Tu∑u∈Upu.then recall and precision are the recommended recall rate and precision rate, respectively, where |·| represents the number of objects in the set. Define formula (11). Let u and i be a certain user and a certain product, respectively, and rui and lui are the actual score and predicted score of user u for product i, respectively. If(12)MAE=∑u,i∈Trui−luiTu.MSE=∑u,i∈Trui−lui2Tu,RMSE=∑u,i∈Trui−lui2Tu.Then, MAE, MSE, and RMSE are called mean absolute error, mean square error, and root mean square error, respectively, where |·| represents the number of objects in the set.


### 5.2. Experimental Environment

The experimental environment is Intel Core i7, 3.4 GHz CPU, 32 GB RAM, Win7 64 bit OS. Since there is no open-source agricultural product data set yet, this experimental data set is mainly obtained from some large e-commerce platforms using crawler technology. After crawling, this paper selects a data set containing 865 users, 1635 agricultural products, and 30,000 reviews (with a score ranging from 1 to 5). In order to verify the effectiveness of the algorithm, combined with the experimental evaluation indicators in Section5.1, this paper completes the experimental comparison between the traditional algorithm and the algorithm in this paper through other experiments such as the recall rate and accuracy rate experiment, and the mean absolute error experiment, and verifies the reliability of the algorithm in this paper and efficiency.


### 5.3. Experimental Comparison of Different Algorithms

In order to test the effectiveness of this algorithm, in the experimental environment with the same test set and data sparsity, two traditional collaborative filtering methods, such as the proposed algorithm based on item fuzzy similarity in the literature and the content-based recommendation algorithm in the literature, were compared. The algorithm is compared in the following experiments.


#### 5.3.1. Determining the Balance Factor

Since the algorithm in this paper needs to set the balance factorα first, before conducting other index comparison experiments, the optimal balance factor α is obtained by calculating the average absolute error of the algorithm in this paper under different balance factors. Through calculation, the relationship between the balance factor α and the mean absolute error (MAE) can be obtained, as shown in Figure 5.Figure 5
Average absolute error and balance factor change curve.From Figure5 that when the balance factor α < 0.4, the MAE of the algorithm gradually decreases. When the balance factor α > 0.4, although the MAE of the algorithm fluctuates, the overall trend is upward. It can be seen that when the balance factor α = 0.4, the average absolute error of the algorithm in this paper is the smallest, and the recommendation accuracy reaches the maximum value, so the recommended system α in this paper is 0.4.


#### 5.3.2. Recall and Accuracy Experiments

When conducting experiments, this paper divides the data set, of which 75% of the data set is the training set and 25% of the data set is the test set. Since the number of recommended products will affect the recommendation quality, this experiment will compare the recall rate, accuracy rate, and other indicators of the above three algorithms under the condition of different recommendation lengths, as shown in Figures6 and 7.Figure 6
Change curve of recall rate when the recommendation length is the same.Figure 7
Accuracy change curve when the recommended length is the same.From Figure6, when the recommendation length exceeds 15, the recall rate of our algorithm begins to outperform the other two algorithms, reaches a peak when the recommendation length is 25, and gradually stabilizes. It can be seen from Figure 7 that the accuracy of the algorithm in this paper is better than the other two algorithms under different recommendation lengths, and tends to be stable when the recommendation length is 25. It can be seen that the recommendation effect of the algorithm in this paper is faced with these two evaluation indicators. Better, it helps to solve the problem of data sparseness.


#### 5.3.3. Experiments on the Relationship between the Number of Nearest Neighbors, the Proportion of Different Training Sets, and MAE

First, the algorithm is compared through the relationship between the number of nearest neighbors and MAE, and the experimental results are shown in Figure8. It can be seen that, compared with the last two traditional collaborative filtering algorithms, the average absolute error of this algorithm is the smallest, and it maintains a relatively smooth curve with the increase of the number of nearest neighbors, indicating that the algorithm in this paper has high accuracy and certain robustness and general applicability. In addition, in this experiment, with the increase of the number of nearest neighbors, the MAE curve of the algorithm tends to be stable, and when the number of nearest neighbors is 40, the average absolute error reaches the minimum value, and then the curve fluctuates upward again, indicating that the larger the number of nearest neighbors, the better. When the number of nearest neighbors is 40, the prediction quality of the algorithm in this paper is the best.Figure 8
Change curve of the relationship between the number of nearest neighbors and MAE.Secondly, this paper compares the algorithms through the relationship between different training set ratios and MAE. The experimental results are shown in Figure9. It can be seen from Figure 9 that when the proportion of the training set is small, the MAE of the algorithm in this paper is relatively low, and it is significantly different from the other two algorithms. As the proportion of the training set increases, the MAE gap of the three algorithms gradually becomes smaller, but the overall MAE of the algorithm in this paper is lower than that of the other two algorithms, and the algorithm performance is better.Figure 9
The curve of the relationship between the proportion of different training sets and MAE.


## 5.1. Experimental Evaluation Indicators

The main task of the recommender system is to establish the connection between users and items, realize information filtering, and improve the user’s shopping experience. Note that due to the different types of recommender systems, items can be commodities, news, advertisements, etc. A good recommendation system can not only obtain user information normally, but also improve user adhesion through item recommendation and enhance users’’ goodwill toward the website. The commonly used evaluation indicators in recommender systems are recall rate, accuracy rate, mean absolute error, and other indicators. Define formula (10). Let u be a certain commodity, U be the set of all commodities in the database, and T (u) and P (u) are the test commodity set and the recommended commodity set, respectively. If(10)recall=∑u∈Upu∩​Tu∑u∈UTu,(11)precision=∑u∈Upu∩​Tu∑u∈Upu.then recall and precision are the recommended recall rate and precision rate, respectively, where |·| represents the number of objects in the set. Define formula (11). Let u and i be a certain user and a certain product, respectively, and rui and lui are the actual score and predicted score of user u for product i, respectively. If(12)MAE=∑u,i∈Trui−luiTu.MSE=∑u,i∈Trui−lui2Tu,RMSE=∑u,i∈Trui−lui2Tu.Then, MAE, MSE, and RMSE are called mean absolute error, mean square error, and root mean square error, respectively, where |·| represents the number of objects in the set.


## 5.2. Experimental Environment

The experimental environment is Intel Core i7, 3.4 GHz CPU, 32 GB RAM, Win7 64 bit OS. Since there is no open-source agricultural product data set yet, this experimental data set is mainly obtained from some large e-commerce platforms using crawler technology. After crawling, this paper selects a data set containing 865 users, 1635 agricultural products, and 30,000 reviews (with a score ranging from 1 to 5). In order to verify the effectiveness of the algorithm, combined with the experimental evaluation indicators in Section5.1, this paper completes the experimental comparison between the traditional algorithm and the algorithm in this paper through other experiments such as the recall rate and accuracy rate experiment, and the mean absolute error experiment, and verifies the reliability of the algorithm in this paper and efficiency.


## 5.3. Experimental Comparison of Different Algorithms

In order to test the effectiveness of this algorithm, in the experimental environment with the same test set and data sparsity, two traditional collaborative filtering methods, such as the proposed algorithm based on item fuzzy similarity in the literature and the content-based recommendation algorithm in the literature, were compared. The algorithm is compared in the following experiments.


### 5.3.1. Determining the Balance Factor

Since the algorithm in this paper needs to set the balance factorα first, before conducting other index comparison experiments, the optimal balance factor α is obtained by calculating the average absolute error of the algorithm in this paper under different balance factors. Through calculation, the relationship between the balance factor α and the mean absolute error (MAE) can be obtained, as shown in Figure 5.Figure 5
Average absolute error and balance factor change curve.From Figure5 that when the balance factor α < 0.4, the MAE of the algorithm gradually decreases. When the balance factor α > 0.4, although the MAE of the algorithm fluctuates, the overall trend is upward. It can be seen that when the balance factor α = 0.4, the average absolute error of the algorithm in this paper is the smallest, and the recommendation accuracy reaches the maximum value, so the recommended system α in this paper is 0.4.


### 5.3.2. Recall and Accuracy Experiments

When conducting experiments, this paper divides the data set, of which 75% of the data set is the training set and 25% of the data set is the test set. Since the number of recommended products will affect the recommendation quality, this experiment will compare the recall rate, accuracy rate, and other indicators of the above three algorithms under the condition of different recommendation lengths, as shown in Figures6 and 7.Figure 6
Change curve of recall rate when the recommendation length is the same.Figure 7
Accuracy change curve when the recommended length is the same.From Figure6, when the recommendation length exceeds 15, the recall rate of our algorithm begins to outperform the other two algorithms, reaches a peak when the recommendation length is 25, and gradually stabilizes. It can be seen from Figure 7 that the accuracy of the algorithm in this paper is better than the other two algorithms under different recommendation lengths, and tends to be stable when the recommendation length is 25. It can be seen that the recommendation effect of the algorithm in this paper is faced with these two evaluation indicators. Better, it helps to solve the problem of data sparseness.


### 5.3.3. Experiments on the Relationship between the Number of Nearest Neighbors, the Proportion of Different Training Sets, and MAE

First, the algorithm is compared through the relationship between the number of nearest neighbors and MAE, and the experimental results are shown in Figure8. It can be seen that, compared with the last two traditional collaborative filtering algorithms, the average absolute error of this algorithm is the smallest, and it maintains a relatively smooth curve with the increase of the number of nearest neighbors, indicating that the algorithm in this paper has high accuracy and certain robustness and general applicability. In addition, in this experiment, with the increase of the number of nearest neighbors, the MAE curve of the algorithm tends to be stable, and when the number of nearest neighbors is 40, the average absolute error reaches the minimum value, and then the curve fluctuates upward again, indicating that the larger the number of nearest neighbors, the better. When the number of nearest neighbors is 40, the prediction quality of the algorithm in this paper is the best.Figure 8
Change curve of the relationship between the number of nearest neighbors and MAE.Secondly, this paper compares the algorithms through the relationship between different training set ratios and MAE. The experimental results are shown in Figure9. It can be seen from Figure 9 that when the proportion of the training set is small, the MAE of the algorithm in this paper is relatively low, and it is significantly different from the other two algorithms. As the proportion of the training set increases, the MAE gap of the three algorithms gradually becomes smaller, but the overall MAE of the algorithm in this paper is lower than that of the other two algorithms, and the algorithm performance is better.Figure 9
The curve of the relationship between the proportion of different training sets and MAE.


## 5.3.1. Determining the Balance Factor

Since the algorithm in this paper needs to set the balance factorα first, before conducting other index comparison experiments, the optimal balance factor α is obtained by calculating the average absolute error of the algorithm in this paper under different balance factors. Through calculation, the relationship between the balance factor α and the mean absolute error (MAE) can be obtained, as shown in Figure 5.Figure 5
Average absolute error and balance factor change curve.From Figure5 that when the balance factor α < 0.4, the MAE of the algorithm gradually decreases. When the balance factor α > 0.4, although the MAE of the algorithm fluctuates, the overall trend is upward. It can be seen that when the balance factor α = 0.4, the average absolute error of the algorithm in this paper is the smallest, and the recommendation accuracy reaches the maximum value, so the recommended system α in this paper is 0.4.


## 5.3.2. Recall and Accuracy Experiments

When conducting experiments, this paper divides the data set, of which 75% of the data set is the training set and 25% of the data set is the test set. Since the number of recommended products will affect the recommendation quality, this experiment will compare the recall rate, accuracy rate, and other indicators of the above three algorithms under the condition of different recommendation lengths, as shown in Figures6 and 7.Figure 6
Change curve of recall rate when the recommendation length is the same.Figure 7
Accuracy change curve when the recommended length is the same.From Figure6, when the recommendation length exceeds 15, the recall rate of our algorithm begins to outperform the other two algorithms, reaches a peak when the recommendation length is 25, and gradually stabilizes. It can be seen from Figure 7 that the accuracy of the algorithm in this paper is better than the other two algorithms under different recommendation lengths, and tends to be stable when the recommendation length is 25. It can be seen that the recommendation effect of the algorithm in this paper is faced with these two evaluation indicators. Better, it helps to solve the problem of data sparseness.


## 5.3.3. Experiments on the Relationship between the Number of Nearest Neighbors, the Proportion of Different Training Sets, and MAE

First, the algorithm is compared through the relationship between the number of nearest neighbors and MAE, and the experimental results are shown in Figure8. It can be seen that, compared with the last two traditional collaborative filtering algorithms, the average absolute error of this algorithm is the smallest, and it maintains a relatively smooth curve with the increase of the number of nearest neighbors, indicating that the algorithm in this paper has high accuracy and certain robustness and general applicability. In addition, in this experiment, with the increase of the number of nearest neighbors, the MAE curve of the algorithm tends to be stable, and when the number of nearest neighbors is 40, the average absolute error reaches the minimum value, and then the curve fluctuates upward again, indicating that the larger the number of nearest neighbors, the better. When the number of nearest neighbors is 40, the prediction quality of the algorithm in this paper is the best.Figure 8
Change curve of the relationship between the number of nearest neighbors and MAE.Secondly, this paper compares the algorithms through the relationship between different training set ratios and MAE. The experimental results are shown in Figure9. It can be seen from Figure 9 that when the proportion of the training set is small, the MAE of the algorithm in this paper is relatively low, and it is significantly different from the other two algorithms. As the proportion of the training set increases, the MAE gap of the three algorithms gradually becomes smaller, but the overall MAE of the algorithm in this paper is lower than that of the other two algorithms, and the algorithm performance is better.Figure 9
The curve of the relationship between the proportion of different training sets and MAE.


## 6. Conclusion

The combination of algorithm and artificial intelligence, and its intelligent upgrade is mainly manifested in three aspects: one is to achieve more accurate communication with higher matching degree, the second is efficient customized communication, and the third is to realize the contextual interaction between advertisements and users. Through the upgrade of precise communication, the key lies in the combination of artificial intelligence algorithms, intensive processing through data mining and analysis, and advertising based on the intelligent user portrait tag system. Through the intelligent user portrait, the algorithm can realize the intelligent push of “thousands of people and thousands of faces.” The application of artificial intelligence technology enables the automatic push of computing advertisements to make intelligent decisions based on data analysis of users’’ real-time usage scenarios, and to achieve contextual interaction between merchants and users. By using related development technologies, this paper designs and develops a recommendation system for agricultural product e-commerce, which not only allows users to browse, search, and purchase agricultural products normally, but also recommends agricultural products that meet user preferences to users by using the recommendation model. In addition, the administrator can also manage agricultural products, users, orders, etc. The system functions are relatively complete and can meet the needs of agricultural product recommendation.



---

*Source: 8323467-2022-10-05.xml*