Keywords

1 Introduction

Cooking recipes have become available by various means. However, despite the huge number of recipes, there are not always dishes that perfectly match each individual’s preference. Also, even if they exist, it is not always easy to find them. It is also clear that too many choices can cause problems [6]. For example, it can be a cause of inhibition of motivation to the selection, a decrease of satisfaction to the selected object, and so on. Likewise, because of huge combination of cocktails made from multiple liquors, beverages, etc., there are not always recipes that can satisfy any request. In order to reliably provide recipes that can meet his or her needs, it is necessary to newly produce recipes that meet requirements as needed. In this study, we focus on cocktails where recipes are simpler than general cuisine and devise a method to generate recipes based on requests. Since combinations of ingredients are complicated, we make a support system by deep learning. A support system is necessary for people who do not have much knowledge to easily devise their favorite recipe.

2 Dataset

We used 3110 recipes obtained from the website [5] that posted cocktail recipes. The variables contain the quantities of 645 different ingredients (treated as different ingredients if units of quantity are different) (Table 1).

Table 1. An example of dataset.

3 Method

First of all, our system takes as inputs a collection of required ingredients, a collection of forbidden ingredients and whether “surprise” is necessary. Required ingredients are always used in recipes to be output finally, while forbidden ingredients are never used. “surprise” is like an indicator of a level of a concept close to the term serendipity used in the field of marketing. Regarding this part, we almost follow the work of Grace et al. [1, 2]. However, there is only one point difference, which is that the input on “surprise” is not at that level and whether it is necessary or not.

On the other hand, our system consists of two processes: the generation of sets of ingredients and the generation of ingredient quantities (Fig. 1).

Fig. 1.
figure 1

Image of the proposed system.

3.1 The Generation of Sets of Ingredients

In the generation of sets of ingredients, two deep learning models are used. One is a multilayer perceptron [3]. It takes as input a vector representation of a part of ingredients contained in a recipe and outputs levels of co-occurrence relation that each ingredient is included in the recipe. Another is a variational autoencoder [4] that encodes a vector with information such as which ingredient is included in a recipe into a vector of multidimensional normal distribution. First, the system receives a request in the form of a collection of required ingredients, a set of forbidden ingredients, and whether “surprise” is necessary. Next, using the multilayer perceptron, excluding forbidden ingredients, add an ingredient with the highest levels of co-occurrence relation of entering recipe or “surprise” estimate to the required ingredient set. The definition of “surprise” here [1, 2] is as follows. When a set of other ingredients is given in multilayer perceptron and it estimates levels of co-occurrence relation \(P_{\theta }\) of entering recipe of different ingredients, s expressed by the following equation is called “surprise”.

$$\begin{aligned} s(f|c) = - \log _2 \frac{P_{\theta }(f)}{P_{\theta }(f|c)} \end{aligned}$$
(1)

where f is an ingredient and c is context of set of ingredients. Considering computational ease of use, the length of the combination at training is up to 3.

For a recipe to which a selected ingredient is added for an required ingredient set, outlier detection with the Mahalanobis distance and the chi-squared distribution [4] is performed on the vector coded by the variational autoencoder. If there is no outlier, a process such as addition of ingredient and processing of outlier detection is repeated. If it is judged as outlier or the number of ingredients exceeds the maximum value of the data set, this algorithm ends. We output a list including all the collections of ingredients from the required ingredient set to the final set of the repetition (however, those whose ingredient set size is 1 or 0 are removed from the candidates).

3.2 The Generation of Ingredient Quantities

The generation of ingredient quantities receives as input a list of ingredients outputted in the process of the generation of sets of ingredients. The following processing is performed on each set of ingredients. First, using the regression by multilayer perceptron [3], the system estimates amounts of each ingredient contained in the set of ingredients. Information on the estimate of quantity is added to the set of ingredients. A set of all ingredient sets subjected to the above processing is regarded as a final output result.

Loss Function in Learning of Multilayer Perceptron (MLP). When existing functions such as Mean Squared Error, Mean Absolute Error and MAPE are used as the loss function in learning of Multilayer Perceptron (MLP) for ingredient quantity generation, a problem that extremely small amounts (value close to 0) is output since the train data is sparse (amounts of ingredients that are not used is 0) arises. Therefore, in this study, we have defined the loss function \(L_N\) uniquely (2).

$$\begin{aligned} L_N = \frac{1}{NP}\sum ^{N}_{n=1}\sum ^{P}_{p=1}{\frac{\mathrm{sign}(y^{(n)}_{p})|y^{(n)}_{p}-\hat{y}^{(n)}_p|}{\max (y^{(n)}_{p}, \epsilon )}}\\ 0 \le y^{n}_{p} \le 1, 0 \le \hat{y}^{(n)}_p \le 1, \epsilon > 0 \nonumber \end{aligned}$$
(2)

