Classification of retail products: From probabilistic ranking to neural networks

Food retailing is now on an accelerated path to a success penetration into the digital market by new ways of value creation at all stages of the consumer decision process. One of the most important imperatives in this path is the availability of quality data to feed all the process in digital transformation. But the quality of data is not so obvious if we consider the variety of products and suppliers in the grocery market. Within this context of digital transformation of grocery industry, \textit{Midiadia} is Spanish data provider company that works on converting data from the retailers' products into knowledge with attributes and insights from the product labels, that is, maintaining quality data in a dynamic market with a high dispersion of products. Currently, they manually categorize products (groceries) according to the information extracted directly (text processing) from the product labelling and packaging. This paper introduces a solution to automatically categorize the constantly changing product catalogue into a 3-level food taxonomy. Our proposal studies three different approaches: a score-based ranking method, traditional machine learning algorithms, and deep neural networks. Thus, we provide four different classifiers that support a more efficient and less error-prone maintenance of groceries catalogues, the main asset of the company. Finally, we have compared the performance of these three alternatives, concluding that traditional machine learning algorithms perform better, but closely followed by the score-based approach.


I. INTRODUCTION
According to [1] digital transformation facilitate new ways of value creation at all stages of the consumer decision process: pre-purchase (need recognition, information search, consideration or evaluation of alternatives), the purchase (choice, ordering, payment), and the post-purchase (consumption, use, engagement, service requests).This value creation is especially relevant given the very competitive nature of the retail market to gain a larger market share.Although digital transformation [2] is being addressed from different fields: multi-channel solutions, user modeling, internet of things, etc. all of them rely to some extent on the availability of information on operations, supply chains and consumer and shopper behaviors.This information is the raw material for data analysis as a central driver towards digital transformation.Food retailing is now on an accelerated path to a success penetration into the digital market and manufacturers and retailers must prepare to achieve six digital imperatives.[3], [4] : (1) Integrate the digital offerings with their brick-and-mortar operations; (2) Forecasts to increase operational efficiency; (3) Optimizing omnichannel marketing and promotions; (4) Fixing inaccurate master data and (5) A single comprehensive view of customer insights; and (6) Integrating digital and in-store shelf capabilities.
This paper focuses on the most supportive digital imperatives, that is, the availability of quality data (accurate, complete and well-maintained data) in order to feed all the visible processes in digital transformation.The quality of data is not so obvious if we consider the variety of products and suppliers in the grocery market.As a remarkable example, Walmart is the largest grocery retailer with more than 10,000 retailer units all over the world and around 3,000 suppliers and 20 million food products.Also, Walmart Marketplace gives access to third party retailers who would like to offer their products to more than 90 million unique visitors who shop on Walmart.comevery month.With this scale of locations, online users, providers, and third-party retailers, maintaining the quality of the information is an issue to address every day.Moreover, Walmart provides suppliers up-to-date sales data.Having the magnitude of Walmart or not, the challenge into a successful transition into the grocery digital market is to get the right data, process it at a high speed and obtain some valued of it.
As well as in other sectors, like financial or consumers in general, grocery industry is harnessing digital to innovate through data-drive business models.This will allow us to optimize processes and operations as replenishment and pricing and, at the same time, offer superior convenience in online grocery [5].Of course, it should also be applied in brick and mortar by redesigning their strategies towards omnichannel retailing.The proliferation of these data drive models brings the emergence of data vendors also in the grocery industry.Precisely, this is where Midiadia1 comes in.This Spanish company works on converting data from the retailers' products into knowledge with attributes and insights from the product labels.The so-called MidiadiaTECH provides the retailers with deep knowledge about their stock and the customers with a new customized shopping experience.While Midiadia extracts the information from the labels of the products, the categorization of the products is manually carried out.Since there are a lot of manufacturers and a lot of different sizes of shops, there is a considerable dispersion of products.Moreover, the list of products changes constantly, so it must be managed properly, taking into account the complex European legislation [6] as well as the national [7] and regional [8] legislation dealing specifically with groceries.Therefore, the main contribution of our approach is that provides retail companies with an automatic categorization solution for new products.This classification is uniquely based on the description of each product.The methodology can be horizontally applied to different domains assuming there is a previously known taxonomy or hierarchy of categories.Thus, it would be applied to recruitment processes, travel decision support systems, investment, etc.
In this context, our objective is to provide a solution to automatically categorize the constantly changing products in the market.Being more specific, Midiadia has defined a food taxonomy and our purpose is automatically to assign which is the right variety/category for a new product.This task must be done exclusively using the information provided by the product labeling and packaging.This would help to maintain the Midiadia data in a more efficient and less error-prone way.With this aim, we have defined different classifiers based on three different approaches: a score-based ranking method (based on BM25), machine learning algorithms (such as K-Nearest Neighbors (KNN), fuzzy K-Nearest Neighbors (FKNN)), eXtreme Gradient Boosting (XGBoost), and deep neural networks (particularly Multilayer Perceptrons (MLP)).After comparing the results, we can conclude that if we offer only one value for the Variety, then FKNN is the best approach, but if we offer two or three options (leaving the decision between them to the experts in the company), then, the best approach is the score-based ranking method, closely followed by FKNN.
The paper is organized as follows: section II describes previous work related to classification in retailing form a customers point of view; section III described the dataset provided by Midiadia; section IV provides an overview of the problem to be solved.Then the four classifiers are introduced, the score-based classifier (section V), the nearest neighbors' classifier (section VI), an extreme gradient boosting classifier (section VII), and the neural network classier (section VIII).Finally, section IX shows evaluation and results and section X concludes our work.

