diff --git a/doc/References.bib b/doc/References.bib index 487cef6..b22da4c 100644 --- a/doc/References.bib +++ b/doc/References.bib @@ -138,7 +138,8 @@ @online{wikiapi, year = {2023}, title = {Wikipedia API documentation}, - url = {https://wikipedia-api.readthedocs.io/en/latest/wikipediaapi/api.html} + url = {https://wikipedia-api.readthedocs.io/en/latest/wikipediaapi/api.html}, + urldate = {2023-06-02} } @@ -149,7 +150,7 @@ title = {{Wikipedia special exports}}, howpublished = {\url{https://en.wikipedia.org/wiki/Special:Export}}, year = {2023}, - note = {[Online; accessed 01-May-2023]} + urldate = {2023-05-01} } @@ -510,3 +511,29 @@ urldate = {2023-08-05}, } +@online{RM, + author = {Retromotion.com}, + title = {Spare parts shop}, + url = {https://retromotion.com/p/vaico-v70-0613}, +urldate = {2023-08-05}, + year = {2023} +} + +@online{iceclog, + author = {Martijn Hoogeveen}, + title = {What is Product Information Management (PIM) in a Multimedia World?}, + url = {https://iceclog.com/what-is-product-information-management-in-a-multimedia-world/}, +urldate = {2023-08-09}, + year = {2019} +} + + +@online{savept, + author = {Matthew Inkawhich}, + title = {SAVING AND LOADING MODELS}, + url = {https://pytorch.org/tutorials/beginner/saving_loading_models.html}, +urldate = {2023-08-09}, + year = {2023} +} + + diff --git a/doc/chapters/appendix.tex b/doc/chapters/appendix.tex index e2851a3..29467d3 100644 --- a/doc/chapters/appendix.tex +++ b/doc/chapters/appendix.tex @@ -18,7 +18,65 @@ For this project, python client elasticsearch 6.8.2 is installed as the client n \end{lstlisting} % Content for Appendix A goes here... +\subsection*{Confusion matrix} +\begin{lstlisting}[language=Python,caption={Confusion matrix},label={code:confusion matrix}] +def confusionMatix(self,df_en): +# Keep track of correct guesses in a confusion matrix +data = Data(df_en) +n_categories = len(data.all_category) + +batch = random.choices(data.all_category,k=20) + +confusion = torch.zeros(n_categories, n_categories) +n_confusion = 10000 + +# Go through a bunch of examples and record which are correctly guessed +for i in range(n_confusion): + category, name, category_tensor, name_tensor = data.randomTrainingExample() + if category in batch: + output = self.evaluate(name_tensor) + guess, guess_i = data.categoryFromOutput(output) + category_i =data.all_category.index(category) + confusion[category_i][guess_i] += 1 + +# Normalize by dividing every row by its sum +for i in range(20): + confusion[i] = confusion[i] / confusion[i].sum() + + +# Set up plot +fig = plt.figure() +ax = fig.add_subplot(111) +cax = ax.matshow(confusion.numpy()) +fig.colorbar(cax) + +# Set up axes +ax.set_xticklabels([''] + data.all_category, rotation=45) +ax.set_yticklabels([''] + data.all_category) + +# Force label at every tick +ax.xaxis.set_major_locator(ticker.MultipleLocator(1)) +ax.yaxis.set_major_locator(ticker.MultipleLocator(1)) + +# sphinx_gallery_thumbnail_number = 2 +plt.show() +plt.savefig('confusion.png', dpi=400) + +\end{lstlisting} + +\subsection*{Load PyTorch model} +\begin{lstlisting}[language=Python,caption={Load PyTorch model},label={code:Loadpt}] +class Predict(): + def __init__(self): + self.rnn = torch.load('ngram-rnn-classification.pt') + \end{lstlisting} + \section{Appendix B} -% Content for Appendix B goes here... +\begin{figure} + \centering + \includegraphics[scale=0.5]{ht_rm.jpg} + \caption{Hydraulic filter automatic transmission VAICO V70-0613 for Lexus RX \parencite{RM}} + \label{fig:sparepart} +\end{figure} \end{appendices} diff --git a/doc/chapters/conclusion.tex b/doc/chapters/conclusion.tex index 2319652..98eb27f 100644 --- a/doc/chapters/conclusion.tex +++ b/doc/chapters/conclusion.tex @@ -54,20 +54,26 @@ There is a scope of research on image classification and its use cases in the E-commerce industry. Images are vital component of an E-commerce website. There is saying ``A picture is worth a thousand words''. The product image itself has so much information to be tapped. + Few of them are listed below: \begin{itemize} \item Image captioning. - Generating text based on image, describing its features such as color. + Generating text from the image is a useful process in E-commerce. For example, product image also describes its features such as color. Such information can be added to the caption of the image. \parencite[Section 15.4.7]{pml1Book} describes an example of image captioning using the sequential data processing network with \textbf{attention algorithm}. + \item Attention based image classification. + + \parencite{Vaswani.12062017} proposes a network architecture named Transformers which uses attention in the encoder and decoder in the machine translation tasks. Using the transformer model to process the sequence of pixels in a product image to identify the clustered components or to identify which other product could be a part of the product. + For example, image from Appendix B figure \ref{fig:sparepart} is product image, using attention based image classification, identifying the products which fit in and around the processed product image could enable E-Commerce industries cluster the products. + + + \item Image based categorization. A Machine learning model can generate product taxonomy based on the image of the product. Clustering the products based on the image could also enable to define a better product taxonomy. \item Image to image translation. - Using \acfp{GAN} \parencite{Goodfellow.31122016}, a sketch can be converted to photorealistic image. - - + Using \acfp{GAN} \parencite{Goodfellow.31122016}, a sketch can be converted to photorealistic image. \end{itemize} \ No newline at end of file diff --git a/doc/chapters/literature-review.tex b/doc/chapters/literature-review.tex index 61fd1e9..225759c 100644 --- a/doc/chapters/literature-review.tex +++ b/doc/chapters/literature-review.tex @@ -70,6 +70,55 @@ In figure \ref{fig:sample-product-taxonomy}, is a sample of product taxonomy rep \end{enumerate} +\section{\acf{PIM}} +\acl{PIM} system is an information system that facilitates the manufactures and distribution channel such as an e-commerce website with a central hub of product data \parencite{iceclog}. \acs{PIM} system manages products details such name, description, manufacturer, price as well as the products' taxonomy. A PIM system may also include the \acf{SKU}. \acsp{SKU} enables the distribution channels to determine which product require reordering and also provides sales data. Distribution channels may also have an extended version of the \acs{SKU} than the one provided by the suppliers. + +\acsp{PIM} are the point of source to verify whether the products' taxonomy are correct and also if the stock is available before distribution channels make it publically available for sales. + + +% \begin{tikzpicture}[ +% node distance=1cm, +% every node/.style={font=\footnotesize}, +% arrow/.style={->,>=Stealth}, +% process/.style={rectangle, draw, text centered, minimum width=2.5cm, text width=2.5cm}, +% decision/.style={diamond, draw, text centered, aspect=2}, +% arrowlabel/.style={midway, above, font=\scriptsize}, +% ] +% % Define nodes +% \node (dc) [process] {Distribution Channels}; +% \node (dp) [process, below=3cm of dc] {Available for Sale}; +% \node (ms) [process, right=6cm of dc] {Source}; +% \node (pim) [process, right=3cm of dc, yshift=-1.5cm] {PIM System}; +% \node (check) [decision, below=of dc] {Verify}; + +% % Define arrows and labels +% \draw [arrow] (dc) -- (check); +% \draw [arrow] (check) -- node[arrowlabel] {Yes} (dp); +% \draw [arrow] (check.east) -- node[anchor=south] {No} ++(1.5,0) |- ($(pim.west) + (0,0.5)$) -- (pim.west); +% \draw [arrow] (ms) -- (pim.east) ; +% \draw [arrow] (pim.north) -- (dc.east); +% \end{tikzpicture} + + +% \begin{itemize} +% \item Getting updated lists of products from suppliers. +% \begin{itemize} +% \item What is the current method to get the updates? +% \item In which cycle do these updates occur? Is it the same cycle for every supplier or is it individual? +% \end{itemize} +% \item Best way to activate / deactive products. +% \begin{itemize} +% \item Would it make sense to have article level toggles in the interface that will (de)activate a product from the Reorder? + +% \item Would a standardised document import be a better solution? +% \end{itemize} +% \end{itemize} + + + + + + \section{Product Taxonomy Prediction Approaches} diff --git a/doc/chapters/math-behind.tex b/doc/chapters/math-behind.tex index e9437b4..bd4fd00 100644 --- a/doc/chapters/math-behind.tex +++ b/doc/chapters/math-behind.tex @@ -283,7 +283,7 @@ Substituting \(a = \exp(x_i)\) and \(b = \sum_{j=1}^n \exp(x_j)\) in equation \e \section{ \acs*{RNN} - Forward and Backward Propagation} \label{sec:math-rnn} -When a feedforward neural network are extended to include feedback connections, they are called \acfp{RNN} \parencite[Chapter 6, Page 164]{Goodfellow-et-al-2016}. \acfp{RNN} is best suited for machine learning problems that involve sequential data and use patterns to predict the output. A recurrent neural network is specialized for processing sequence of values $ x^{(1)},\ldots,x^{(t)}$. +When a feedforward neural network are extended to include feedback connections, they are called \acfp{RNN} \parencite[Chapter 6, Page 164]{Goodfellow-et-al-2016}. \acfp{RNN} is best suited for machine learning problems that involve sequential data such as sequence translation, generation and classification. A recurrent neural network is specialized for processing sequence of values $ x^{(1)},\ldots,x^{(t)}$. The prediction of output $y^t$ also depends on the hidden state of the system $h^t$, which gets updated overtime as the sequence is processed \parencite[Chapter 15, Page 501]{pml1Book}. \begin{figure}[H] \centering diff --git a/doc/chapters/training-hypertuning.tex b/doc/chapters/training-hypertuning.tex index 6b619be..a2a656a 100644 --- a/doc/chapters/training-hypertuning.tex +++ b/doc/chapters/training-hypertuning.tex @@ -484,6 +484,24 @@ In this experiment, the model is trained with and without triangular learning ra \end{enumerate} +\section{Model Evaluation} + +The model is evaluated using the confusion matrix. Confusion matrix is square matrix of predicted label $y_{pred}$ verses the true target label $y_{true}$. +Figure \ref{fig:meval} is the confusion matrix of the model trained only for 20 categories. The actual model is trained to predict around 300 categories. Author choose to attach the miniature version of the confusion matrix. Refer Appendix A code \ref{code:confusion matrix} for the python code to generate a confusion matrix. + +\begin{figure}[H] + \centering + \includegraphics[scale=0.5]{confusion._200epoch.png} + \caption{Confusion matrix: with little training. + } + \label{fig:meval} +\end{figure} + +\section{Model Deployment} + +A \textbf{.pt} file represents the PyTorch model checkpoint file. These files store the parameter and architecture of trained PyTorch model. The PyTorch's torch.save and torch.load function uses the pythons Pickle (refer section \ref{sec:ngram_vector}) utility for serialization \parencite{savept}. + +As the \acl{PIM} systems get updated with the latest details of product information, the model requires retraining for accurate prediction. Refer Appendix A code \ref{code:Loadpt} for Python code to load the trained PyTorch model. \section{Summary} diff --git a/doc/images/ht_rm.jpg b/doc/images/ht_rm.jpg new file mode 100644 index 0000000..bfd2d74 Binary files /dev/null and b/doc/images/ht_rm.jpg differ diff --git a/doc/images/ht_rm.jpg:Zone.Identifier b/doc/images/ht_rm.jpg:Zone.Identifier new file mode 100644 index 0000000..9c304ce --- /dev/null +++ b/doc/images/ht_rm.jpg:Zone.Identifier @@ -0,0 +1,4 @@ +[ZoneTransfer] +ZoneId=3 +ReferrerUrl=https://retromotion.com/p/vaico-v70-0613 +HostUrl=https://retromotion.com/img/productDetail/resize/custom/83f38f06a1681a3907bf32742412706875708ab8653b354afbc917fecbb64e15.jpg diff --git a/doc/index.tex b/doc/index.tex index e89a5d3..bc9475a 100644 --- a/doc/index.tex +++ b/doc/index.tex @@ -10,7 +10,7 @@ \usepackage{float} \usepackage{fancyhdr} \usepackage[nohyperlinks, printonlyused, withpage, smaller]{acronym} -\usepackage[backend=biber, sorting=nyt, style=ext-authoryear-icomp,dashed=false,block=par]{biblatex} +\usepackage[backend=biber, sorting=nyt, style=ext-authoryear-comp,dashed=false,block=par]{biblatex} \usepackage[inkscapeformat=png]{svg} \usepackage{booktabs,multirow,array} \usepackage{listings} @@ -25,7 +25,7 @@ \usepackage{mathrsfs} -\usetikzlibrary{shapes,arrows,positioning,arrows.meta} +\usetikzlibrary{shapes,arrows,positioning,arrows.meta,calc} \captionsetup[table]{skip=5pt} % Customize list of figures appearance in table of contents @@ -213,7 +213,7 @@ chapters/appendix% \addcontentsline{toc}{chapter}{Bibliography} - +\nocite{*} \printbibliography[title={References}] diff --git a/doc/preliminary/acronyms.tex b/doc/preliminary/acronyms.tex index 1104d5d..1848cc6 100644 --- a/doc/preliminary/acronyms.tex +++ b/doc/preliminary/acronyms.tex @@ -40,6 +40,8 @@ \acro{PMF}[PMF]{Probability Mass Function } \acro{MSE}[MSE]{Mean Squared Error} \acro{GAN}[GAN]{generative adversarial network} +\acro{PIM}[PIM]{Product Information Management} +\acro{SKU}[SKU]{stock-keeping unit} \end{acronym}