update doc

This commit is contained in:
shoney.arickathil 2023-07-16 02:06:29 +02:00
parent 86399459ed
commit d2925a3d0c
6 changed files with 42 additions and 28 deletions

View file

@ -19,7 +19,7 @@ In table \ref{table:TN}, displays the difference in text before and after normal
\end{tabular} \end{tabular}
\end{table} \end{table}
\subsection{Lower case} \section{Lower case}
Using Pandas - vectorized string method, a text can be lower cased across the document. These methos exclude the missing / NA values automatically \parencite{mckinney-proc-scipy-2010}. Using Pandas - vectorized string method, a text can be lower cased across the document. These methos exclude the missing / NA values automatically \parencite{mckinney-proc-scipy-2010}.
@ -27,7 +27,7 @@ Using Pandas - vectorized string method, a text can be lower cased across the do
df_de["name"]= df_de["name"].str.lower() df_de["name"]= df_de["name"].str.lower()
\end{lstlisting} \end{lstlisting}
\subsection{Html parsing} \section{Html parsing}
Probability of getting html tags in a document increases if the source of document is from web scraping or also if the document from database source has inline html tags. In such case, fetching normal texts from a html text is required. One of the method would be to use regular expressions to get text in between angel brackets \textless \textgreater text \textless \textgreater. However, this method would require to have the tags to be well formed. Probability of getting html tags in a document increases if the source of document is from web scraping or also if the document from database source has inline html tags. In such case, fetching normal texts from a html text is required. One of the method would be to use regular expressions to get text in between angel brackets \textless \textgreater text \textless \textgreater. However, this method would require to have the tags to be well formed.
\begin{lstlisting}[language=Python] \begin{lstlisting}[language=Python]
@ -43,8 +43,7 @@ The better option would be to use Beautiful Soup \footnote{https://www.crummy.co
text =soup.get_text() text =soup.get_text()
\end{lstlisting} \end{lstlisting}
\subsection{Cleanning text} \section{Cleanning text}
A product detail text may contain non-word characters represented in regular expression as \textbackslash W. It may also contain space seperated decimals describing the dimentional values of the product such as weight, height. Regular expressions could be used for removing the non-character words and spaces between the decimal values. A product detail text may contain non-word characters represented in regular expression as \textbackslash W. It may also contain space seperated decimals describing the dimentional values of the product such as weight, height. Regular expressions could be used for removing the non-character words and spaces between the decimal values.
\begin{lstlisting}[language=Python] \begin{lstlisting}[language=Python]
@ -52,7 +51,7 @@ A product detail text may contain non-word characters represented in regular exp
text = (re.sub('(?<=\d) (?=\d)', '', text)) text = (re.sub('(?<=\d) (?=\d)', '', text))
\end{lstlisting} \end{lstlisting}
\subsection{Normal form D - Unicode database} \section{Normal form D - Unicode database}
A product name in Deutsch language may contain umlaute characters such as \"A. Pythons unicodedata \footnote{https://docs.python.org/3/library/unicodedata.html} module provides access to the Unicode Character Database (UCD) which defines the character properties for all Unicode characters. To change \"A to A, the Normal form D (NFD) should be applied which translated each character into its decomposed form. Further the text can be refined with the general category assigned to the character as string. Nonspacing mark characters \footnote{https://www.compart.com/en/unicode/category/Mn} are represented as "Mn". These characters could be removed by referring the the character category. A product name in Deutsch language may contain umlaute characters such as \"A. Pythons unicodedata \footnote{https://docs.python.org/3/library/unicodedata.html} module provides access to the Unicode Character Database (UCD) which defines the character properties for all Unicode characters. To change \"A to A, the Normal form D (NFD) should be applied which translated each character into its decomposed form. Further the text can be refined with the general category assigned to the character as string. Nonspacing mark characters \footnote{https://www.compart.com/en/unicode/category/Mn} are represented as "Mn". These characters could be removed by referring the the character category.
\begin{lstlisting}[language=Python] \begin{lstlisting}[language=Python]

View file

@ -48,7 +48,7 @@ Mode imputation on categorical data are prone to fill incorrect data if the miss
\section{\textit{k}-Nearest Neighbors imputation} \section{\textit{k}-Nearest Neighbors imputation}
k-Nearest Neighbor 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. k-Nearest Neighbor 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.
The most common distance functions are:- The most common distance functions are:-
@ -79,31 +79,33 @@ As per \parencite{scikit-learn}, larger \textit{k} suppresses the effects of noi
\subsection{KNN model implementation} \subsection{KNN model implementation}
In table \ref{table:KNN_implementation} there are nine columns. Target column is 'catL3' which is the category at level three. In table \ref{table:KNN_implementation} there are 8 columns. Target column is 'catL3' which is the category at level three.
\begin{table}[h] \begin{table}[h]
\centering \centering
\caption{Data frame head} \caption{Data frame head}
\label{table:KNN_implementation} \label{table:KNN_implementation}
\begin{tabular}{ lll } \begin{tabular}{llll}
\toprule \toprule id & name & shortDesc & Desc \\
\midrule
\textbf{No}& \textbf{Feature} & \textbf{Categorical}\\ 1&DENSO DTM82363 & NaN & NaN \\
\midrule \bottomrule
1&Product name & No\\ \end{tabular}
3&Description & No\\
4&Short description & No\\ \begin{tabular}{llll}
5&Supplier & Yes\\ \toprule catL1 & catL2 & catL3 & catL4\\
6&Manufacturer & Yes\\ \midrule
7&Price & No \\
8&Dimension & Yes\\ SparePart & Cooling System & Thermostat & NaN \\
\bottomrule \bottomrule
\end{tabular} \end{tabular}
\end{table} \end{table}
\begin{lstlisting}[language=Python] \begin{lstlisting}[language=Python]
X = df.drop(['catL3'], axis = 1) X = df.drop(['catL3'], axis = 1)
y = df['catL3'] y = df['catL3']

View file

@ -1,4 +1,4 @@
Get retromotion-indexer_development_products/_search POST retromotion-indexer_development_products/_search
{ {
"_source":["_id","descriptions","descriptionsSource","nameSource","shortDescriptionSource","categoriesSource"] "_source":["_id","descriptions","descriptionsSource","nameSource","shortDescriptionSource","categoriesSource"]
// "query": { // "query": {

View file

@ -178,7 +178,7 @@ class DataFrame:
def setDfProductTaxonomy(self,lang='en'): def setDfProductTaxonomy(self,lang='en'):
resp=self.es.searchDevelopmentProducts() resp=self.es.searchDevelopmentProducts()
df = pd.DataFrame(columns=["id",'name','shortDesc','Desc','catL1','catL2','catL3','catL4','catL5']) df = pd.DataFrame(columns=["id",'name','shortDesc','Desc','category','catL1','catL2','catL3','catL4','catL5'])
for hit in resp['hits']['hits']: for hit in resp['hits']['hits']:
list_row = dict (id=None,name=None,shortDesc=None,Desc=None,catL1=None,catL2=None,catL3=None,catL4=None,catL5=None) list_row = dict (id=None,name=None,shortDesc=None,Desc=None,catL1=None,catL2=None,catL3=None,catL4=None,catL5=None)
@ -188,6 +188,14 @@ class DataFrame:
if (name["language"]==lang): if (name["language"]==lang):
list_row["name"]=name["value"] list_row["name"]=name["value"]
for sd in hit['_source']['shortDescriptionSource']:
if (name["language"]==lang):
list_row["shortDesc"]=sd["value"]
for ds in hit['_source']['descriptionsSource']:
if (name["language"]==lang):
list_row["Desc"]=ds["value"]
for cats in hit['_source']['categoriesSource']: for cats in hit['_source']['categoriesSource']:
if (cats["language"]=="en"): if (cats["language"]=="en"):

View file

@ -50,8 +50,8 @@ class ElasticSearchDb:
self.ingest('english-false-prediction', val, 'category_prediction') self.ingest('english-false-prediction', val, 'category_prediction')
def searchDevelopmentProducts(self): def searchDevelopmentProducts(self):
resp = self.es.search("retromotion-indexer_development_products", resp = self.es.search(index="retromotion-indexer_development_products",
{ body={
"_source": "_source":
["_id", ["_id",
"descriptions", "descriptions",
@ -59,7 +59,8 @@ class ElasticSearchDb:
"nameSource", "nameSource",
"shortDescriptionSource", "shortDescriptionSource",
"categoriesSource" "categoriesSource"
] ],
"size":65000
}) })

View file

@ -1,3 +1,7 @@
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier
class KNN(): class KNN():
def __init__(self) -> None: def __init__(self) -> None:
pass pass