II. RELATED WORK
Automatic retail classification is an essential task for industry, since it could reduce the huge amount of human labor needed in the product chain, from distribution to inventory management.Within the traditional market field (stores and supermarkets) a considerable number of approaches in the specialized literature focus on recognizing retail products on shelves, that means, the automatic classification approaches are usually based on the product appearance.This will be very useful for retailers, who can audit the placement of products, and for costumers, who may obtain additional information about products by taking a simple picture of the shelf.These approaches usually rely on computer vision techniques [9]- [12] and face challenging issues such as the similar appearance in terms of shape, color, texture and size of different products.In order to overcome these problems, other researches combine the information obtained from image analysis with other information based on statistical methods in order to provide a fine-grained retail product recognition and classification [13].Advances in this area can help to logistic problems like shelf space planning [14].
Apart from these specific problems for image analysis, there is a well-known problem with retail products: the overwhelming amount of different products and categories in any supermarket.A typical supermarket could have more than thousand of different products [15] and this number increases when we talk about merging catalogues from different supermarkets.Because of the popularization of e-commerce, this large number of different products are usually managed through multilevel category systems.Two relevant problems arises within this field.First, obtaining relevant information (characteristics and description) of retail products.Second, the automatic retail classification based on this data.Some approaches have focused on the first topic and try to automatically extract relevant metadata from the analysis of product images [16], [17].However, retailers usually acquire this data from suppliers and/or third parties to complete the product information on their websites.Precisely the research work introduced in this paper is being used by one of these third parties, a Spanish SME (Midiadia) that offers relevant data to retailers for their e-commerce platforms.Both, retailers and third parties, need to have automatic classification systems based on the information of the retail products to have consistent multilevel category structured data.
In [18], this problem is tackled by applying natural language processing techniques to the text titles.One of the problems these researches face are the typical absence of grammar rules in products title or name, so they apply short text classification methods, such as character embedding, to overcome this issue.In [19], a United States patent, a machine learning classifier helps to automatically select one or more categories for a product.The information is extracted from the metadata fields of the product description and it is used to enrich a recommendation engine.In [20], another United States patent, a new method to automatically categorize a product in an electronic marketplace is provided.It is based on parsing the category information (provided by the retailer) to obtain a first category identifier.This information is used to search the most adequate category identifier within the available taxonomy.This methodology takes into account information of expired category identifiers.The authors in [21] perform an interesting analysis of text classification and offer a solution to automated classification on e-commerce by using distributional semantics.The idea here is to create a taxonomy by first applying a modification of the Bag-of-Words model [22].This approach creates feature vectors from the description of the products and combines three types of predictors: the Path-Wise Prediction Classifier, in which each path in the taxonomy tree is considered as a class; the Node-Wise Prediction Classifier, in which each node in the taxonomy tree is considered as a class; and the Train Depth-Wise Node Classifier, which combines different classifiers on each level of the taxonomy tree, where each node represents a different class inside these sub-classifiers.There is also an interesting and different analysis [23] that studies how shape and packaging impact on brand status categorization, concluding that slender packages are more likely to be categorized as high-end products (high brand status) than those in short, wide packages (low brand status).
Deep learning technologies are also used in this field (retail) to enhance the information analysis processes.In fact, [24] offers a survey of the most recent works in the field of computer vision applied to automatic product recognition combined with deep learning techniques.Other interesting analysis that supplements the previous one is the work in [25].Here the authors focus on fine-grained image analysis (FGIA) combined with deep learning to automatically assign subordinate categories in specific application fields.Although there explicitly mention species of birds or models of cars, the bases might also be applied to retail commerce as well.In the paper, the FGIA techniques are organized into three main categories: recognition, retrieval, and generation.When dealing with natural language, instead of images, there are also research works that apply deep learning to deal with automatic analysis of this kind of data.For instance in [26] the authors face the automatic analysis of natural language to infer polarity and sentiment information from reviews in social media.Their approach is based on vector machine, logistic regression, and advanced deep neural network models.It explores dependency-based rules to extract multilingual concepts from a mixture of sentences in two languages (Persian and English) to detect subjectivity and sentiment in sentences.
Other approaches take into account the customers for gathering relevant information about products.For instance, the authors of [27] study the influence that product categorization and types of online stores have on customers, mainly using hypothesis testing.The research follows three steps: the first one is a test to see if the online shopping preferences of the customers vary according to the type of product, without taking into account the kind of online retail store; the second step is a test on the interaction effects of both the online store and the types of products; and the last step is a hypothesis testing, which results in the identification of the attributes considered relevant by the customers when they purchase retailing products.Along this line, the proposal in [28] analyses the prediction of customer behaviour in the purchase process with machine learning techniques used in real-world digital signage viewership data.The data were obtained from a camera that recorded a clothing store and additional features that were added manually.In this case, the customers can be considered in buying groups -for example, a family that is going to purchase a product.The goal was to classify the customers in six categories: (i) Initiator, the person from the buying group who recognizes the need and finds the product that the group needs, (ii) Influencer, the person whose opinion has a relevant effect on the purchase decision, (iii) User, the final customer who will use the product or service, (iv) Decider, the one who makes the final decision about whether or not to purchase a product, (v) Purchaser, the person who pays for the purchased product and also determines the terms of the purchase, and (vi), Passive influencer, a member of the buying group but is not involved in the purchase.In [29], the approach is exclusively customer-behaviour based, providing a new clustering mechanism able to organize retail products into different categories.
In the specialized literature, there are different approaches for automatic categorization of retail products.Computer vision solutions are mainly oriented to traditional supermarkets and have to face important accuracy problems because of the huge amount of different products and the high similarity in the packaging of products within the same categories.In the E-commerce field, there are different needs, but automatic classification based on product characteristics is a relevant one.The number of different products is overwhelming, especially if we are working on combined catalogues, i.e., catalogues from different supermarkets and retailers, as it is our case.Analysing the product title or name is not enough and taking into account customer behaviour is not always available.Thus, to the best of our knowledge, there are not other studies that have faced the automatic classification problem of combined catalogues, without data from customers and only based on the product description (name, trade mark and ingredients).Our proposal fills in an interesting gap for third parties specialized on enriching the retailers catalogues with smart data.