where, N is the number of data, P is the dimension of data. \(\epsilon \) is a tiny positive number to prevent division by 0, such as \(10^{-7}\) is used. In MAPE, the loss for each sample is multiplied by the sign of the true value \(y^{n}_{p}\). When \(y^{n}_{p}\) is 0, the loss is fixed to 0.

Evaluation Function in Validating of Multilayer Perceptron (MLP). If the proposed loss function 2 is used as an evaluation function in validating, there is a problem that it is easier to output a better evaluation value (lower value) as the number of ingredients used is smaller, that is, data with a lot of \(y^{(n)}_{p}\) where \(\mathrm{sign}(y^{(n)}_{p})\) takes zero. Therefore, we also uniquely defined the evaluation function (3).

$$\begin{aligned} L_N = \frac{1}{\sum ^{N}_{n=1}\sum ^{P}_{p=1}{\mathrm{sign}(y^{(n)}_{p})}}\sum ^{N}_{n=1}\sum ^{P}_{p=1}{\frac{\mathrm{sign}(y^{(n)}_{p})|y^{(n)}_{p}-\hat{y}^{(n)}_p|}{\max (y^{(n)}_{p}, \epsilon )}}\\ 0 \le y^{n}_{p} \le 1, 0 \le \hat{y}^{(n)}_p \le 1, \epsilon > 0 \nonumber \end{aligned}$$
(3)

By replacing NP with the sum of \(\mathrm{sign}(y^{(n)}_{p})\), it becomes equivalent to MAPE for \(y^{(n)}_{p}\) which take positive values.

4 Experiment

Based on our method, we constructed a support system for recipe design on WEB application. Below are two screens of the application screen.

Fig. 2.
figure 2

The page for entering a query.

If you enter information on “required ingredients”, “forbidden ingredients” and “surprise”, you will transition to the result page (Fig. 2).

Fig. 3.
figure 3

The page displaying a result.

The input information is described at the top. A recommended recipe is displayed under that. Below it a plurality of recipes generated by the algorithm are displayed (Fig. 3).

First, We also generated recipes by our method using requests of randomly generated. After that, we took and analyzed a questionnaire including question items on the generated recipes.

In the questionnaire, the main questions are roughly divided into two types. One type is the question “Which of the following two recipes do you feel more than wanting to drink?” Another type is the question “Which of the following two recipes do you think is “a cocktail recipe created by a computer algorithm”?”. Ten questions were prepared for each question type. The two recipes presented in one question are the recipe generated by the algorithm based on a certain request and the known recipe that most closely matches the same request. Furthermore, we asked questions such as taste for alcoholic beverages and drinking habits. A questionnaire survey was conducted for 37 males and females aged from 20 to 43. Using the data obtained from the questionnaire, we analyzed the probability of wanting to drink the recipe of the algorithm, the probability of discrimination between a recipe of the algorithm and a known recipe, respectively by logistic regression.

4.1 Procedure

Two patterns of analysis by logistic regression are carried out based on the questionnaire result. One is modeling the probability that the recipe of the algorithm is preferred, and another is modeling the probability that the recipe of the algorithm is distinguished.

First, modeling the probability that the recipe of the algorithm is preferred is explained. The objective variable is set to 1 if the algorithm recipe is selected as the recipe that the user prefers, and 0 if not selected. We prepared the following variables as explanatory variable candidates.

  • Type of alcohol drink preference (True: 1, False: 0)

    • The most popular alcohol drink (whisky or wine or beer, plum wine)

    • Popular alcohol drink (liqueur or jin or shochu or sake)

    • Unpopular alcohol drink (brandy or spirits or vodka oe rum)

    • None

  • Question

    • Question 1

    • Question 2

    • Question 3

    • Question 4

    • Question 5

    • Question 6

    • Question 7

    • Question 8

    • Question 9

    • Question 10

  • Use of “surprise” in algorithm (True: 1, False: 0)

  • Alcohol preference (True: 1, False: 0)

  • Cocktail preference (True: 1, False: 0)

  • Age (normalized)

  • Sex (Male: 1, Female: 0)

  • Alcohol drink preference (True: 1, False: 0)

    • Whisky

    • Jin

    • Beer

    • Liqueur

    • Wine

    • Sake

    • Plum wine

    • Shochu

  • Experience equivalent to work of making cocktail (True: 1, False: 0)

    • Experienced

    • Not experienced

  • Frequency of drinking cocktail

    • No drinking

    • Few (About 2 days or less per month)

    • Normal (About 1 to 3 days per week)

    • Frequent (About 4 days or more per week)

  • Frequency of drinking alcohol

    • No drinking

    • Few (About 2 days or less per month)

    • Normal (About 1 to 3 days per week)

    • Frequent (About 4 days or more per week)

  • Drinking amount on drinking alcohol

    • No drinking

    • Small (It is equivalent to beer medium bottle (1 bottle) or sake (1 go) or whisky single (2 cups) or less)

    • Normal (It is equivalent to beer medium bottle (1 to 2 bottles) or sake (1 to 2 go) or whisky single (3 cups))

    • Large (It is equivalent to beer medium bottle (3 bottles) or sake (3 go) or whisky double (3 cups)) or more

  • Maximum value of “surprise” at the time of ingredient selection (normalized)

