From 901257db17c61c80e2fb80edec260022de55e4dc Mon Sep 17 00:00:00 2001 From: "shoney.arickathil" Date: Fri, 28 Jul 2023 09:27:41 +0200 Subject: [PATCH] doc --- doc/chapters/chapter4.tex | 15 +++--- doc/chapters/chapter5.tex | 95 +++++++++++++++++++++++------------ doc/chapters/chapter_new1.tex | 39 ++++++++++++++ 3 files changed, 112 insertions(+), 37 deletions(-) create mode 100644 doc/chapters/chapter_new1.tex diff --git a/doc/chapters/chapter4.tex b/doc/chapters/chapter4.tex index 8a2a04d..993005b 100644 --- a/doc/chapters/chapter4.tex +++ b/doc/chapters/chapter4.tex @@ -3,7 +3,7 @@ Machine leaning algorithms requires that their inputs have no missing values. Missing values encoded as NaNs or blanks are incompatible with estimators which represents as the numerical values and assumes all values have and hold meaning. Discarding the entire row and/or columns of a dataset containing the missing values could lead to losing valuable data. The process to fill (impute) missing values are referred to as imputation. -\section{Feature imputation / Regression imputation / Predictive Imputation} +\section{Feature imputation / Regression imputation or \\ Predictive Imputation} Machine learning algorithm to predict values in a categorical variable based on other available features. Table \ref{table:feature_imputation} states the categorical features from the all the features mentioned in \ref{table:feature_decription}. @@ -48,12 +48,15 @@ Mode imputation on categorical data are prone to fill incorrect data if the miss \section{\acf{KNN} imputation} -\acl{KNN} is a supervised learning algorithm is used to search dataset with the most similar elements to a given query element, with similarity defined by a distance function. This imputation method is suitable for categorical data. +\acl{KNN} is a supervised learning algorithm and is used to search dataset with the most similar elements to a given query element, with similarity defined by a distance function. This imputation method is suitable for categorical data. -The most common distance functions are:- +The most common distance metrics functions are:- \begin{enumerate} - \item Eulidean distance. + \item Euclidean distance. + % \begin{lstlisting}[language=Python, caption={Euclidean distance formula }] + % dist(x, y) = sqrt(dot(x, x) - 2 * dot(x, y) + dot(y, y)) + % \end{lstlisting} \item Manhattan distance. \item Hamming distance. \end{enumerate} @@ -78,13 +81,13 @@ The \textit{k}-neighbors classification implements learning based on \textit{k} \subsection{\acs{KNN} model implementation} In table \ref{table:KNN_implementation} there are 7 columns. Target column is \textbf{Category-Level-3} which is the category at level three. -As per the sample category hierarchy, the +As per the example category hierarchy in table \ref{table:KNN_implementation} \begin{table}[h] \centering - \caption{Data frame head} + \caption{Sample features } \label{table:KNN_implementation} \begin{tabular}{ll} \toprule diff --git a/doc/chapters/chapter5.tex b/doc/chapters/chapter5.tex index 34e10f3..334def0 100644 --- a/doc/chapters/chapter5.tex +++ b/doc/chapters/chapter5.tex @@ -1,39 +1,72 @@ -\chapter{Development environment and hardware setup} +\chapter{Feature extraction} -\section {Ubuntu server 20.04 configuration} +Transforming text or image data into numerical representation usable for machine learning is called feature extraction. Raw sequence of data cannot be fed directly into a machine learning algorithm as they expect data in numerical vector and in fixed size. Whereas raw text document are of variable lengths. -\section {Python virtual environment} \label {pyenv} +\section{Tokenization} -pyenv facilitaes to isolate python version dependent source codes and avoid version conflicts. A virtual environment will install packages to a specific python module instad of installing globally. Asuming the directrory root directory name is "dev", follow linux bash code to activate virtual environment. -The bash script below will create and activate virtual environment and all the packages will be installed within the venv directory -\begin{lstlisting}[language=bash] - pyenv install 3.10 / - cd ~/dev / - pyenv local 3.10 / - python -m venv .venv / - source .venv/bin/activate +Tokenization is splitting the text in sequential words which can be embedded in a vector space. +For example, the normalized product name "abc joint kit drive shaft" can be tokenized into "abc", "joint", "kit", "drive", "shaft". + + +\section{Counting} + +Number of occurrence of each token in a document is called counting in terms of numerical feature extraction. + +\section{Count Vectorization or One-Hot encoding} + + +CountVectorizer class of scikit learn API implements both tokenization and occurrence counting \parencite{sklearn_api}. + +Consider a data frame with columns \textit{ProductName} and data value as in tbale \ref{table:count_vectorization} + +\begin{table}[h] + \centering + \caption{Sample data for count vectorization} + \label{table:count_vectorization} + \begin{tabular}{ l } + \toprule + + \textbf{ProductName}\\ + \midrule + abc joint kit drive shaft\\ + xyz joint kit drive shaft\\ + + \bottomrule + \end{tabular} +\end{table} + +The length of the vocabulary is the number of unique tokens in the data frame column. In the sample data the vocabulary length is six. The vector has the dimensionality equal to the size of the vocabulary. Adding one in the dimension to each of the word in the vocabulary represents one hot encoding. + +\begin{table}[h] + \centering + \caption{One hot encoding} + \label{table:countencode} + \begin{tabular}{ ll } + \toprule + + \textbf{text}& \textbf{encoding}\\ + \midrule + abc&[1,0,0,0,0,0]\\ + joint&[0,1,0,0,0,0]\\ + kit&[0,0,1,0,0,0]\\ + drive&[0,0,0,1,0,0]\\ + shaft&[0,0,0,0,1,0]\\ + xyz&[0,0,0,0,0,1]\\ + + \bottomrule + \end{tabular} +\end{table} + +\section{ \textit{n-grams} Vectorization} + +Count Vectorization can also be performed on range of grams of words. + +\begin{lstlisting}[language=Python,label=ngramcode, caption={\textit{n-gram} vectorization}] + bigram_vectorizer = CountVectorizer(ngram_range=(1, 2)) + bigram_vectorizer.fit(df["ProductName"]) \end{lstlisting} -Compatible python clients to interact with project dependent module installation can be installed by specifying the version range. -Python Elastic search client's official low version installation details are mentioned on elasticsearch-py \footnote{https://elasticsearch-py.readthedocs.io/en/6.8.2/} website. -vGPU \footnote{https://docs.nvidia.com/grid/5.0/grid-vgpu-user-guide/index.html} - -\begin{lstlisting}[language=Python] - python -m pip install "elasticsearch>=6.4.0,<7.0.0" -\end{lstlisting} - -\section {Docker containers - CouchDB, Elastic search, Redis} - -\section {Hyper-v virtualization and networking} - -\subsection{vGPU installation} - -\subsection{Networking} - -\subsection{SSH} - - -\section{Cloud computing} +The code in listing \ref{ngramcode}, will add additional vocabularies of two words such as "drive shaft". This enables to preserve local ordering information. diff --git a/doc/chapters/chapter_new1.tex b/doc/chapters/chapter_new1.tex new file mode 100644 index 0000000..34e10f3 --- /dev/null +++ b/doc/chapters/chapter_new1.tex @@ -0,0 +1,39 @@ +\chapter{Development environment and hardware setup} + +\section {Ubuntu server 20.04 configuration} + +\section {Python virtual environment} \label {pyenv} + +pyenv facilitaes to isolate python version dependent source codes and avoid version conflicts. A virtual environment will install packages to a specific python module instad of installing globally. Asuming the directrory root directory name is "dev", follow linux bash code to activate virtual environment. +The bash script below will create and activate virtual environment and all the packages will be installed within the venv directory +\begin{lstlisting}[language=bash] + pyenv install 3.10 / + cd ~/dev / + pyenv local 3.10 / + python -m venv .venv / + source .venv/bin/activate + +\end{lstlisting} + +Compatible python clients to interact with project dependent module installation can be installed by specifying the version range. +Python Elastic search client's official low version installation details are mentioned on elasticsearch-py \footnote{https://elasticsearch-py.readthedocs.io/en/6.8.2/} website. + +vGPU \footnote{https://docs.nvidia.com/grid/5.0/grid-vgpu-user-guide/index.html} + +\begin{lstlisting}[language=Python] + python -m pip install "elasticsearch>=6.4.0,<7.0.0" +\end{lstlisting} + +\section {Docker containers - CouchDB, Elastic search, Redis} + +\section {Hyper-v virtualization and networking} + +\subsection{vGPU installation} + +\subsection{Networking} + +\subsection{SSH} + + +\section{Cloud computing} +