III. DATASET
The dataset used in this work is provided by Midiadia which consist of a collection of 31, 193 products.The list of attributes considered in this study are shown in Table I.The European Article Number (EAN) is a standard describing a barcode symbology and numbering system used in global trade to identify a specific retail product type, in a specific packaging configuration, from a specific manufacturer.Category, Subcategory, and Variety represent the 3-levels (hierarchy) the company considers to organizing the catalog into a taxonomy.Brand is an identifying name for a product manufactured by a particular company.Finally, the other terms are coherent to the EU regulation, as follows.Just to clarify the meaning of these terms, a sample extract2 of the dataset is shown in Table II: • 'Customary name' means a name which is accepted as the name of the food by consumers in the Member State in which that food is sold, without that name needing further explanation.• 'Legal name' means the name of food prescribed in the Union provisions applicable to it or, in the absence of such Union provisions, the name provided for in the laws, regulations and administrative provisions applicable in the Member State in which the food is sold to the final consumer or to mass caterers.• An 'Ingredient' means any substance or product, including flavorings, food additives and food enzymes, and any constituent of a compound ingredient, used in the manufacture or preparation of food and still present in the finished product, even if in an altered form; residues shall not be considered as 'ingredients'.Moreover, the EU regulation on the provision of food information to consumers.• 'List of ingredients' (suitable heading which includes the word 'ingredients') shall include all the ingredients of the food, in descending order of weight, as recorded at the time of their use in the manufacture of the food.The dataset also includes other attributes, such as packaging size, healthy claims, calories, etc.However, these attributes are aimed to recommend alternative or replacement products in a specific variety, but the problem we are trying to solve is a different one: when a new product is incorporated into the company food catalog, all the information in the product labeling and packaging is automatically extracted but the decision of which Variety is the one that corresponds to the new product is currently manually done.Thus, we need to automatically decide to which Variety a new product belongs, so we have focused only on attributes directly related to the kind of food, discarding the others.According to this selection, rows with blank fields in all the selected columns of Table I are removed.That entails that we have worked with a dataset with 20,888 products, hereinafter MDD-DS (Midiadia DataSet).Table I also includes the number of different values that exist in the variable considered MDD-DS.Thus, as a categorical variable, the dataset shows 159 levels for Variety.The fact of knowing in which upper level of categorization is each variety can be helpful for classification purposes.Brand can bring useful information apart from the Name and Legal Name since they are defining the kind of product.Regarding Ingredients, it is a list of ingredients that require further processing in order to support the classification.Figure 1 shows the distribution of products per variety as well as the statistical parameters of this distribution.The average number of products per variety is around 200, being the 1st quartile 116.5, so that 75% of the varieties have a number of assigned products above 213 products.