Variables are selected from the above variables using the variable increment method of the stepwise method based on AIC criterion and the resulting model is treated as an official model in this study.

We describe the modeling the probability that the recipe of the algorithm is distinguished. The objective variable is 1 if the recipe of the algorithm is selected as the recipe which is thought to have been created by the algorithm, and 0 if it is not chosen. For explanatory variables, we use the same variables as those used for modeling the probability that the recipe of the algorithm is preferred. However, note that the variables of the question correspond to different questions. In the same way as modeling the probability that the recipe of the algorithm is preferred, the variable selection is also done, and the model obtained from the result is handled as an official model in this study.

4.2 Results

Crosstabulation on whether or not each respondent like alcohol and whether or not each respondent like cocktails is shown below (Table 2).

Table 2. Crosstabulation on whether or not each respondent like alcohol and whether or not each respondent like cocktails.

Crosstabulation of preference of existing recipe vs. recipe created by algorithm and presence of “surprise” is shown below.

Table 3. Crosstabulation of preference of existing recipe vs. recipe created by algorithm and presence of “surprise.”

As shown in Table 3, the recipe of the algorithm seems to prefer to drink is about 51%.

The result of modeling the probability that the recipe of the algorithm is preferred is shown in the following table (Table 4).

Table 4. The result of modeling the probability that the recipe of the algorithm is preferred.

Crosstabulation of the recipe which was thought to be a recipe created by the algorithm and the presence of “surprise” is shown below (Table 5).

Table 5. Crosstabulation of the recipe which was thought to be a recipe created by the algorithm and the presence of “surprise.”

From the result, the rate at which the recipe of the algorithm is perceived is about 57%.

The result of modeling the probability that the recipe of the algorithm is distinguished is shown in the following table (Table 6).

Table 6. The result of modeling the probability that the recipe of the algorithm is distinguished.

5 Discussion

In this study, it is desirable that we proposed a system with the following properties. One is to make people want to drink cocktails of recipes generated by the algorithm. Another is that recipes generated by the algorithm is indistinguishable from existing recipes.

As an overall tendency, there are more cases where people want to drink a cocktail of recipes generated by the algorithm, and there are more cases that a recipe generated by the algorithm is distinguished from an existing recipe by a person. However, neither of these trends is prominent.

In order to make more appreciate recipe which is match to individual person’s favorite, the following factors are important. First of all, it is better to use “surprise”. In the system proposed in this study, it is left to the user whether or not to use “surprise”, but we should always use “surprise” to reduce the elements that the user must select. By reducing the number of elements that must be selected, motivation for user selection and improvement in satisfaction after selection can be expected. Also, the features of users suitable for the proposed system are as follows.

  • Person who likes liqueurs

  • Person who does not like beer

  • Person who does not like unpopular alcohol drink

People who can not distinguish between recipe generated by algorithm and existing recipe have the following features.

  • Person who does not like liqueurs

  • Person who likes cocktails

  • Person who frequently drinks alcohol

  • Person who has no experience equivalent to work making cocktails

  • Person who likes popular alcohol drink

To summarize the discussions in the above two viewpoints, we point out following matters.

The likes and dislikes of liqueur in the features of users suitable for the proposed system are opposite, however, people who like liqueurs are thought to want to drink cocktails of algorithm recipes after distinguishing them from existing recipes. Therefore, liqueur lover is appropriate as a target user image. Even people who do not like popular alcohol drinks or unpopular alcohol drinks, some people prefer cocktails. Such people are suitable as users of our system. Such people are considered people who does not like drinking alcohol drink as it is. In other words, they are suitable people as a target for providing cocktails. People who do not like popular drinks and have no experience equivalent to a cocktail job match the user image. It is thought that such people are not familiar with alcohol drink or cocktail. Therefore, it should be assumed that the user does not have much knowledge. People with a high frequency of alcohol drinking are not only difficult to discriminate through recipes generated by algorithms or not, but also they should consume a large amount of alcohol. It can be said that these people can be promising customers from a commercial point of view.

6 Conclusion

We proposed a support system for demand driven design of cocktail recipes.

As an overall tendency, there were more cases where people want to drink a cocktail of recipes generated by the algorithm, and there were more cases that a recipe generated by the algorithm is distinguished from an existing recipe by a person. However, neither of these trends was prominent.

In addition, as a result of analyzing the questionnaire, the features of people ideal for users and the points to be improved of the system were also clarified.

At the present study, we adopted a system that allows users to select ingredients. However, in the present system, there are too many choices and it may become a burden to the user. Therefore, instead of letting users choose ingredients, we should allow users to enter rough information such as taste. Also, since we found “surprise” to be preferable, we will change to specifications that always use “surprise”.

Furthermore, we would like to conduct an evaluation experiment that people actually drink cocktails made based on recipes made by the proposed method.