Personalized recipe database retrieval method based on diet image features
By employing a personalized recipe database retrieval method based on user dietary image features, and utilizing the second-order difference operation of time-sliding sampling windows and click data streams, dynamic taste preference vectors and popularity trend acceleration values are generated. This solves the problem of difficulty in capturing changes in user tastes, achieves personalization and timeliness of recipe retrieval, and improves the accuracy of retrieval results and user stickiness.
Patent Information
- Application Number
- CN202511770948.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-28
- Publication Date
- 2026-01-09
AI Technical Summary
Existing big data analytics technologies struggle to capture the instantaneous shifts in user taste preferences caused by seasonal changes, mood, or physiological state in recipe searches, resulting in outdated user profiles. Furthermore, statistical methods based on existing data are prone to creating a Matthew effect, where older content occupies top display positions while emerging content fails to gain effective exposure.
By employing a personalized recipe database retrieval method based on user dietary image features, a time-sliding sampling window is used to identify oiliness and sweetness features. Combined with second-order difference operations on click data streams, dynamic flavor preference vectors and popularity trend acceleration values are generated. A comprehensive retrieval ranking weight is calculated to achieve personalized ranking and recommendation of recipes.
It achieves a keen perception of the user's current appetite, identifies the rate of increase or decrease in the popularity of recipes, improves the hit rate of search results and user stickiness, and provides an intelligent search experience with accuracy and novelty, solving the problem of information overload and difficulty in matching personalized needs.
Smart Images