IV. PROPOSED MODEL
In order to automatize the time-consuming classification process, this paper proposed a multi-label classification methodology to map inputs (new products) to a maximum of 3 labels from all the varieties considered3 .According to the scheme in Figure 2, the deployment of our solution (bottom part of the figure) takes Name, Legal Name, and Ingredients of a new product (N P ) as input observational variables.Then, a multi-label classifier predicts the varieties' score of N P , that is the classification score for N P to be a member of each variety (class) C1 . . .Cn in the taxonomy.The output is defined as the three varieties C1, C2, C3 with higher scores.From these three varieties the sets T op_1 = C1; T op_2 = {C1, C2} and T op_3 = {C1, C2, C3} are defined.This paper describes the methodology and experiments to obtain the classifiers by using the MDD-DS (described in section III).The modeling methodology consists of 3 main steps: (1) preprocessing the data and potentially reducing their dimensionality; (2) learning the classifier model: three different classifier models, such as score-based model, nearest-neighbors models ((KNN: K-Nearest Neighbors and FKNN: Fuzzy K-Nearest Neighbors) and deep learning (MLP or Multi-Layer Perceptron Network); (3) testing the classifier models in order to compare them and estimate the quality measures of our approach.In step (1), and in order to apply machine learning and deep learning approaches, we include a new sub-step for dimensionality reduction based on PCA (Principal Component Analysis).
The main idea of this paper is to select the best classification algorithm for retail products among a wide range of possibilities that goes from probabilistic ranking approaches to deep neural network ones.With this aim, we have selected different techniques within each approach: a score-based model in probabilistic ranking based on the BM25 algorithm; K-Nearest Neighbors (KNN), Fuzzy K-Nearest Neighbors (FKNN, a fuzzy version of the KNN classification algorithm), and eXtreme Gradient Boosting (XGBoost) in machine learning; and Multi-Layer Perceptron in deep neural networks.This selection was made taking into account the advantages of each algorithm.Consequently, BM25 was selected because of its efficiency, since its performance is well known in different ad-hoc retrieval tasks, especially those designed by TREC [30] (see section V for further details).Within the machine learning field, we have selected KNN and FKNN because both of them need to perform predictions in order to learn new knowledge.Therefore, new products can be added because they will not affect the accuracy of the algorithms [31].In FNNN, we have proposed to use the fuzzy memberships values of the samples to adjust the contribution values, since this algorithm delays the decision to assign a sample to a certain class across memberships [32], [33] (see section VI for further details), and XGBoost for predictive modeling as a sturdy and efficient machine learning method for prediction.XGBoost is a boosting algorithm that belongs to supervised learning, which is an ensemble algorithm based on gradient boosted trees.It integrates the predictions of "weak" classifiers to achieve a "strong" classifier (tree model) through a serial training process.It's additionally a comparatively new technique; however, it's achieved wonderful results in several classification tasks (see section VII for further details).Finally, within the deep learning area, we have selected the MLP algorithm.This is a simple but efficient algorithm that represents a broad family and that was used because of its ability to adaptive learn to perform tasks based on the data provided for the initial training or experience.Besides, it is based on a defining a decision function that it is directly obtained through training [34] (see section VIII for further details).

A. Preprocessing
As previously mentioned, MDD-DS consists of 20,888 products, which is the result of cleaning the original dataset (31,193 products) before applying the classification algorithm.This first cleaning procedure consisted of removing all the products with no name, no ingredients, and no legal name.After that, MDD-DS is pre-processed by extracting all the meaningful words for the attributes 'Name', 'Legal Name' and 'Ingredients'.For each product p, the three attributes are merged into a single text which aims to describe the product des(p).This description (des(p)) is obtained after a cleansing process described [35] step by step in Algorithm 1: (i) parenthesis are transformed into blank spaces, (ii) numbers, stop-words, punctuation and extra spaces are removed (iii) all letters are converted to lowercase, and (iv) repeated strings are removed.
Then words are split and a vector of words product_words(p) is generated, an example is shown in Table III.Additionally, we also create the all_products_words (for all the products in MDD-DS).This is another vector of words that contains as many elements as different words in the products' vectors (from the fields Name, Legal Name, and Ingredients).After preprocessing, all_products_words contains a total of 11,359 unique words, an example is shown in Table IV.
With the information provided by the all_products_words, we obtain the product matrix X[m, n], which is mathematically defined as follows.Let ⃗ w be the n-dimensional vector obtained from all_products_words such that ⃗ w = (w1, . . ., wn) and ∀ k ∈ [1, . . ., n], w k is a string ∈ all_products_words and N = dim(all_products_words) is the total number of different meaningful words in the dataset (after cleaning).
• The product matrix X[m, n] is a M xN matrix where each column represents a word wi ∈ ⃗ w and each row represents a product p of the dataset so that M is the total number of products  • Let ⃗ p be the product_words[] list such that, each element contains a vector ⃗ pi hence ⃗ p = (⃗ p1, . . ., ⃗ pm).Likewise, ⃗ pi = (pi [1], . . ., pi[l]) where l = dim(product_words[i]), length of the vector in the i element of the list ⃗ p.Note that ∀ k ∈ [1, . . ., l], pi[k] is a string.Therefore: where This means X[i, j] is 1 if the product i has the word j in its product_words[i]; otherwise, the value will be 0.For evaluation purposes, we include the variety of the product in an additional column, as shown in Table V.
There are some interesting techniques within this field, such as Principal Component Analysis (PCA) [36], Linear Discriminant Analysis (LDA) [37], and Autoencoders [38].PCA and LDA are both linear transformation techniques used for dimensionality reduction and visualization, but while PCA is an unsupervised technique, LDA is a supervised one.PCA searches for attributes with the most variation and ignores class labels.In contrast, LDA maximizes the separation of known categories.An autoencoder is a neural network, with as many output units as input units and at least one hidden layer, that is used to learn a representation (encoding) for a data set by training the network to avoid or ignore signal noise.This provides a non-linear transformation that reduces the dimensionality of the data.The authors of [39] evaluate the performance of this technique by comparing an autoencoder with other models that can perform a similar reduction task, such as PCA, LDA, etc.The results showed that PCA and LDA are relatively more stable than autoencoder (low stability implies that different results might be obtained when replicating the experiment).To sum up, we opted for an stable reduction technique and, more precisely, an unsupervised one, that is PCA.Both stability and the absence of a training step before applying reduction eases the deployment of automatic classification in a real retailing scenario, where the product catalogue is intrinsically dynamic.

