Background
In recent years, along with the rapid development of electronic commerce, a great amount of network image data is generated, and in the face of such a great amount of image data, a user wants to be able to quickly locate image information of interest of the user, and search becomes a necessary function for realizing the purpose, while the search is a service request initiated by the user actively, in order to enable the system to actively provide services for customers, an image recommendation system is provided, and image content which is most likely to be of interest to the user in an image database is recommended for the user by analyzing historical data of interest to the user and image data in the image database, that is, an image closest to the image of interest to the user historical is recommended to the user.
Most of the commercial product search systems currently used in large e-commerce websites use keyword-based searches, such as Taobao, Amazon, etc., the image retrieval system based on the keywords requires that the commodity image must be added with the relevant text description information of the name, the category and the like of the commodity, and then the search keywords input by the user are matched with the text description of the commodity, however, the text information is difficult to completely describe all the characteristics of the commodity, and the influence of user subjective factors is very large, so that the commodity description information input by the user is difficult to objectively and accurately, different commodity requirements can reflect the same keywords under the user subjective condition, or the same commodity requirements reflect different keywords, so that the returned image sets have great difference, and the efficiency of searching the interested images by the user is greatly reduced. In the searching process based on the keywords, a large amount of time and labor are consumed for sorting the additional text information of the standard commodities, and the searching keywords also have great influence on the searching results due to the influence of the subjective factors of the user. How to reduce the influence of these factors on the search results is attracting more and more attention, and the problem proposed above can be effectively solved by using image content to perform relevant search and reducing the dependence on text information.
The traditional image retrieval based on image content extracts the visual features of the image through the visual features of the color, texture or shape of the image, and the retrieval method is influenced by the environment and image shooting equipment when the image is shot, and can seriously influence the image search result. How to reduce the influence of these factors on the retrieval result as much as possible is still a difficulty. Moreover, the traditional image recommendation only focuses on the attributes of the articles, cannot take the personal preference and interest of the user into consideration, and cannot realize accurate personalized recommendation.
Disclosure of Invention
Aiming at the problems in the prior art, the invention provides an image recommendation method integrating visual features and user scores so as to improve recommendation precision and realize personalized recommendation.
The invention adopts the following technical scheme for solving the technical problems:
the invention relates to an image recommendation method integrating visual features and user scores, which is characterized by comprising the following steps of:
step 1, crawling an article image set P and a corresponding article scoring data set Q from a website through a web crawler;
step 2, extracting N article images from the article image set P, and extracting evaluation information of M users on the N article images from the corresponding article scoring data set Q, thereby obtaining a scoring matrix of the M users on the N article images
And the score of any user u on any item image i in the scoring matrix Y is recorded as Y
uiIf y is
ui1 denotes that the user u evaluated the item corresponding to the item image i, and y
ui0 indicates that the user u does not evaluate the item corresponding to the item image i;
step 3, carrying out normalization processing on the N article images to obtain an image set C;
step 4, respectively extracting the characteristics of the N images in the image set C by using a convolutional neural network CNN to obtain visual characteristic matrixes of the N images
Where T represents the dimension of the visual feature of each image, each column vector
Representing a visual feature vector corresponding to the image i;
and 5, establishing a prediction preference model by using the formula (1):
in the formula (1), the reaction mixture is,
representing user uPotential feature vectors, K representing potential feature dimensions,
representing a transformation matrix for transforming the visual feature vector f of the image i
iConverting into an embedded vector; ef
iA potential feature vector representing the image i,
representing predicted user u preferences for image i;
step 6, updating the prediction preference model by using an element-based alternating least square method;
step 6.1, obtaining a loss function L by using the formula (2):
in the formula (2), Y represents the set of item images evaluated in the evaluation matrix Y, and w
uiRepresenting the weight of any user u scoring any item image i in the scoring matrix Y,
after the k-th row vector in the transformation matrix E is removed, the preference of any user u to any article image i is shown, and
p
ukpotential feature vector p representing user u
uThe k-th dimension value of (1); c. C
iRepresenting the weights of the item images i that were not evaluated in the scoring matrix Y, lambda represents the parameters of the L2 regularization,
representing the kth row vector in the transformation matrix E;
step 6.2, defining a loop variable of α and initializing α to 0, defining a maximum loop number of α
maxRandomly initializing the parameters of the prediction preference model of the α th cycle by using the standard normal distribution
Wherein,
potential feature vector, E, representing user u in the α th loop
αA transformation matrix representing the α th cycle;
step 6.3, updating the potential feature vector p of the user u in the α th circulation by using the formula (3)
uK-th dimension value of
In the formula (3), the reaction mixture is,
denotes the k row vector, y, in the transformation matrix E at the α th cycle
uRepresenting a set of item images evaluated by user u in a scoring matrix Y;
step 6.4, adopting an element-by-element updating strategy, and updating the α th cycle transformation matrix E by using the formula (4)
αJ-dimension value of k-th row vector
In the formula (4), f
ijThe j-th dimension of the feature value of the item image i in the visual feature matrix F,
denotes the transformation matrix E at the α th cycle
αIn the k-th row vector, eliminating the potential characteristic value of the j-th dimension value of the article image i in the visual characteristic matrix F;
after the k-th row vector in the transformation matrix E is removed in the α th cycle, the preference of any user u on any article image i;
step 6.5, assigning α +1 to α, and judging α > α
maxWhether the optimal prediction preference model parameter is obtained or not is judged, if yes, the optimal prediction preference model parameter is obtained
Otherwise, returning to the step 6.3 for execution;
7, according to the optimal prediction preference model parameter
Predicting a preference set of the user u for all the item images by using the formula (5)
In the formula (5), the reaction mixture is,
denotes the α th
maxThe sub-cycle transforms the matrix,
denotes the α th
maxPotential feature vectors of user u in the secondary loop;
step 8, collecting the preference of the user u to all the article images
The preference values in the list are sorted in descending order, and the item images corresponding to the top-to preference values are selected and recommended to the user u.
Compared with the prior art, the invention has the beneficial effects that:
1. the image visual characteristics are merged into a matrix decomposition formula, the convolutional neural network CNN is used for extracting the image visual characteristics, a prediction preference model is established by using matrix decomposition in collaborative filtering, and the matrix decomposition is carried out by using an element-based alternating least square method, so that the recommendation precision of an image recommendation system is improved and personalized recommendation is realized.
2. The method utilizes the convolutional neural network CNN to extract the characteristics of the images in the image set, and uses the recommendation method based on the image visual characteristics, thereby effectively solving the problems that the traditional text-based recommendation method is difficult to completely describe all the characteristics of the commodity and can be influenced by the factors of the user.
3. The method utilizes matrix decomposition in collaborative filtering to establish a prediction preference model, and a collaborative filtering algorithm does not depend on the content characteristics of the recommendation information but depends on the behavior characteristics of the user more, so that the application range is wider.
4. The method updates the prediction preference model by using the element-based alternating least square method, and has the advantages of low time complexity, good convergence effect and the like compared with the traditional alternating least square method.
Detailed Description
In this embodiment, an image recommendation method fusing visual features and user scores includes: crawling a data set, extracting an article image and a scoring matrix of a user for the corresponding article image from the data set, performing image visual feature extraction on the acquired article image by using a convolutional neural network to obtain a visual feature matrix, establishing a prediction preference model, updating the prediction preference model by using an element-based alternating least square method, obtaining preference values of the user for all article images from a final prediction preference model, and completing image recommendation. The whole process is shown in figure 1, and concretely, the method comprises the following steps
Step 1, crawling an article image set P and a corresponding article scoring data set Q from a website through a web crawler;
step 1.1, initializing a URL list;
step 1.2, calling API to obtain a large amount of commodity information stored in an XML format;
step 1.3, analyzing to obtain an XML file, obtaining a seed list, and returning an analysis return result to be stored in a warehouse;
step 1.4, after the seed list of the commodity name is obtained, screening and duplicate removal operation is carried out on the obtained list;
and 1.5, if the URL list needs to be expanded, continuing to execute the step 1.2, otherwise, obtaining an item image set P and a corresponding item scoring data set Q.
Step 2, extracting N article images from the article image set P, and extracting evaluation information of M users on the N article images from the corresponding article scoring data set Q, thereby obtaining a scoring matrix of the M users on the N article images
And the score of any user u on any item image i in the scoring matrix Y is recorded as Y
uiIf y is
ui1 denotes that the user u evaluated the item corresponding to the item image i, and y
ui0 indicates that the user u does not evaluate the item corresponding to the item image i;
step 3, carrying out normalization processing on the N article images to obtain an image set C;
step 4, respectively extracting the characteristics of the N images in the image set C by using a convolutional neural network CNN to obtain a visual characteristic matrix of the N images
Where T represents the dimension of the visual feature of each image, each column vector
Representing a visual feature vector corresponding to the image i;
and 5, establishing a prediction preference model by using the formula (1):
formula (A), (B) and1) in (1),
representing potential feature vectors for user u, K representing potential feature dimensions,
representing a transformation matrix for transforming the visual feature vector f of the image i
iConverting into an embedded vector; ef
iA potential feature vector representing the image i,
representing predicted user u preferences for image i;
step 6, updating the prediction preference model by using an element-based alternating least square method;
step 6.1, obtaining a loss function L by using the formula (2):
in the formula (2), Y represents the set of item images evaluated in the evaluation matrix Y, and w
uiRepresenting the weight of any user u scoring any item image i in the scoring matrix Y,
after the k-th row vector in the transformation matrix E is removed, the preference of any user u to any article image i is shown, and
p
ukpotential feature vector p representing user u
uThe k-th dimension value of (1); c. C
iRepresenting the weights of the item images i that were not evaluated in the scoring matrix Y, lambda represents the parameters of the L2 regularization,
representing the kth row vector in the transformation matrix E;
wherein formula (2) is derived from formula (1) by substituting the following formula:
in the above equation, the first term of the loss function L
A loss function value representing a set of images of the evaluated object, a second term
A loss function value representing a set of images of the article that have not been evaluated, a third term
An L2 regularization term representing a prediction preference model;
step 6.2, defining a loop variable of α and initializing α to 0, defining a maximum loop number of α
maxRandomly initializing the parameters of the prediction preference model of the α th cycle by using the standard normal distribution
Wherein,
potential feature vector, E, representing user u in the α th loop
αA transformation matrix representing the α th cycle;
step 6.3, updating the potential feature vector p of the user u in the α th circulation by using the formula (3)
uK-th dimension value of
In the formula (3), the reaction mixture is,
indicating the α th cycle in the transformation matrix Ek line vectors, y
uRepresenting a set of item images evaluated by user u in a scoring matrix Y;
wherein formula (3) is represented by formula (2) to p
ukDerivation, making derivatives
Thus obtaining the product.
Step 6.4, adopting an element-by-element updating strategy, and updating the α th cycle transformation matrix E by using the formula (4)
αJ-dimension value of k-th row vector
In the formula (4), f
ijThe j-th dimension of the feature value of the item image i in the visual feature matrix F,
denotes the transformation matrix E at the α th cycle
αIn the k-th row vector, eliminating the potential characteristic value of the j-th dimension value of the article image i in the visual characteristic matrix F;
after the k-th row vector in the transformation matrix E is removed in the α th cycle, the preference of any user u on any article image i;
the derivation process of formula (4) is as follows:
the following formula is defined:
in the above formula, EktRepresenting the t-dimensional value of the k-th row of the E matrix, EkjDenotes the j-th dimension value, f, of the k-th row of the E matrixitRepresenting the t-dimensional value, F, of the ith row of the F matrixijRepresents the j-th dimension value of the i-th row of the F matrix. According to the above definition, the formula for rewriting L is:
to EkjTaking the derivative, we can get:
order to
Thus, formula (4) can be obtained.
Step 6.5, assigning α +1 to α, and judging α > α
maxWhether the optimal prediction preference model parameter is obtained or not is judged, if yes, the optimal prediction preference model parameter is obtained
Otherwise, returning to the step 6.3 for execution;
7, according to the optimal prediction preference model parameters
Predicting a preference set of the user u for all the item images by using the formula (5)
In the formula (5), the reaction mixture is,
denotes the α th
maxThe sub-cycle transforms the matrix,
denotes the α th
maxPotential feature vectors of user u in the secondary loop;
step 8, collecting the preference of the user u to all the article images
The preference values in the list are sorted in descending order, and the item images corresponding to the top-to preference values are selected and recommended to the user u.