Figure CN121301664A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of big data analytics, and in particular to a method for retrieving a personalized recipe database based on dietary image features. Background Technology
[0002] The field of big data analytics is used for the collection, storage, management, and in-depth processing of massive, multi-source, and heterogeneous data.
[0003] Current big data analytics technologies, when applied to recipe retrieval scenarios, largely rely on users' historically accumulated static behavioral tags or explicit keyword search records as the basis for recommendations. This data processing model struggles to capture the instantaneous shifts in user tastes caused by seasonal changes, mood, or physiological states. This results in user profiles that are outdated and fixed. In measuring content popularity, conventional technologies typically rank content based solely on absolute numerical indicators such as total clicks or cumulative viewing time. This statistical approach, based on existing data, easily creates a Matthew effect, where long-standing, outdated content occupies top display positions, while high-quality, emerging content fails to gain effective exposure due to insufficient initial data accumulation. Therefore, improvements are needed. Summary of the Invention
[0004] The purpose of this invention is to address the shortcomings of existing technologies by proposing a personalized recipe database retrieval method based on dietary image features.
[0005] To achieve the above objectives, the present invention adopts the following technical solution: a personalized recipe database retrieval method based on dietary image features, comprising the following steps:
[0006] Based on the user's food image log, a time-sliding sampling window is set, and the oiliness and sweetness feature values of each image within the window are identified to calculate and generate a dynamic taste preference vector.
[0007] Traverse the recipe database click data stream to perform daily segmented sampling on a single recipe, calculate the difference in click values between adjacent sampling segments, generate the daily average access rate value, and perform a second-order difference operation on the daily average access rate value of the current time period and the daily average access rate value of the previous time period to generate a popularity trend acceleration value.
[0008] Using the dynamic taste preference vector and the popularity trend acceleration value, the distance between the dynamic taste preference vector and each recipe vector in the recipe library feature matrix is calculated to generate a basic feature distance value. Based on the basic feature distance value and the popularity trend acceleration value, a comprehensive search ranking weight is calculated.
[0009] The recipe entries in the database are sorted according to the comprehensive retrieval ranking weight to generate an ordered recipe index sequence. A preset number of index items are extracted from the beginning of the ordered recipe index sequence, and the index items are mapped to the corresponding recipe details page text and image data to generate a personalized recipe search list.
[0010] Preferably, the step of obtaining the dynamic taste preference vector is as follows:
[0011] Based on the user's food image log, a time-sliding sampling window is set, and the images in the window are arranged in order of generation time. The color saturation distribution of each image is extracted, and the greasiness feature value and sweetness feature value are calculated in combination with the image brightness threshold range. The lag time difference value between the image generation time point and the current request time point is calculated to obtain the greasiness feature value, sweetness feature value and lag time difference value.
[0012] Based on the oiliness characteristic value, sweetness characteristic value and lag time difference value, calculate the time consistency weighted aggregation vector value;
[0013] Based on the time-consistent weighted aggregate vector value, each component is extracted and normalized with the maximum component value. The result is truncated to upper and lower limits while maintaining the original order of the oiliness and sweetness components to generate a dynamic taste preference vector.
[0014] Preferably, the step of obtaining the average daily access rate value is as follows:
[0015] Based on the click data stream of the recipe database, perform daily segmented sampling for a single recipe, read the timestamp and click count of each record, divide the continuous interval from midnight to midnight of the natural day, accumulate the click count within the interval and arrange them in chronological order, calculate the difference between adjacent intervals, and obtain the click value difference sequence of adjacent sampling segments.
[0016] Based on the click value difference sequence of adjacent sampling segments, the click value difference of adjacent sampling segments within the same natural day is summed. For natural days without records, zero difference is added while maintaining the time sequence. The sum of differences within a natural day is divided by the length of the natural day to generate the average daily access rate value.
[0017] Preferably, the step of obtaining the heat trend acceleration value is as follows:
[0018] Based on the average daily access rate value, the first difference is obtained by subtracting the average daily access rate value of the previous period from the current period's average daily access rate value. Then, the second difference is obtained by subtracting the first difference of the previous period from the first difference of the current period. The positive or negative sign of the second difference is used to map acceleration or deceleration markers and output the amplitude to generate the popularity trend acceleration value.
[0019] Preferably, the step of obtaining the basic feature distance value is as follows:
[0020] Based on the dynamic taste preference vector and each recipe vector in the recipe library feature matrix, each component value of each recipe vector is extracted and compared with the corresponding component value of the dynamic taste preference vector one by one. The square of the difference between the corresponding components is calculated, and the sum is taken to obtain the square root of the difference, thus obtaining the Euclidean distance value of each recipe, forming the basic feature distance value.
[0021] Preferably, the step of obtaining the comprehensive retrieval ranking weight is as follows:
[0022] Each of the basic feature distance values is incremented by one to eliminate the risk of zero denominator, resulting in a non-negative distance base sequence. The heat trend acceleration value is then mapped one-to-one with the non-negative distance base sequence while retaining the original recipe index, forming a personalized correction input sequence.
[0023] Calculate the comprehensive retrieval ranking weight based on the personalized modified input sequence.
[0024] Preferably, the step of obtaining the ordered recipe index sequence is as follows:
[0025] Based on the comprehensive retrieval ranking weight, the recipe index and comprehensive retrieval ranking weight of each recipe entry in the database are read one by one, and the recipes are arranged in descending order according to the comprehensive retrieval ranking weight. If the comprehensive retrieval ranking weights are the same, they are arranged in ascending order according to the recipe index, thus generating an ordered recipe index sequence.
[0026] Preferably, the step of obtaining the personalized recipe search list is as follows:
[0027] According to the ordered recipe index sequence, a preset number of index items are extracted sequentially starting from the beginning. If the length of the ordered recipe index sequence is insufficient, the existing length is used to extract the items and the actual extraction amount is recorded. The original order of the ordered recipe index sequence is kept unchanged, and a preset number of index items are generated.
[0028] Based on the preset number of index items, locate the text and image data of the recipe details page in the database according to the recipe index, verify that the text fields are not empty and verify that the image links are accessible, and combine the text and image data of the recipe details page into entries according to their original ordered positions to form a personalized recipe search list.
[0029] Compared with the prior art, the advantages and positive effects of the present invention are as follows:
[0030] This invention captures the dynamic taste trends of users over specific time periods by setting a time-sliding sampling window based on user dietary image logs and extracting oiliness and sweetness features. This overcomes the shortcomings of static labels in reflecting real-time physiological preferences. Combined with the generated dynamic taste preference vector, it effectively assigns higher weight to recent eating behaviors, achieving a keen perception of the user's current appetite. By traversing the click data stream, calculating the difference between adjacent sampling segments, and performing second-order difference operations to generate a popularity trend acceleration value, it breaks the lag in popularity caused by single cumulative clicks, identifies the rate of increase or decrease in recipe popularity, and thus uncovers relevant content with explosive potential. By integrating the dynamic taste preference vector and the popularity trend acceleration value, it achieves an organic balance between personalized matching and popular trends, ensuring that the output recipe search list not only highly matches the user's current subtle taste needs but also has timeliness and topicality, improving the hit rate of search results and user stickiness. It solves the problem of information overload and difficulty in matching personalized needs in the context of massive data, providing users with an intelligent search experience that combines accuracy and novelty. Attached Figure Description
[0031] Figure 1 This is a schematic diagram of the steps of the present invention. Detailed Implementation
[0032] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0033] Please see Figure 1 This invention provides a technical solution: a personalized recipe database retrieval method based on dietary image features, comprising the following steps:
[0034] Based on the user's food image log, a time-sliding sampling window is set, and the oiliness and sweetness feature values of each image within the window are identified to calculate and generate a dynamic taste preference vector.
[0035] Traverse the recipe database click data stream and perform daily segmented sampling for each recipe. Calculate the click value difference between adjacent sampling segments to generate the daily average access rate value. Perform a second-order difference operation on the daily average access rate value of the current time period and the daily average access rate value of the previous time period to generate the popularity trend acceleration value.
[0036] By referencing the dynamic taste preference vector and the popularity trend acceleration value, the distance between the dynamic taste preference vector and each recipe vector in the recipe library feature matrix is calculated to generate basic feature distance values. Based on the basic feature distance values and the popularity trend acceleration values, a comprehensive search ranking weight is calculated.
[0037] The recipe entries in the database are sorted according to the comprehensive search ranking weight to generate an ordered recipe index sequence. A preset number of index items are extracted from the beginning of the ordered recipe index sequence, and the index items are mapped to the corresponding text and image data of the recipe details page to generate a personalized recipe search list.
[0038] The steps to obtain a dynamic taste preference vector are as follows:
[0039] Based on the user's food image log, a time-sliding sampling window is set, and the images in the window are arranged in order of generation time. The color saturation distribution of each image is extracted, and the greasiness feature value and sweetness feature value are calculated in combination with the image brightness threshold range. The lag time difference value between the image generation time point and the current request time point is calculated to obtain the greasiness feature value, sweetness feature value and lag time difference value.
[0040] Based on the greasiness characteristic value, sweetness characteristic value, and lag time difference value, calculate the time consistency weighted aggregation vector value. The calculation formula is as follows:
[0041] ;
[0042] in, For the reason and Vectors composed of components in order of their composition For the first The oiliness feature value of the image. For the first Sweetness feature values of the images For the first The lag time difference value of the two images. The number of images within the time-sliding sampling window. It is the exponential decay constant. It is a natural constant. The flavor consistency factor is calculated using the following formula:
[0043] ;
[0044] in, This is the average vector of all dietary feature vectors within the window. Let be the sensitivity constant for taste consistency. For the first The Euclidean distance between each dietary feature vector and the average taste baseline For the taste consistency factor value, The time-consistency weighted aggregate vector values;
[0045] Based on the time-consistent weighted aggregate vector values, each component is extracted and normalized with the maximum component value. The results are truncated to upper and lower limits while maintaining the original order of the oiliness and sweetness components, thus generating a dynamic flavor preference vector.
[0046] Specifically, based on the user's dietary image log, the user ID is read and the associated cloud storage path is located. Metadata for all image files under that path is retrieved, and the generation timestamp attribute is extracted. The time length to be extrapolated backward from the current request time is set; for example, tracing back 336 hours (14 days) from the current time as a complete time sliding sampling window, the generation timestamp falls within this [0, All images within the 336] hour interval are marked as valid samples. The binary data of the valid samples is read and decoded into an RGB format matrix. The RGB matrix is converted into an HSV color space. The saturation (S) component and brightness (V) component are extracted from the pixels. A saturation threshold range for oiliness determination is set. For example, 2000 sample images labeled "light" and "oily" are selected. It is found that the average saturation value of oily samples is concentrated between 0.6 and 1.0, and the average brightness value is concentrated between 0.7 and 1.0. Therefore, the lower limit of the saturation threshold is set to 0.6, and the lower limit of the brightness threshold is set to 0.7. The proportion of pixels with an S value greater than 0.6 and a V value greater than 0.7 in a single image within the statistical window is used as the oiliness feature value of that image. Similarly, for the sweetness feature value, the common color spectrum of sweets is analyzed to determine the hue H in [330, 360] and [0, A sweetness region is defined as a color temperature range of 40 degrees and a brightness V greater than 0.6. The percentage of pixels that meet these color temperature and brightness conditions is calculated as the sweetness feature value. Simultaneously, the generation time of each image is recorded. With the current request time point Perform subtraction operation The time is then converted to hours. For example, if the current time is 12:00 on the 10th and the image was generated at 10:00 on the 10th, the result is 2.0 hours. If the result is negative, it is set to zero. This process is repeated for all images in the window to generate a data sequence containing greasiness feature values, sweetness feature values, and lag time difference values.
[0047] The formula, by introducing a dual weighting mechanism of time decay and content consistency, aggregates user taste preferences by... The parameters reduce the influence weight of outdated data, and also through Factor suppression of occasional dietary records that differ too much from overall dietary habits (such as occasional overeating or eating unusual foods) from interfering with preference profiles, thereby constructing a taste feature model that is more consistent with the user's long-term stability and timeliness.
[0048] The steps for obtaining the parameters are as follows: count the total number of valid food images after screening within a set time sliding sampling window (e.g., the aforementioned 14 days). This value is obtained directly by traversing the image list using a counter and is used to determine the loop boundary of the summation operation. For example, if 3 valid images are collected.
[0049] The steps for obtaining the parameters are as follows: the first parameter extracted from the aforementioned steps... Oiliness feature value of the image Sweetness characteristic value Combining and All values are calculated based on pixel ratios and are dimensionless ratios ranging from 0 to 1. For example, in the first image, the oiliness level is 0.8 and the sweetness level is 0.2. ;
[0050] The steps to obtain the parameters are as follows: calculate the timestamp of the current request and the timestamp of the request. The difference in timestamps generated from the images is uniformly converted to hours. (This is used to measure the freshness of information, for example, the first image is 2 hours old);
[0051] The steps for obtaining the parameters are as follows: Based on the Ebbinghaus forgetting curve and the experimental design of dietary preference memory, 100 volunteers were selected to record their diets for 30 days and follow up on their preferences. A curve showing the decrease in preference correlation over time was fitted, and the half-life was set to 72 hours (3 days), meaning that the weight of records before 72 hours should be reduced to 50%. According to the formula... (72 here refers to hours), calculated as follows The unit is the reciprocal of the hour ( ), to ensure The product is dimensionless; in this example, it takes the value 0.01. This value is used to control the rate of weight decay over time.
[0052] The parameter acquisition steps are as follows: This parameter, a dimensionless constant, is used to control the penalty for samples with inconsistent tastes. It is obtained by analyzing the variance of the dietary feature vector distribution of a large amount of historical user data. The Euclidean squared distance distribution between the feature vector of each user's meal and its mean vector is calculated. A squared distance threshold of 0.04 (i.e., a distance of 0.2) covering 90% of the normal fluctuation range is selected. The expected consistency factor is determined at this distance. Keep it above 0.6, then substitute it into the formula. Solving for In conjunction with experimental optimization, to enhance the suppression of outliers (such as sudden group meals), the following settings were implemented: This indicates that as the difference distance increases, the reference weight of the sample decreases sharply;
[0053] The steps to obtain the parameters are as follows: for all windows within the window... Feature vectors of an image Perform an average calculation, that is, all Add the corresponding components and divide by The result is still a dimensionless eigenvector, which is used to establish the baseline of basic taste in the current period as a benchmark for measuring consistency.
[0054] Calculations based on parameters:
[0055] The settings window contains Image
[0056] Image 1 (Recent greasy meal): Lag time ;
[0057] Image 2 (Mid-term greasy meal): Lag time ;
[0058] Image 3 (Recent light meals, outlier): Lag time ;
[0059] Parameter settings: , ;
[0060] The first step is to calculate the average vector. :
[0061] Average amount of oil: ;
[0062] Average sweetness of the portion: ;
[0063] Right now ;
[0064] The second step is to calculate the squared Euclidean distance between each image. (Dimensionless) and consistency factor :
[0065] For image 1:
[0066] Square distance ;
[0067] ;
[0068] For image 2:
[0069] Square distance ;
[0070] ;
[0071] For image 3 (which shows significant differences):
[0072] Square distance ;
[0073] (The consistency factor is extremely low, and it is judged as an outlier habit).
[0074] The third step is to calculate the time decay factor. (Dimensionless):
[0075] ;
[0076] ;
[0077] ;
[0078] The fourth step is to calculate the overall weight. :
[0079] ;
[0080] ;
[0081] ;
[0082] Total weights ;
[0083] Fifth step, calculate the weighted aggregation vector. ;
[0084] The results indicate that, through double-weighted calculation, although image 3 is recent data, its influence on the final preference is significantly weakened (weight only 0.038) due to its large difference from the overall preference (outlier). In contrast, image 2, although older, retains a higher contribution because it conforms to a consistency pattern, resulting in a higher final vector. It accurately reflects the user's long-term stable dietary habits that prefer oily and low-sweet foods, rather than being affected by a single abnormal diet.
[0085] Based on the calculated time-consistent weighted aggregate vector value, all component values in the vector are read. For example, in the previous step, an aggregate vector containing oiliness and sweetness components is obtained. The vector is traversed to identify the maximum value. For example, in the vector [0.706, 0.289], the maximum value is identified as 0.706. This maximum value is used to perform a division operation on each component in the vector to complete the normalization process. The calculation process is to divide 0.706 by 0.706 to get 1.0, and divide 0.289 by 0.706 to get approximately 0.409, thereby mapping the feature intensity to a relative intensity space with a peak value of 1. Then, the minimum response threshold of the effective feature is set. For example, by consulting relevant research literature on human taste perception threshold and combining the experience of sparsity processing in recommendation systems, the minimum effective preference threshold is set to 0. 1. The normalized vector components are compared one by one with the threshold. If the component value is less than 0.1, it is forcibly corrected to 0.1 to prevent the loss of feature dimensions or the risk of division by zero during subsequent distance calculation due to the value being too small. If the component value is greater than or equal to 0.1, the original value is retained. For example, 0.409 is retained unchanged. At the same time, the order of the physical meanings of each component in the vector is strictly maintained. That is, the first digit still corresponds to the oiliness and the second digit still corresponds to the sweetness. Finally, the processed numerical sequence is encapsulated into a one-dimensional array structure to generate a dynamic taste preference vector.
[0086] The steps to obtain the average daily access rate value are as follows:
[0087] Based on the click data stream of the recipe database, perform daily segmented sampling for a single recipe, read the timestamp and click count of each record, divide the continuous interval from midnight to midnight of the natural day, accumulate the click count within the interval and arrange them in chronological order, calculate the difference between adjacent intervals, and obtain the click value difference sequence of adjacent sampling segments.
[0088] Based on the click value difference sequence of adjacent sampling segments, the click value difference of adjacent sampling segments within the same natural day is summed. For natural days without records, zero difference is added while maintaining the time sequence. The sum of differences within a natural day is divided by the length of the natural day to generate the average daily access rate value.
[0089] Specifically, based on the click data stream from the recipe database, daily segmented sampling is performed for each recipe. Each line of click log stored in the data stream is read, and the Unix timestamp data and the recipe's unique identifier carried in the log header fields are parsed. The timestamp is mapped to a YYYY-MM-DD format date string using a conversion function to establish the boundary of the natural day. The sampling time granularity is set to 24 hours, meaning a complete sampling loop is from 00:00:00 to 23:59:59. All parsed log records are traversed, and a hash mapping table is built with date strings as keys and click counts as values. Whenever a click record belonging to a specific date is read, the value corresponding to that date is incremented. After all logs have been traversed, all key-value pairs in the mapping table are extracted and sorted in ascending order according to the ASCII code of the date strings, forming a continuous time series list. Then, the difference calculation logic between adjacent intervals is defined. The sorted time series list is traversed, and starting from the second time node, the click count value of the current node is read. Click count value compared to the previous time point Perform subtraction operation ,in This represents the change in clicks between two adjacent days. If there is a date gap in the list, it is necessary to first determine whether the previous date and the current date are consecutive based on the calendar logic. For consecutive dates, the difference is calculated directly. For non-consecutive dates, the difference calculation is not performed or it is completed in a later step. This process is repeated until the end of the list. All the calculated differences are stored in a new array structure in chronological order to obtain the click value difference sequence of adjacent sampling segments.
[0090] Based on the click value difference sequence of adjacent sampling segments, an initial result container for storing the daily average rate is created. The start and end dates recorded in the sequence are read, and a complete calendar index containing all natural days within the range is constructed. This complete calendar index is traversed, and each natural day is checked to see if it exists in the original difference sequence. If the current natural day has a corresponding difference record in the original sequence, the difference value is directly extracted. If the current natural day is missing from the original sequence, it means there is no access fluctuation record for that day. In this way, a difference item with a value of 0 is created and filled into the corresponding position to eliminate time gaps in the data stream and ensure the continuity of the time axis. After completion, the differences of all sampling segments contained in each natural day (if the granularity of the previous steps is finer than one day) are summed to obtain the total change for that natural day. Then, the time normalization benchmark for the daily average access rate is determined, and the natural day time length parameter is set. The setting of this parameter needs to be based on the time accuracy requirements of the business scenario. For example, under a normal daily update frequency, it should be set as follows: (Unit: hours). For higher precision, set it to 1440 (unit: minutes). Here, hours are used as the unit. The sum of the differences for each natural day The division operation is performed using the following formula: For example, if the total difference on a certain day is 120 times and the time length is 24 hours, then the calculated access rate value for that day is 5.0. This value reflects the average rate of change of popularity per hour. The calculated rate values for each day are pushed into the result queue in chronological order to generate the average daily access rate value.
[0091] The steps to obtain the heat trend acceleration value are as follows:
[0092] Based on the average daily access rate, the first difference is obtained by subtracting the average daily access rate of the previous period from the current period's average daily access rate. Then, the second difference is obtained by subtracting the first difference of the previous period from the first difference of the current period. The positive or negative sign of the second difference is used to map acceleration or deceleration markers and output the amplitude to generate the popularity trend acceleration value.
[0093] Specifically, based on the average daily access rate, a second-order difference operation model is constructed to capture the acceleration characteristics of popularity. First, a sliding calculation window is established, with the window length covering three consecutive time points, namely the current time period. Previous period and the previous period Read the corresponding average daily access rate value , and The first step is to perform a difference operation to calculate the trend change during the current time period. and the trend change in the previous period. The second step involves performing a second-order difference operation based on these two changes, calculated using the following formula: ,Should This is the raw value of the heat trend acceleration. To map this value to acceleration or deceleration indicators with business implications, an acceleration threshold needs to be set. The threshold The setup steps are as follows: Collect heat acceleration data for a total of 90 days within the first quarter, and calculate the standard deviation of this data set. For example, the standard deviation is obtained through calculation. ,set up It is 0.2 times the standard deviation, that is This setting is designed to filter out minute random fluctuations, and the judgment logic is as follows: if If so, it is marked as "accelerated upward" or "reverse recovery of decelerated downward" (depending on the original direction). If so, it will be marked as "deceleration" or "accelerated descent". If it is, then mark it as "uniform speed" and retain it. The specific absolute value is used as the amplitude output. The obtained mark is combined with the calculated amplitude value to generate the heat trend acceleration value.
[0094] The steps for obtaining the basic feature distance values are as follows:
[0095] Based on the dynamic taste preference vector and the recipe vectors in the feature matrix of the recipe library, each component value of each recipe vector is extracted and compared with the corresponding component value of the dynamic taste preference vector one by one. The square of the difference between the corresponding components is calculated, and the sum is taken to obtain the square root of the difference. This yields the Euclidean distance value of each recipe, forming the basic feature distance value.
[0096] Specifically, based on the dynamic taste preference vector and the recipe vectors in the recipe library feature matrix, the recipe library feature matrix, pre-built in an in-memory database, is invoked. The row dimensions of this matrix correspond to the hundreds of thousands of existing recipe entries in the database, and the column dimensions are strictly aligned with the two feature dimensions of oiliness and sweetness in the user profile, thus forming a... The numerical plane, where each value has been normalized to between 0 and 1, is a dimensionless relative intensity value. Each row of data in the matrix is traversed, and its feature vector for a single recipe is extracted. Simultaneously, the dynamic taste preference vector generated in the previous step, containing the user's real-time taste preferences, is read to ensure consistency in numerical type and dimension between the two sets of vectors. The vector distance calculation logic is then initiated. For each recipe vector, the difference between its oiliness component value and the oiliness component value in the user preference vector, and the difference between its sweetness component value and the sweetness component value in the user preference vector, are calculated. These differences are then squared. The steps aim to eliminate positive and negative biases and nonlinearly amplify large feature differences. Then, the results of the two squares are summed to obtain the sum of squared distances between the recipe and the user's preference in the feature space. Finally, the square root function in the math library is called to perform a square root operation on the sum of squares. The result of this operation directly quantifies the geometric similarity between the recipe flavor and the user's current desired flavor. That is, the closer the value is to zero, the more similar the flavor is. Since the original components are all dimensionless ratios, the calculated distance values are also dimensionless values. Each of the calculated floating-point distance values is stored in a temporary result array in the order of the recipe index to form the basic feature distance values.
[0097] The steps for obtaining the overall search ranking weights are as follows:
[0098] To eliminate the risk of zero denominator, each basic feature distance value is incremented by one to obtain a non-negative distance base sequence. The heat trend acceleration value is mapped one-to-one with the non-negative distance base sequence while retaining the original recipe index, thus forming a personalized correction input sequence.
[0099] Based on the personalized modified input sequence, the comprehensive retrieval ranking weight is calculated using the following formula:
[0100] ;
[0101] in, For the first The overall search ranking weight of each recipe. For the first The personalized effective trend value for each recipe is used to represent the actual impact of flavor distance on popularity trends. is the acceleration value of the heat trend, and is the global trend strength parameter. is the trend effect attenuation coefficient, and is a positive scalar constant used to control the rate at which the influence of taste distance weakens on the heat trend. For the first The non-negative distance cardinality for each recipe is the distance index obtained by adding one to the base feature distance value. It is a natural constant.
[0102] Specifically, each basic feature distance value is incremented by one to eliminate the risk of zero denominator. The array storing basic feature distance values generated in the previous step is traversed, and each floating-point distance value is read and incremented by one. A non-negative metric base starting from 1 is established, and the processed numerical sequence is defined as the non-negative distance base sequence. Next, the popularity trend acceleration value corresponding to each recipe ID is read. This acceleration value reflects the second-order rate of change of the number of visits to the recipe within the current time window, that is, the degree of rise and fall in popularity. Its original unit is "clicks / day squared". To meet the needs of subsequent calculations, a data alignment operation is performed in this step. Using the unique index ID of the recipe as the association key, the non-negative distance base of each recipe is bound to its corresponding original popularity trend acceleration value in a tuple. A structured data item containing "recipe ID, non-negative distance base, and original acceleration value" is constructed, or a parallel index mapping table is constructed to ensure that the flavor distance data and popularity trend data of the same recipe can be accurately called during subsequent weighted calculations. Finally, all aligned data items are assembled into an ordered list to form a personalized correction input sequence.
[0103] The comprehensive search ranking weight calculation formula incorporates an exponential decay mechanism to dynamically adjust the recommendation weight of popular recipes for users with different taste preferences. As the independent variable of the decay index, it makes the taste differences large (i.e. Larger recipes, their popularity bonus It is quickly suppressed, thus ensuring that the recommendation results can capture popular trends without deviating from the user's personalized dietary needs;
[0104] The parameter acquisition steps are as follows: based on the original heat trend acceleration value generated in the previous steps (unit: times / After dimensionless normalization, the values can be substituted into the exponential calculation. The specific process is as follows: statistically analyze the absolute value distribution of the acceleration values of all recipes in the recipe database over the past 30 days, and take the 99th percentile value as the maximum baseline value. (e.g., 50 times / ) Read the raw acceleration value of the current recipe. The transformation is performed using either a linear mapping or the hyperbolic tangent function; here, a linear truncation mapping is used, and the calculation formula is as follows: ,in This is the scaling factor, typically set to 2.0, which limits the results to a specific value. Within the interval, the dimensionless trend strength parameter is obtained. For example, the second difference of a certain recipe is 10 times. , ,but This parameter is used to measure the relative intensity of a heat burst;
[0105] The parameter was obtained through A / B testing analysis of historical recommendation logs. It is used to quantify the rate at which users' tolerance for "popular but not to their liking" foods decays. This parameter is a dimensionless constant. Specifically, a group of users was selected and shown different distances... But heat intensity Same recipe, record click rate Fitted curve The result was obtained through least squares regression. Values, for example, in a test involving 5,000 users, revealed that when the taste deviated from the baseline... When the version was upgraded from 1.0 to 2.0, users' willingness to click on popular recipes decreased by approximately 60%, meaning... Solving for To enhance the personalized screening capabilities, set This means that when the distance increases by 1 unit, the heat influence decreases back to its original value. ;
[0106] The steps for obtaining parameters are as follows: read the first parameter from the personalized correction input sequence. The "non-negative distance cardinality" of each recipe is obtained by adding one to the basic Euclidean distance (dimensionless), and its value ranges from 1 to 1. For example, if the Euclidean distance between a recipe and user preference is 0.4, then... ;
[0107] Calculations based on parameters:
[0108] Set the current processing recipe The parameters are as follows:
[0109] The original acceleration was 20 times / benchmark value scaling factor Then the dimensionless thermal trend acceleration value ;
[0110] If the distance between a user and the recipe's base feature is 0.4, then the cardinality of the non-negative distance is: ;
[0111] The trend effect decay coefficient is set to ;
[0112] The first step is to calculate the personalized effective trend value. (Dimensionless):
[0113] The index of the index term is ;
[0114] Calculate the natural index ;
[0115] calculate ;
[0116] (This indicates that due to the difference in taste, the original heat contribution of 0.8 was reduced to about 0.2)
[0117] The second step is to calculate the overall search ranking weight. (Dimensionless):
[0118] The numerator is ;
[0119] The denominator term is ;
[0120] calculate ;
[0121] Comparative example: If another recipe The temperature is relatively low, and the original acceleration is 5 times / ,but However, their tastes are a perfect match (distance 0), that is... ;
[0122] but ;
[0123] ;
[0124] The result indicates that, despite the recipe The heat (0.8) is much higher than the recipe. (0.2), but due to the recipe The discrepancy between the content and user preferences (distance 0.4) reduces its popularity and influence. Significant decay, and the denominator The weighting was further reduced, and the final comprehensive score was calculated using the formula. (0.8701) lower than a perfectly matching recipe (1.0764), thus prioritizing the recommendation of content whose tastes better match user preferences, reflecting the personalized sorting strategy of "taste first, popularity second".
[0125] The steps to obtain an ordered recipe index sequence are as follows:
[0126] Based on the comprehensive search ranking weight, the recipe index and comprehensive search ranking weight of each recipe entry in the database are read one by one, and the recipes are sorted in descending order according to the comprehensive search ranking weight. If the comprehensive search ranking weights are the same, they are sorted in ascending order according to the recipe index, thus generating an ordered recipe index sequence.
[0127] Specifically, based on the comprehensive retrieval ranking weight, a dedicated buffer is allocated in memory to store the intermediate data structure to be sorted. This data structure is designed as a key-value pair object containing a unique identifier for the recipe and a floating-point weight. All recipe entries participating in the calculation are traversed in the database, and the ID of each recipe and its corresponding comprehensive retrieval ranking weight are recorded. The data is loaded into the buffer. After loading, a composite comparator logic is defined to perform the sorting operation. The first priority rule of this comparator is to compare the size of the weights. A precision tolerance range for floating-point comparison is set, for example, to 0.000001. When the absolute value of the difference between two weights is greater than this tolerance and the former is greater than the latter, the former is ranked first. If the absolute value of the difference between two weights is less than the tolerance, they are considered to have the same weight. At this time, the second priority rule is triggered, which is to read the unique identifier of the recipe and compare it with an integer. The recipe with the smaller identifier value is ranked first. This rule is used to ensure the determinism and reproducibility of the sorting result when the weights are the same. An efficient sorting algorithm, such as quicksort or mergesort, is called to rearrange all objects in the buffer according to the above composite rule. During the sorting process, the physical position of each recipe in the sequence is adjusted by pointer swapping or data movement until the data in the entire buffer meets the characteristics of descending order. After sorting, the sorted list of ordered objects is traversed, and only the unique identifier field of the recipe is extracted. The recipes are stored in a new linear array or list container in order to generate an ordered recipe index sequence.
[0128] The steps to obtain a personalized recipe search list are as follows:
[0129] Based on the ordered recipe index sequence, a preset number of index items are extracted sequentially starting from the beginning. If the length of the ordered recipe index sequence is insufficient, the existing length is used to extract the items and the actual extraction amount is recorded. The original order of the ordered recipe index sequence is maintained, and a preset number of index items are generated.
[0130] Based on the preset number of index items, locate the text and image data of the recipe details page in the database according to the recipe index, verify that the text fields are not empty and verify that the image links are accessible, and combine the text and image data of the recipe details page into entries according to their original ordered positions to form a personalized recipe search list.
[0131] Specifically, based on the ordered recipe index sequence, the metadata of the sequence is read to obtain the total number of elements it currently contains, and a preset threshold is set to control the length of the output list. The threshold The settings need to take into account the screen display density of mobile devices and the packet size limitations of network transmission. For example, by analyzing the average dwell time and scrolling intention of users during the first screen loading, combined with the average byte size of a single recipe data item of about 5KB, in order to control the first screen loading latency to within 200 milliseconds, while covering the display area of about 3 times the screen height of mainstream mobile phone screens, the optimal number of items loaded at one time was calculated to be 20. Therefore, a preset number was set. The total length of the sequence With preset quantity Perform a numerical comparison, if Greater than or equal to Then, a truncation operation is performed, initializing a capacity of... The new array is created by copying elements one by one from the beginning of the original sequence, starting at index 0, until the index reaches the specified value. Until then, if Less than If the truncation is not performed, all sequences in the original sequence will be directly removed. Each element is completely copied to a new array, and the actual number of copies is recorded for subsequent log statistics. Throughout the entire truncation or copying process, the relative positions of the elements in the original sequence are strictly maintained to ensure that high-priority recipes remain at the front of the list. Finally, the processed array containing a specific number of recipe IDs is locked as the output object, and a preset number of index items are generated.
[0132] Based on a preset number of index items, each recipe ID in the index list is traversed. A precise search is performed in the recipe content table using a database query interface to locate the corresponding record row. The details page text fields of that record row are read, including the dish name, ingredient list, and preparation steps description. Simultaneously, the image data field is read, typically the URL link address storing the image. A strict data integrity verification process is executed. For the text fields, a minimum threshold for valid text length is set. This threshold is based on statistical analysis of a historical high-quality recipe database. Statistics show that the average number of characters in the step description of valid recipes is around 150 characters, with a standard deviation of 30 characters. To exclude blank or extremely simplistic test data, a minimum character threshold of 15 characters is set, i.e., the character length of the read text content. If the length is less than 15 characters, it is marked as invalid. For the image data, a link reachability check is performed, initiating an HTTP request. A HEAD request is sent to the image server, with a response timeout threshold set to 500 milliseconds. This threshold is based on the average loading time of 99% of image resources in the current network environment. If the server returns a status code other than 200 or the request times out, the image is marked as unavailable. After all validations are completed, only records with acceptable text lengths and valid image links are retained. The text content and image addresses in these records are then repackaged into standardized data entry objects according to their original order in the index sequence. All the packaged objects are then sequentially filled into the final result container to form a personalized recipe search list.
[0133] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention in any other way. Any person skilled in the art may make changes or modifications to the above-disclosed technical content to create equivalent embodiments that can be applied to other fields. However, any simple modifications, equivalent changes, and modifications made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the protection scope of the present invention.
Claims
1. A personalized recipe database retrieval method based on dietary image features, characterized in that, Includes the following steps: Based on the user's food image log, a time-sliding sampling window is set, and the oiliness and sweetness feature values of each image within the window are identified to calculate and generate a dynamic taste preference vector. Traverse the recipe database click data stream to perform daily segmented sampling on a single recipe, calculate the difference in click values between adjacent sampling segments, generate the daily average access rate value, and perform a second-order difference operation on the daily average access rate value of the current time period and the daily average access rate value of the previous time period to generate a popularity trend acceleration value. Using the dynamic taste preference vector and the popularity trend acceleration value, the distance between the dynamic taste preference vector and each recipe vector in the recipe library feature matrix is calculated to generate a basic feature distance value. Based on the basic feature distance value and the popularity trend acceleration value, a comprehensive search ranking weight is calculated. The recipe entries in the database are sorted according to the comprehensive retrieval ranking weight to generate an ordered recipe index sequence. A preset number of index items are extracted from the beginning of the ordered recipe index sequence, and the index items are mapped to the corresponding recipe details page text and image data to generate a personalized recipe search list.
2. The personalized recipe database retrieval method based on dietary image features according to claim 1, characterized in that, The steps for obtaining the dynamic taste preference vector are as follows: Based on the user's food image log, a time-sliding sampling window is set, and the images in the window are arranged in order of generation time. The color saturation distribution of each image is extracted, and the greasiness feature value and sweetness feature value are calculated in combination with the image brightness threshold range. The lag time difference value between the image generation time point and the current request time point is calculated to obtain the greasiness feature value, sweetness feature value and lag time difference value. Based on the oiliness characteristic value, sweetness characteristic value and lag time difference value, calculate the time consistency weighted aggregation vector value; Based on the time-consistent weighted aggregate vector value, each component is extracted and normalized with the maximum component value. The result is truncated to upper and lower limits while maintaining the original order of the oiliness and sweetness components to generate a dynamic taste preference vector.
3. The personalized recipe database retrieval method based on dietary image features according to claim 1, characterized in that, The steps for obtaining the average daily access rate value are as follows: Based on the click data stream of the recipe database, perform daily segmented sampling for a single recipe, read the timestamp and click count of each record, divide the continuous interval from midnight to midnight of the natural day, accumulate the click count within the interval and arrange them in chronological order, calculate the difference between adjacent intervals, and obtain the click value difference sequence of adjacent sampling segments. Based on the click value difference sequence of adjacent sampling segments, the click value difference of adjacent sampling segments within the same natural day is summed. For natural days without records, zero difference is added while maintaining the time sequence. The sum of differences within a natural day is divided by the length of the natural day to generate the average daily access rate value.
4. The personalized recipe database retrieval method based on dietary image features according to claim 1, characterized in that, The steps for obtaining the heat trend acceleration value are as follows: Based on the average daily access rate value, the first difference is obtained by subtracting the average daily access rate value of the previous period from the current period's average daily access rate value. Then, the second difference is obtained by subtracting the first difference of the previous period from the first difference of the current period. The positive or negative sign of the second difference is used to map acceleration or deceleration markers and output the amplitude to generate the popularity trend acceleration value.
5. The personalized recipe database retrieval method based on dietary image features according to claim 1, characterized in that, The steps for obtaining the basic feature distance value are as follows: Based on the dynamic taste preference vector and each recipe vector in the recipe library feature matrix, each component value of each recipe vector is extracted and compared with the corresponding component value of the dynamic taste preference vector one by one. The square of the difference between the corresponding components is calculated, and the sum is taken to obtain the square root of the difference, thus obtaining the Euclidean distance value of each recipe, forming the basic feature distance value.
6. The personalized recipe database retrieval method based on dietary image features according to claim 1, characterized in that, The steps for obtaining the comprehensive retrieval ranking weight are as follows: Each of the basic feature distance values is incremented by one to eliminate the risk of zero denominator, resulting in a non-negative distance base sequence. The heat trend acceleration value is then mapped one-to-one with the non-negative distance base sequence while retaining the original recipe index, forming a personalized correction input sequence. Calculate the comprehensive retrieval ranking weight based on the personalized modified input sequence.
7. The personalized recipe database retrieval method based on dietary image features according to claim 1, characterized in that, The steps for obtaining the ordered recipe index sequence are as follows: Based on the comprehensive retrieval ranking weight, the recipe index and comprehensive retrieval ranking weight of each recipe entry in the database are read one by one, and the recipes are arranged in descending order according to the comprehensive retrieval ranking weight. If the comprehensive retrieval ranking weights are the same, they are arranged in ascending order according to the recipe index, thus generating an ordered recipe index sequence.
8. The personalized recipe database retrieval method based on dietary image features according to claim 1, characterized in that, The steps for obtaining the personalized recipe search list are as follows: According to the ordered recipe index sequence, a preset number of index items are extracted sequentially starting from the beginning. If the length of the ordered recipe index sequence is insufficient, the existing length is used to extract the items and the actual extraction amount is recorded. The original order of the ordered recipe index sequence is kept unchanged, and a preset number of index items are generated. Based on the preset number of index items, locate the text and image data of the recipe details page in the database according to the recipe index, verify that the text fields are not empty and verify that the image links are accessible, and combine the text and image data of the recipe details page into entries according to their original ordered positions to form a personalized recipe search list.