V. SCORE-BASED MODEL
Our first approach is based on the bag-of-words BM25 model [42] (BM for Best Matching), widely used in information retrieval to rank documents based on a query of words.The BM25 equation considers the frequency of occurrence of the words in the documents, smoothing out the weighting in favour of how distinctive they are: where w is the word analyzed, c(w, D) is the number of times the word w appears in the document D, Q is the query, N is the number of documents, D is the document analyzed, df(w) is the number of documents that contain the word w, k is a constant with the value 1.2 (typical value obtained from TREC experimentation [30]), |D| is the total number of words in the document D, b is a constant with the value 0.75 (typical value obtained from TREC experimentation [30]), and avdl is the average number of words per document.
In order to apply this probabilistic model to the classification of retail products into varieties, after obtaining the product matrix, we generate a variety matrix.This matrix will have as many columns as different words exist in the dataset -i.e., the same number of columns as the product matrix.The number of rows will be the same as the number of different varieties obtained from the dataset.
• Let Y be the variety matrix (y x n).
• Let ⃗ v be the m-dimensional vector that contains an integer that represents each product variety.Thus, ⃗ v = (v1, . . ., vy). Therefore: In Equation 4, the value of Y [i, j] will be the number of times the word j appears in the variety i (i.e., the set of all the products belonging to it and represented by the index k), as shown in Table VI.To obtain the variety V of a product, we apply the modification of the BM25 model depicted in (Equation 5).This equation gives a realistic smoothing when the term frequency is high and rewards low-frequency words even more than the one in (Equation 3).We consider two modifications with regard to the original BM25 equation.First, one unit is added to both the nominator and the denominator.The reason for the addition in the denominator is that the term of the query may be missing in the analyzed document within the corresponding iteration of the addition, so vf (w) can be equal to zero.Adding a unit instead of 0.5 makes more sense in our scenario because it is more realistic to add integers (i.e., entire words) than a rational number; the lower bound is also equal to the unit.At the same time, the unit added to the numerator balances out the fraction.The second modification is that the factor c(w, V ) is a constant.This is due to the fact that the word duplicates contained in the query are removed and the terms are unique.Thus, c(w, V ) will always be equal to 1.
Once the modified BM25 equation is repeated for all the varieties, the variety was chosen as a result for a product is the one ranked the highest.

VI. NEAREST-NEIGHBORS MODEL
The nearest neighbor (NN) [43] rule is a nonparametric method for classification based on instances.Taking into account the problem in Figure 2, a product in the MDD-DS p follows the definition {p1, p2, .., pn, v} where n is the number of the aforementioned product attributes and v is it's assigned product variety.
The KNN approach [31] classifies an unlabelled product on the majority of similar sample products among the k-nearest neighbors in MDD-DS that are the closest to the unlabelled product.The distances between the unlabelled product and each of the training product samples is determined by a specific distance measure.Therefore, the variety of new product ⃗ p is assigned to the most common variety among its closest k training samples according to the attributes considered in the product vectors.More formally, let ⃗ unlabel − p an unlabelled product, the decision rule predicts a variety v for the ⃗ unlabel − p according to the variety v of the majority of its k nearest neighbors; in the case of a tie, v is given by the closest nearest neighbor that belongs to one of the tied varieties.
One of the problems for KNN is to give equivalent importance to each of the samples to determine the class membership, neglecting the typicality among them.Alternatively, some challenges arise for classification in high dimensionality dataset where it is complex to discriminate between classes.This problem is due to the fact that the number of training samples and the increase in dimensionality grow overwhelmingly.The aforementioned drawbacks have been addressed in the literature by Fuzzy Sets Theory to allow imprecise knowledge to be represented and fuzzy measures to be introduced.
Consequently, FKNN is a fuzzy version of the KNN classification algorithm [32].Fuzzy classifiers delay the decision to assign a sample to a certain class by using memberships.In terms of our problem in Figure 2, FKNN assign to an ⃗ unlabel_p a variety's fuzzy membership (not just true or false) by taking into account the distance from ⃗ unlabel_p to its k nearest neighbors and those neighbors' memberships for this variety.More formally: • Variety membership is defined for each product ⃗ p in MDD-DS with a value in [0, 1] for each variety v.Although the details can be found in [32], the main idea is assigning to each product ⃗ p a membership value for a variety v not just according to the assigned variety (true value) but also according to the assigned variety for its k nearest neighbors.
• Besides given an unlabeled product ⃗ unlabel_p, each neighboring product ⃗ p = {p1, p2, .., pn, v} votes for every variety {v1, v2, . . ., vm} by using its variety memberships (not just for its assigned one v).Again the details can be found in [32] but votes are weighted according to the inverse of the distance to ⃗ unlabel_p and added.The estimated variety v for ⃗ unlabel_p is the variety with the greatest combined vote.The main benefit of using the FKNN model may not be decreasing the error rate but, more importantly, the model provides a degree of certainty that can be used with a "refuse to decide" option.Therefore, objects with overlapping classes can be detected and processed separately Since KNN and FKNN are computationally expensive algorithms, we apply Principal Component Analysis (PCA) to MDD-DS to reduce its dimensionality.In our experiment, the original set of product attributes are transformed into a smaller set (the so-called principal components) so that the reduced dataset MDD-DS-reduced still contains most of the information in MDD-DS.More specifically, we evaluate the performance of KNN and FKNN applying PCA and selecting 400, 500, 600, 700 and 800 principal components.As a result, the product matrix is replaced by a PCA-reduced matrix.Given the variance retention for the following number of eigenvectors (400, 0.796452); (500, 0.825814); (600, 0.84735); (700, 0.865117); (800, 0.879153), the experiments in this paper have been carried out over a reduced dataset of 600 principal components, referred to as MDD-DS-PCA-600.

