From fb614d55b6c5e81a08cc967efc78e0d31cdde808 Mon Sep 17 00:00:00 2001 From: "shoney.arickathil" Date: Wed, 13 Sep 2023 02:48:01 +0200 Subject: [PATCH] doc --- doc/References.bib | 10 +++- doc/chapters/data-preprocessing.tex | 4 ++ doc/chapters/literature-review.tex | 71 +++++++++++++++++++---------- doc/chapters/math-behind.tex | 37 +++++++++++++++ doc/chapters/model-selection.tex | 13 ------ doc/index.tex | 5 +- doc/preliminary/acronyms.tex | 3 +- 7 files changed, 104 insertions(+), 39 deletions(-) create mode 100644 doc/chapters/math-behind.tex diff --git a/doc/References.bib b/doc/References.bib index 5a96866..b1c8a02 100644 --- a/doc/References.bib +++ b/doc/References.bib @@ -466,7 +466,15 @@ number = {MSR-TR-2010-82}, author = {Chris Messina}, title = {Conversational commerce, Messaging apps bring the point of sale to you}, url = {https://medium.com/chris-messina/conversational-commerce-92e0bccfc3ff}, - urldate = {Date Accessed}, + urldate = {10-05-2023}, year = {2015} } +@online{BonnieMa, + author = {Bonnie Ma}, + title = {Feature Transformation for Multiple Linear Regression in Python}, + url = {https://towardsdatascience.com/feature-transformation-for-multiple-linear-regression-in-python-8648ddf070b8}, +urldate = {10-05-2023}, + year = {2019} +} + diff --git a/doc/chapters/data-preprocessing.tex b/doc/chapters/data-preprocessing.tex index c3aadf6..22223ab 100644 --- a/doc/chapters/data-preprocessing.tex +++ b/doc/chapters/data-preprocessing.tex @@ -356,7 +356,11 @@ Pandas.DataFrame.median \parencite{mckinney-proc-scipy-2010} returns the median df = df.fillna(df.median().iloc[0]) \end{lstlisting} +\section{Log transformation of data} +Log transformation is a mathematical operation applied on data to change its scale and to reduce its skewness and to make data more symmetric. Skewness is a measure of the asymmetry of a distribution, and a right-skewed distribution has a long tail on the right side of the distribution \parencite{BonnieMa}. + +The numpy library provides natural logarithmic function to apply log transformation on array of data. \section{Feature extraction} \label{ch:feature-extraction} diff --git a/doc/chapters/literature-review.tex b/doc/chapters/literature-review.tex index 59fdcb6..95fd154 100644 --- a/doc/chapters/literature-review.tex +++ b/doc/chapters/literature-review.tex @@ -100,6 +100,54 @@ A lot of research have been conducted on methodology for predicting taxonomy. Pr \end{itemize} + + +\section{Supervised Learning} + +The machine learning model built using existing dataset is called supervised learning. ´Figure \ref{fig:sup learinig workflow} illustrates the supervised learning workflow. In this paper, author builds a supervised learning model to predict the product taxonomies. The work flow starts with data collection, this steps involves fetching the corpus of raw data. This raw data processed before creating a training data set out of it. The data preprocessing steps involves feature selection, text normalization, data imputation and feature extraction. The training data is passed an input to the model which compares its results with the actual value to self evaluate and learn. If any hyperparameter tuning for the machine learning model is required then it is trained again with new parameters. The model is then evaluated and then deployed for production use. + +\begin{figure}[H] + \centering + \begin{tikzpicture}[ + node distance=1cm, + every node/.style={font=\footnotesize}, + arrow/.style={->,>=Stealth}, + process/.style={rectangle, draw, text centered, minimum width=2.5cm}, + data/.style={rectangle, draw, text centered, text width=2.5cm}, + decision/.style={diamond, draw, text centered, aspect=2}, + arrowlabel/.style={midway, above, font=\scriptsize}, + ] + % Nodes + \node (start) [process] {Data Collection}; + \node (data) [data, below=of start] {Data Preprocessing}; + \node (split) [process, below=of data] {Training dataset}; + \node (model) [process, below=of split] {Initial Model}; + \node (train) [process, below=of model] {Train Model}; + \node (evaluate) [process, below=of train] {Evaluate Model}; + \node (deploy) [process, below=of evaluate] {Deploy Model}; + + + % Arrows + \draw [arrow] (start) -- (data); + \draw [arrow] (data) -- (split); + \draw [arrow] (split) -- (model); + \draw [arrow] (model) -- (train); + \draw [arrow] (train) -- (evaluate); + \draw [arrow] (evaluate) -- (deploy); + + + % Decision point + \node (decision) [decision, right=of model, xshift=1cm] {Tune Model?}; + \draw [arrow] (model) -- (decision); + \coordinate[right=of decision] (temp); + \draw [arrow] (decision) -| node[arrowlabel] {Yes} (temp) |- (train); + \draw [arrow] (decision) |- node[arrowlabel] {No} (evaluate); + \end{tikzpicture} + \caption{Supervised Learning Workflow} + \label{fig:sup learinig workflow} +\end{figure} + + \section{Related Works} \parencite{AliCevahir.} describes implementing classification model by chunking the process to predict at every level using the \acl*{KNN} classifier. \parencite{Gupta.20062016} proposes a distributional semantics representation for predicting the product taxonomies. @@ -143,27 +191,4 @@ Learning to rank is a machine learning algorithm for \acf{IR}. The application o One of the use case of conversational commerce is in the reverse logistics- return and exchange. For example, if the user has ordered and wrong product and would like to return it while being on the go. He may use the chatbot assistance and type "I want to return." The chatbot lists the delivered products list and customer selects the product to be returned. -% \begin{figure} -% \centering -% \begin{tikzpicture}[node distance=2.5cm, auto, -% rect/.style={rectangle, draw, text centered}, -% ellipse/.style={ellipse, draw, text centered} -% ] -% % Nodes -% \node [rect] (user) {User}; -% \node [ellipse, below of=user] (order) {Order Wrong Product}; -% \node [rect, below of=order] (chatbot) {Chatbot}; -% \node [rect, below of=chatbot] (list) {List Delivered Products}; -% \node [rect, below of=list] (select) {Select Product to Return}; - -% % Arrows -% \draw [->] (user) -- (order); -% \draw [->] (order) -- (chatbot); -% \draw [->] (chatbot) -- (list); -% \draw [->] (list) -- (select); - -% \end{tikzpicture} -% \caption{Process of Returning a Wrong Product Using Chatbot} -% \end{figure} - Application of knowledge graphs within the e-commerce industry involves the creation of network of information concerning the products. This knowledge graph can serve as the basis for chatbots to provide answers to user queries. \ No newline at end of file diff --git a/doc/chapters/math-behind.tex b/doc/chapters/math-behind.tex new file mode 100644 index 0000000..3167710 --- /dev/null +++ b/doc/chapters/math-behind.tex @@ -0,0 +1,37 @@ +\chapter{Mathematical Foundations of Classification Model} + + + +\section{Probability Distribution} + +A probability distribution is the information of how likely a random variable or set of variables is to take each of its possible states. The way the probability distribution is described depended on whether the variables are discrete (finite set of variables) or continuous \parencite[Page 54]{Goodfellow-et-al-2016}. + +In this paper, the finite number of categories to be predicted indicate that the probability distribution variable is of discrete type. The probability that variable $X = x$ is denoted by $ P(x) $, with a probability of 1 indicating that $x-x$ is certain and probability of 0 indicating an impossible event \parencite[Page 55]{Goodfellow-et-al-2016}. + + +The probability values ranging between 0 and 1 are called \acf{PMF} denoted as $ P $. To ensure that \acs*{PMF} provides valid probabilities the function $P$ must satisfy following propertise. + + +\begin{itemize} + \item Domain of PMF must be defined for all possible states of random variable $x$. It should specify probabilities for each value $x$. For example, of the variable of vector representation of product name ``X'' the $P$ must be defined for all categories. + \item The $ P(x) $ must satisfy $0 \leq P(x) \leq 1$. + \item Impossible events have probability 0. + \item Certain events have probability 1. + \item Normalization property indicating sum of all probabilities equals to 1. +\end{itemize} + + +\begin{table}[H] + \centering + \begin{tabular}{ccccccc} + \hline + $x$ & $x_1$ & $x_2$ & $x_3$ & $\dots$ & $x_n$ \\ + \hline + $P(x)$ & $P_1$ & $P_2$ & $P_3$ & $\dots$ & $P_n$ \\ + \hline + \end{tabular} + \caption{Probability Distribution $P(x)$ for Random Variable $x$} + \label{tab:probability-distribution} +\end{table} + +where \(P_i > 0\), \(i=1\) to \(n\) and \(P_1 + P_2 + P_3 + \ldots + P_n =1\) \\ \ No newline at end of file diff --git a/doc/chapters/model-selection.tex b/doc/chapters/model-selection.tex index 8b1e91a..7cbbd04 100644 --- a/doc/chapters/model-selection.tex +++ b/doc/chapters/model-selection.tex @@ -230,20 +230,7 @@ Pytorch's nn.LogSoftmax function applies $\text{log}\left(\text{Softmax}(\mathbf Pytorch's nn.Softmax applies the Softmax function to an n-dimensional input Tensor rescaling them so that the elements of the n-dimensional output Tensor lie in the range [0,1] and sum to 1. -\begin{table}[h] - \centering - \begin{tabular}{ccccccc} - \hline - $X$ & $X_1$ & $X_2$ & $X_3$ & $\dots$ & $X_n$ \\ - \hline - $P(X)$ & $P_1$ & $P_2$ & $P_3$ & $\dots$ & $P_n$ \\ - \hline - \end{tabular} - \caption{Probability Distribution $P(X)$ for Random Variable $X$} - \label{tab:probability-distribution} -\end{table} -where \(P_i > 0\), \(i=1\) to \(n\) and \(P_1 + P_2 + P_3 + \ldots + P_n = 1\) \\ \begin{align} diff --git a/doc/index.tex b/doc/index.tex index 2ea70d3..674b6fa 100644 --- a/doc/index.tex +++ b/doc/index.tex @@ -22,7 +22,7 @@ \usepackage{enumitem} \usepackage{appendix} -\usetikzlibrary{shapes,arrows,positioning} +\usetikzlibrary{shapes,arrows,positioning,arrows.meta} \captionsetup[table]{skip=5pt} % Customize list of figures appearance in table of contents @@ -97,6 +97,7 @@ chapters/literature-review, % chapters/data-preprocessing, % chapters/model-selection, % chapters/training-hypertuning, % +chapters/math-behind, % chapters/building-kg, % chapters/conclusion, % chapters/appendix% @@ -130,7 +131,9 @@ chapters/appendix% \include{chapters/data-preprocessing} \include{chapters/model-selection} \include{chapters/training-hypertuning} +\include{chapters/math-behind} \include{chapters/building-kg} + \include{chapters/conclusion} \pagenumbering{roman} diff --git a/doc/preliminary/acronyms.tex b/doc/preliminary/acronyms.tex index 59c5326..45d4b07 100644 --- a/doc/preliminary/acronyms.tex +++ b/doc/preliminary/acronyms.tex @@ -36,6 +36,7 @@ \acro{CLR}[CLR]{Cyclic learning rate } \acro{LTR}[LTR]{Learn to Rank } \acro{IR}[IR]{Information Retrieval } -\acro{AI}[AI]{Artificial Intelligence } + +\acro{PMF}[PMF]{Probability Mass Function } \end{acronym}