A. Optimal k and Distance for KNN and FKNN
The key to success in KNN and FKNN are finding the optimal value of k and the distance function.Usually, the k parameter is chosen empirically depending on each problem, different numbers of nearest neighbors are tested, and the parameter with the best performance (accuracy) is chosen to define the classifier.Choosing the optimal k is almost impossible for a variety of problems since the performance of a KNN classifier varies significantly when changing k and the change of the distance metric used [44].Therefore, the decision about the distance measure also plays a vital role in determining the final result of the classification.Although Euclidean distance is the most widely used distance metric in NN-based classifiers, we have applied a variety of distance metrics in MDD-DS.We refer to as "best distance metric" to the metric which allows KNN, FKNN to classify test samples with the highest accuracy, recall, precision, and F-score.The definition of the distances considered in this paper (Spearman, Cosine, Correlation, Euclidean, Cityblock, Chebychev, Hamming, Jaccard, and Seuclidean) are described in Equation XIII, included as an appendix.To determine the optimal value of k and distance for Nearest-Neighbors Models KNN and FKNN, we deploy the pseudocode in Algorithm 2 to try different combinations in two loops (odd k values initialized from [1 to 30] and the different distances used) over the reduced dimension MDD-DS for 600 principal components.This value was selected taking into account that with 600 principal components we obtain a value around 85% of retained variance, as a criteria to choose the appropriate number of principle components.Besides, we have perceived that the results do not significantly improve if the number of principal components increase.Since we pursue to obtain the optimal pair of k and distance not only for classification per se (T op_1) but also for T op_2 and T op_3, the pseudocode obtain the accuracy for all the combinations as it is shown in Figure 3.
The optimal type of the distance is Spearman of three approaches of KNN and FKNN.Table VII shows that the optimal value of k and accuracy result for each approach according to the Figure 3.  [45], [46] is an extremely scalable end-to-end tree boosting system, a machine learning technique for classification and regression issues.XGBoost is additionally boosting algorithm belonging to supervised learning; it uses an ensemble of X classification and regression trees (CARTs), each inside node represents values for attributes test, and a leaf node with scores represents a choice (X i E |i ∈ 1..X).In terms of our problem in Figure 2, and given ⃗ p = {p1, p2, .., pi, v}, XGBoost can learn using Equation 6, which is (p1, p2, .., pi) → v. Given a set of features {p1, p2, .., pi} for ⃗ unlabel_p, XGBoost can predict based on the total of the prediction scores for every tree: where pi represents the i th training sample of MDD-DS and vi are the variety corresponding label, sx represents the score for x th tree, and S represents the set of all X scores for all CARTs.XGBoost adopts a similar gradient boosting as the Gradient Algorithm 2 Tuning parameter for KNN and FKNN 1: procedure TUNING_PARAMETERS(Train_PCA600, Test_PCA600) Dist[] = ['Spearman', 'Cosine', 'Correlation', 'Euclidean', 'Cityblock', 'Chebychev', 'Hamming', 'Jaccard', 'Seuclidean'] for K ← 1 : 30 by 2 do 8: for J ← 1 : 9 do 9: M ← build_model(Train_PCA600, k, Dist[J]) 10: [C1, C2, C3] ← Predict(M , Test_PCA600) end for 12: i ← i + 1 13: end for 14: T op_1 ← C1 15: return T op_1, T op_2, T op_3 18: end procedure Boosting Machine (GBM).Regularization is applied to enhance the ultimate result: where LF (θ) means the total objective function, l represents the differentiable loss function, that measures the difference between the prediction of a variety vi and the target label of a variety vi.The Ω avoids over-fitting penalizes the complexity of the model: where γ and λ are constants that control the degree of regularization, T represents the leaves number in the tree, and w means the weight of each leaf.XGBoost also applies a second-order approximation to extend the loss function and removes the constant term and applies two additional techniques to reduce overfitting further; the details can be found in [45], [46].

VIII. MLP MODEL
Multilayer perceptron's (MLP) [47] is a deep feed-forward neural network particularly designed for multi-class supervised learning problems.It has one or more hidden layers between the input and the output, each layer fully connected to the next.An MLP network is trained on a set of input-output pairs so that the network learns to model the dependencies between those inputs and outputs.Training involves adjusting the parameters, or weights and biases, of the model to minimize error.Back-propagation is used to make those weight and bias adjustments in relation to error and error itself can be measured in various ways.Figure 4 shows MLP structure with scalar output.In terms of our problem in Figure 2, and given ⃗ p = {p1, p2, .., pn, v}, MLP learns a function f ({p1, p2, .., pn}) → v. Given a set of features {p1, p2, .., pn} for ⃗ unlabel_p, MLP can learn a non-linear function for classification in the varieties space v.For the purpose of comparison, we built-up an MLP network from 600 principal components as a reduced input set.With a Leaning Rate4 of 0.001 which is its default value, the first experiments showed a significative increase of performance from 1 to 3 hidden layers and, above 3 hidden layers (3,4,5), the increase in performance slows down meanwhile computation time increases significantly.
In practice, as the number of hidden layers determine the ability to generalize, we selected 3 hidden layers, upper values, apart from increasing computation time, tend to overfit which leads to reduce classification performance for out-of-sample instances.To obtain the optimal values of the number of nodes per layer N and the times an algorithm visits the data set, training epoch T , we applied the pseudocode in Algorithm 3 over the reduced dimension MDD-DS for 600 principal components (as mentioned, the reason in section VI).According to the curve in Figure 5 accuracy increases when the number of training epochs significantly increase, and remarkably does not increase when applying 600, 700, and 800 and the same for the number of nodes.Therefore, the two loops can stop at 800; number of nodes [300, 400, 500, 600, 700, 800] and training epochs [100, 200, 300, 400, 500, 600, 700, 800].The result of the evaluation shows that the optimal number of nodes is 800 and the number of training epochs is 600 for the three (T op_1, T op_2 and T op_3).

IX. EVALUATION AND RESULTS
For evaluation purposes, we have implemented the approaches using different tools and programming languages: (i) R (Rstudio) to pre-process the data set and then (ii) Matlab and Python to implement machine learning algorithms and deep neural networks.We have analyzed the usual parameters of each algorithm: (i) k and the distance for KNN and FKNN, because these two parameters are the ones that condition the algorithm section VI; and (ii) the number of hidden layers, the number of nodes and the number of epochs for MLP are the three most relevant parameters that condition the algorithm of neural networks section VIII.
In order to evaluate the different approaches, we randomly split the data from the product matrix obtained from the dataset into a training set (≃ 90% of the data) and a testing set (≃ 10% of the data).The evaluation performed on some of the measure parameters, such as accuracy, precision, recall and F 1-score [48] as shown in Equation 9.These parameters are obtained from (i) True Positive (T P ) (when the real value is positive and prediction is positive); (ii) True Negative (T N ) (when the real value is negative and the prediction is negative); (iii) False Positive (F P ) (when the real values is negative but the prediction is positive) and (iv) False Negative (F N ) (when the real value is positive but the prediction is negative).Therefore accuracy is described as the ratio of correctly classified instances, which is the total number of correct predictions divided by the total number of predictions made for a dataset; meanwhile, precision and recall are used to quantify how well the proposed algorithm matches the ground truth.Precision quantifies the number of positive class predictions that actually belong to the positive class.In addition, Recall quantifies the number of positive class predictions made out of all positive examples in the dataset.Finally, the F1-score provides a way to combine both precision and recall into a single measure that captures both properties.We evaluate the performance of our nearest neighbors models over reduced dimension dataset with 400, 500, 600, 700 and 800 principal components.KNN results are shown in Table IX.The results represent the best values for T op_1: 700 principal components with Accuracy (0.8427).The best fit with T op_2 is 600 principal components with Accuracy (0.8874).However, 500 principal components are also suitable for the F1-score (0.8241).In addition to the T op_3, the exact result is 400 principal components with Accuracy (0.9201).On the other hand, 700 principal components are also suitable for the F1-score (0.8263).Regarding FKNN, Table X illustrates that the best fit with T op_1 for FKNN is 800 principal components with accuracy (0.8459).In addition, the best fit with T op_2 is 600 principal components with accuracy (0.9153), also suitable for the F1-score (0.8302).In addition to the T op_3, the best result is 600 principal components with accuracy (0.9413) and F1-score (0.8302).We would like to draw attention to the values of T op_1 results in Table IX and Table X.Both of them are the same, which indicates that recall equals precision and accuracy.This means that the model is somehow "balanced", that is, its ability to correctly classify positive samples (T P +F N ) is the same as its ability to correctly classify negative samples (T N +F P ).Therefore, the F1-score is also the same [48].
Table XI presents the performance of our XGBoost classifier, which was also obtained for the principal components (400, 500, 600, 700 and 800), which declares selecting 400 as the best value for the principal component for T op_1, T op_2 and T op_3; accuracy 0.7071 for T op_1; 0.8126 for T op_2 and 0.8568 for T op_3.
The performance of our MLP classifier was obtained also for 400, 500, 600, 700 and 800 principal components, as it is shown Table XII, which suggests to select 800 as the best value for the principal component for T op_1, T op_2 and T op_3; accuracy 0.8388 for T op_1; 0.8436 for T op_2 and 0.8436 for T op_3.
Additionally, we have assessed the results for the accuracy and the F1-score for the last four algorithms with respect to T op_1, T op_2 and T op_3 on a reduced dimension dataset with 400, 500, 600, 700 and 800 principal components; as show in Figure 7.The FKNN obtains the best accuracy on T op_1, T op_2 and T op_3.The highest accuracy, in T op_1 with the appropriate PCA which is PCA-800 is (84.59%), and in T op_2 and T op_3 with the suitable PCA that's PCA-600 is (91.53%,94.13%), respectively.The best algorithm to obtain the highest result in the F1-score is FKNN in T op_1 with the appropriate principal component which is PCA-800 at the rate of 84.59%, while in T op_2 and T op_3, the best algorithm is MLP with PCA-800 at the rate of 90.46%, 91.09%, respectively.
To sum up, Figure 8 shows the comparison in terms of accuracy among all the models (for their optimal values) regarding T op_1, T op_2 and T op_3.The best in T op_1 is FKNN followed by KNN.As well as, the appropriate one in T op_2, T op_3 is BM25 followed by FKNN.

X. CONCLUSIONS
In this paper, we propose a solution for automatic classification of groceries in a digital transformation scenario, where the availability of quality data is key for retailers and costumers.Besides, food market is a very dynamic context where new products emerge daily, so product catalogs are composed of a huge amount of data that needs constant updates.Within this context, the Spanish company Midiadia provides retailers with quality data about their product catalogs.Midiadia processes the information from the products packaging and labeling to offer relevant knowledge to retailers that eventually supports commercial processes   (offers, customization, etc.).Our main objective is to collaborate with Midiadia to improve the efficiency of one of their internal processes: classification of new products into the ontology the company uses.In particular, we focused on providing an automatic classification mechanism that replaces the manual task of deciding to which Variety (one of the taxonomy levels that is composed of 159 values) a new product belongs.With this aim, we worked with three different alternatives in order to decide the most appropriate: score-based algorithms, machine learning approaches, and deep neural networks.After an intensive work to preprocess the dataset (MDD-DS, composed by 20, 888 products), we applied the following algorithms.First, we define a score-based algorithm based on the probabilistic model BM25, but adapting the formulation to our specific problem of groceries.Then, we applied the KNN, FKNN and XGBoost algorithms, after reducing the data dimensionality with PCA.Finally, we also applied an MLP algorithm using the same PCA mechanism for reducing data dimensionality.
The main objective is providing a totally automatic classification tool that directly offers one result: the most appropriate Variety for a new product (T op_1 option).However, and considering the company benefits, we also studied other two alternatives:  best in T op_1 is FKNN, closely followed by KNN.Although in T op_2 and T op_3 the score-based algorithm performs better, closely followed by FKNN.
We are currently working on the creation of a dictionary of synonyms for ingredients.This need arises because the current regulations allow manufacturers to include different terms for the same element (vitamin C or ascorbic acid, for instance).Additionally, we are working on extending our analysis to other approaches, such as Convolutional Neural Network (CNN), Long Short-Term Memory (LSTM), Deep Bidirectional LSTMs (BILSTM), Bidirectional Encoder Representations from Transformers (BERT) and Support Vector Machine (SVM).Regarding the course of dimensionality, applying DNN with abstract features is a natural next step provided that the issues related with memory consumption during training can be mitigated.After that, we expect to perform a comparison experiment with deep neural networks using additional hidden layers.Besides, the research work already done for the classification problem is the basis of a recommender algorithm to provide product alternatives to the customer when the desired product is not available.With this aim, we are currently working on a multidimensional recommender that takes into account the list of ingredients and other relevant data, such as calories, allergens, healthy aspects, etc. APPENDIX TABLE XIII: Definition of distance measures [31], [49] Cityblock, also known as Manhattan distance, It examines the absolute differences between the opposite values in vectors as shown in Equation 10.
Cosine is a measure of similarity between two nonzero vectors of an internal product space that measures the cosine of the angle between them as shown in Equation 11.
Correlation is a measure of dependency between two paired random vectors of arbitrary dimension, not necessarily equal as shown in Equation 12.
Euclidean is the ordinary straight-line distance between two points in Euclidean space as shown in Equation 13.
Seuclidean, Standardized Euclidean distance.Defined as the Euclidean distance calculated on standardized data as shown in Equation 14.
Jaccard distance measures the difference between sets of samples, it is a complement to the Jaccard similarity coefficient and is obtained by subtracting the Jaccard coefficient from one as shown in Equation 15.
Hamming, the percentage of coordinates that differ as shown in Equation 16.
Chebychev, Maximum coordinate difference as shown in Equation 17.
Spearman's ρ is a nonparametric measure of the statistical dependence of rank correlation between the rankings of two variables.Evaluate how well the relationship between two variables can be described using a monotonic function as shown in Equation 18.
where d = the pairwise distances of the ranks of the variables a i and b i .n = the number of samples.

Fig. 2 :
Fig. 2: Description of the proposed model definition and evaluation.

Fig. 3 :
Fig. 3: Accuracy of KNN and FKNN for the three approaches: T op_1, T op_2 and T op_3

F 1 − 9 )
Score = 2 * P recision * Recall P recision + Recall (Table VIII and Figure6summarizes the performance of our score-based approach, based on the BM25 model.

Fig. 5 :
Fig. 5: Accuracy of MLP for the three approaches: T op_1, T op_2 and T op_3
(i) T op_2 that obtains the 2 most appropriate Varieties for a new product and (ii) T op_3 that obtains the 3 most appropriate Varieties for a new product.Both of them would also help the classification process by turning the problem of classifying a new product within 159 categories into a problem of classifying a new product within 2 or 3 categories.According to our results, the

TABLE I :
Product attributes in the dataset

TABLE II :
Extract of the MDD-DS

TABLE IV :
Extract from all_products_words.

TABLE V :
Example of a product matrix.

TABLE VI :
Example of a variety matrix.

TABLE VII :
Optimal Parameters of KNN, FKNN for each approach.

TABLE VIII :
Score-based Methods: Quality measures

TABLE IX :
KNN: Quality measures by number of PCA components

TABLE X :
FKNN: Quality measures by PCA components

TABLE XI :
XGBoost: Quality measures by PCA components

TABLE XII :
MLP: Quality measures by PCA components