dopc
This commit is contained in:
parent
9eafb0ab07
commit
28602d10a3
14 changed files with 194 additions and 139 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -439,5 +439,5 @@ TSWLatexianTemp*
|
|||
*.ipynb:Zone.Identifier
|
||||
|
||||
development-environment/*
|
||||
*.pt
|
||||
*-classification.pt
|
||||
*.pickel
|
||||
|
|
|
|||
BIN
confusion.png
Normal file
BIN
confusion.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 438 KiB |
|
|
@ -212,7 +212,7 @@
|
|||
@online{sean,
|
||||
author = {Sean Robertson},
|
||||
title = {{Classifying names with a character level RNN}},
|
||||
url={https://pytorch.org/tutorials/intermediate/char_rnn_classification_tutorial.html}},
|
||||
url={https://pytorch.org/tutorials/intermediate/char_rnn_classification_tutorial.html},
|
||||
year = {2023},
|
||||
note = {[Online; accessed 02-June-2023]}
|
||||
urldate = {02-07-2023},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,44 +1,68 @@
|
|||
\chapter{Data collection}
|
||||
|
||||
\chapter{Prerequisites for developing classification model}
|
||||
% One of the major challenge in an ecommerce industry is to categorize the products. The phenominal types of products in the ecommerce web application sold online may require an artificial inteligence generated category tree. The multi level product-categories in the taxonomy tree received and defined from the suppliers or manfucture may not be usable. Since the existing multi level category of those products in ecommerse application may defer. Importing product-category details directly from the various channels may lead to disambugution. The artificial inteligence generated category tree reduces the product ready to deploy time on the production environment. The product ready to deploy time here refers to the check lists of data correctness of the product before listing online.
|
||||
|
||||
One of the major challenge in an ecommerce industry is to categorize the products. The phenominal types of products in the ecommerce web application sold online may require an artificial inteligence generated category tree. The multi level product-categories in the taxonomy tree received and defined from the suppliers or manfucture may not be usable. Since the existing multi level category of those products in ecommerse application may defer. Importing product-category details directly from the various channels may lead to disambugution. The artificial inteligence generated category tree reduces the product ready to deploy time on the production environment. The product ready to deploy time here refers to the check lists of data correctness of the product before listing online.
|
||||
|
||||
\section {Fetch existing product taxonomy using Elastic Search}
|
||||
|
||||
In section \ref {pyenv}, version specific python client installation detail are documented. For this project, python client elasticsearch 6.8.2 is installed as the client needs to be compatble with Elastic search version being used.
|
||||
|
||||
\section {Fetch existing product taxonomy using Elasticsearch}
|
||||
Elastic search \footnote{https://www.elastic.co/} is a fast and scalable search and analytics engine. It can build a powerful AI and machine learning enabled search experience. In this paper, author fetches labeled dataset of products to serve as the training data for the machine learning model.
|
||||
Refer section \ref {pyenv} for installation detail of version specific python client of Elastic search. For this project, python client elasticsearch 6.8.2 is installed as the client needs to be compatible with Elastic search version being used. The official Python client provides mapping with Elasticsearch REST APIs.
|
||||
|
||||
\begin{lstlisting}[language=Python]
|
||||
from elasticsearch import Elasticsearch
|
||||
client = Elasticsearch("http://localhost:9200")
|
||||
|
||||
resp = client.search(index="development_products",
|
||||
body={"_source":["descriptions","descriptionsSource","nameSource","shortDescriptionSource","categoriesSource"],
|
||||
"query": {"match_all": {}}})
|
||||
resp=self.es.search("english-name-category",{"_source":["id","name","category"],
|
||||
'from':_from,
|
||||
'size' :_size ,
|
||||
"query": {"match_all": {}}})
|
||||
\end{lstlisting}
|
||||
|
||||
The above code sample fetches the features of the product such as "name","description",category".
|
||||
The above code fetches indexed product name and its top hierarchy level category. This record serves as a foundation for multi level category prediction.
|
||||
|
||||
\begin{table}[h]
|
||||
\caption{Index: english-name-category statistics}
|
||||
\centering
|
||||
\label{table:enc}
|
||||
\begin{tabular}{ll}
|
||||
\toprule
|
||||
|
||||
Samples total&22160 \\
|
||||
Dimensionality&2 \\
|
||||
Features&name \\
|
||||
Target&category \\
|
||||
|
||||
\bottomrule
|
||||
\end{tabular}
|
||||
\end{table}
|
||||
|
||||
% In table \ref{table:enc}, the total number of products is mentioned.
|
||||
|
||||
|
||||
Elasticsearch uses \acf{Tf-Idf}. \acs{Tf-Idf} is a technique to generate numeric representation of words. \acs{Tf-Idf} represents product of two terms, \acs{Tf} and \acs{Idf}.
|
||||
|
||||
|
||||
% Elasticsearch uses \acf{Tf-Idf}. \acs{Tf-Idf} is a technique to generate numeric representation of words. \acs{Tf-Idf} represents product of two terms, \acs{Tf} and \acs{Idf}.
|
||||
|
||||
% \begin{math} x_i=tf(w_i) x idf(w_i) \end{math}
|
||||
|
||||
\section {Feature selection and dataset sources}
|
||||
|
||||
A feature represents a set of data inputed in a training model to predict the the masked related data. In simple terms, in a classication model which predicts category of a product, product name, description can be labeled as its feature.
|
||||
A feature represents a dataset fine-tuned to serve as a training data for machine learning model. The feature selection API from Scikit learn \parencite{sklearn_api} name it as dimensionality reduction. In table \ref{table:enc} the dimensionality is only two. Hence, the obvious choice of feature is "Product name" and target is "Category". Selecting features from higher number of dimensionality is a challenge and a deciding factor to improve the estimators' accuracy scores.\\
|
||||
Various methods for feature selection with Scikit Learn API are:-
|
||||
\begin{enumerate}
|
||||
\item Removing features with low variance
|
||||
\item Univariate feature selection
|
||||
\item Recursive feature elimination
|
||||
|
||||
The datasets used primarly for extracting feautures will be from the existing product database. In this paper, the datasets used are of an ecommerce business belonging to automotive industry domain. Secondary dataset used is from the TecDoc catalogue by TecAlliance \footnote{https://www.tecalliance.net/}
|
||||
\end{enumerate}
|
||||
|
||||
In this experiment, consider 5 levels of categories as the maximum limit. The number of category levels differ for each products. Consider an example of category tree with three levels.
|
||||
% The datasets used primarly for extracting feautures will be from the existing product database. In this paper, the datasets used are of an ecommerce business belonging to automotive industry domain. Secondary dataset used is from the TecDoc catalogue by TecAlliance \footnote{https://www.tecalliance.net/}
|
||||
|
||||
\begin{quote}
|
||||
\centering
|
||||
sparepart/cooling-system/thermostat
|
||||
\end{quote}
|
||||
In such case, level 4 and level 5 will be appended with values using data imputation techniques, refer section \ref{dataimput}.
|
||||
Author initially chose to experiment with two-dimensionality, a simple experiment of predicting target which is top level category with feature which is the name of the product. Refer table \ref{table:feature_decription} to view the potential features for an ecommerce domain.
|
||||
% five levels of categories are taken into consideration. The number of category levels differ for each product. Consider an example of category tree with three levels.
|
||||
|
||||
The table \ref{table:l5} lists the feature description aling with the sample of category levels.
|
||||
% \begin{quote}
|
||||
% \centering
|
||||
% sparepart/cooling-system/thermostat
|
||||
% \end{quote}
|
||||
% In such case, level 4 and level 5 will be appended with values using data imputation techniques, refer section \ref{dataimput}.
|
||||
% \begin{figure}[h]
|
||||
% \centering
|
||||
% \small{This is text. It's in a figure environment but it's still text}
|
||||
|
|
@ -48,110 +72,43 @@ The table \ref{table:l5} lists the feature description aling with the sample of
|
|||
|
||||
|
||||
\begin{table}[h]
|
||||
\caption{Feature descriptin and five levels of category sample data}
|
||||
\label{table:l5}
|
||||
|
||||
% \end{table}
|
||||
|
||||
% \begin{table}
|
||||
% \caption{Feature descriptions}
|
||||
% \label{table:features}
|
||||
\centering
|
||||
\caption{Feature description}
|
||||
\label{table:feature_decription}
|
||||
\begin{tabular}{ lll }
|
||||
\toprule
|
||||
|
||||
\textbf{No}& \textbf{Feature} & \textbf{Value}\\
|
||||
\textbf{No}& \textbf{Feature} & \textbf{Description}\\
|
||||
\midrule
|
||||
1&Category tree & multi level categories\\
|
||||
2&Description & description with html tags\\
|
||||
3&Manufacturere & name of company manfactured\\
|
||||
1&Product name & normalized form of name\\
|
||||
2&Category tree & multi level categories\\
|
||||
3&Description & Description with html tags\\
|
||||
4&Short description & product info displayed\\
|
||||
5&Supplier & supplier of the product\\
|
||||
\color{red}6&n number of category levels & feature extracted from category tree\\
|
||||
6&Manufacturer & manufacturer of the product\\
|
||||
7&Price & Price of the product\\
|
||||
8&Dimension & Height, weight of the product\\
|
||||
9&(n-1) number of category levels & n is the total category level, one of which will be the target\\
|
||||
|
||||
\bottomrule
|
||||
\end{tabular}
|
||||
|
||||
\begin{tabular}{llllll}
|
||||
\toprule
|
||||
catlevel0 & catlevel1 & catlevel2 & catlevel3 & catlevel4 & catlevel5 \\
|
||||
\midrule
|
||||
sparepart & cooling system & thermostat & NaN & NaN & NaN \\
|
||||
% \begin{tabular}{llllll}
|
||||
% \toprule
|
||||
% catlevel0 & catlevel1 & catlevel2 & catlevel3 & catlevel4 & catlevel5 \\
|
||||
% \midrule
|
||||
% sparepart & cooling system & thermostat & NaN & NaN & NaN \\
|
||||
|
||||
\bottomrule
|
||||
\end{tabular}
|
||||
% \bottomrule
|
||||
% \end{tabular}
|
||||
|
||||
\end{table}
|
||||
|
||||
|
||||
\subsection{Dependency parsing for extracting nouns from features}
|
||||
% \subsection{Dependency parsing for extracting nouns from features}
|
||||
|
||||
\section {Text normalization} \label{text_normalization}
|
||||
% \section {Data imputation techniques - on missing data} \label{dataimput}
|
||||
|
||||
Text normalization is a process of transforming the document into a standard and consistent form of a text. A document is a text from single source. Some of the examples of document are list of product names from databases, a pdf file, texts retrieved from web scraping. Text normalization enables to perform required operations on the text as the text inputs are consistent accross the document. The process of text normalization varies based on the type of text that needs to normilized. There is no standard method for text normalization task. In this paper, text normalization of product name and category from the database source is performed. The text are of two languages, English and Deutsch.
|
||||
% \subsection {Forward and Backward fill}
|
||||
|
||||
In table \ref{table:TN}, displays the difference in text before and after normalization.
|
||||
|
||||
\begin{table}[h]
|
||||
\caption{Sample of text normalization effect}
|
||||
\centering
|
||||
\label{table:TN}
|
||||
\begin{tabular}{lll}
|
||||
\toprule
|
||||
&\textbf{Name} & \textbf{Category} \\
|
||||
\midrule
|
||||
\textbf{Before}&VAICO V10-4245 Stoßdämpfer & Stoßdämpfer \\
|
||||
\textbf{After}&vaico v104245 stoßdampfer & stoßdampfer \\
|
||||
|
||||
\bottomrule
|
||||
\end{tabular}
|
||||
\end{table}
|
||||
|
||||
\subsection{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}.
|
||||
|
||||
\begin{lstlisting}[language=Python]
|
||||
df_de["name"]= df_de["name"].str.lower()
|
||||
\end{lstlisting}
|
||||
|
||||
\subsection{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.
|
||||
\begin{lstlisting}[language=Python]
|
||||
text = re.sub('<[^>]*>', '', text)
|
||||
\end{lstlisting}
|
||||
|
||||
|
||||
|
||||
The better option would be to use Beautiful Soup \footnote{https://www.crummy.com/software/BeautifulSoup/bs4/doc/} a Pyhon library for pulling data out of HTLM and XML.
|
||||
\begin{lstlisting}[language=Python]
|
||||
# Remove html tags
|
||||
soup = BeautifulSoup(doc, 'html.parser')
|
||||
text =soup.get_text()
|
||||
\end{lstlisting}
|
||||
|
||||
\subsection{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.
|
||||
|
||||
\begin{lstlisting}[language=Python]
|
||||
text = (re.sub('[-\W]+', ' ', text))
|
||||
text = (re.sub('(?<=\d) (?=\d)', '', text))
|
||||
\end{lstlisting}
|
||||
|
||||
\subsection{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.
|
||||
\begin{lstlisting}[language=Python]
|
||||
''.join(
|
||||
c for c in unicodedata.normalize('NFD', text)
|
||||
if unicodedata.category(c) != 'Mn')
|
||||
\end{lstlisting}
|
||||
|
||||
|
||||
|
||||
\section {Data imputation techniques - on missing data} \label{dataimput}
|
||||
|
||||
\subsection {Forward and Backward fill}
|
||||
|
||||
\subsection {Impute with mode}
|
||||
% \subsection {Impute with mode}
|
||||
|
|
@ -1,8 +1,62 @@
|
|||
\chapter{Text normalization} \label{text_normalization}
|
||||
|
||||
\chapter{Multi level category vectorization techniques}
|
||||
Text normalization is a process of transforming the document into a standard and consistent form of a text. A document is a text from single source. Some examples of document are list of product names from databases, a pdf file, texts retrieved from web scraping. Text normalization enables to perform required operations on the text as the text inputs are consistent across the document. The process of text normalization varies based on the type of text that needs to normalize. There is no standard method for text normalization task. In this paper, text normalization of product name and category from the database source is performed. The text are of two languages, English and Deutsche.
|
||||
|
||||
Vectorization of a text is a process of transforming a text into a real number representation. Scikit-learn api \parencite{sklearn_api}, provides python libraries for machine learning. Applying the ngram vectorization method transforms the text data into a real number.
|
||||
In table \ref{table:TN}, displays the difference in text before and after normalization.
|
||||
|
||||
\section {n-gram vectorization}
|
||||
\begin{table}[h]
|
||||
\caption{Sample of text normalization effect}
|
||||
\centering
|
||||
\label{table:TN}
|
||||
\begin{tabular}{lll}
|
||||
\toprule
|
||||
&\textbf{Name} & \textbf{Category} \\
|
||||
\midrule
|
||||
\textbf{Before}&VAICO V10-4245 Stoßdämpfer & Stoßdämpfer \\
|
||||
\textbf{After}&vaico v104245 stoßdampfer & stoßdampfer \\
|
||||
|
||||
\bottomrule
|
||||
\end{tabular}
|
||||
\end{table}
|
||||
|
||||
\section {Tf-iTf vectorization}
|
||||
\subsection{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}.
|
||||
|
||||
\begin{lstlisting}[language=Python]
|
||||
df_de["name"]= df_de["name"].str.lower()
|
||||
\end{lstlisting}
|
||||
|
||||
\subsection{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.
|
||||
\begin{lstlisting}[language=Python]
|
||||
text = re.sub('<[^>]*>', '', text)
|
||||
\end{lstlisting}
|
||||
|
||||
|
||||
|
||||
The better option would be to use Beautiful Soup \footnote{https://www.crummy.com/software/BeautifulSoup/bs4/doc/} a Pyhon library for pulling data out of HTLM and XML.
|
||||
\begin{lstlisting}[language=Python]
|
||||
# Remove html tags
|
||||
soup = BeautifulSoup(doc, 'html.parser')
|
||||
text =soup.get_text()
|
||||
\end{lstlisting}
|
||||
|
||||
\subsection{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.
|
||||
|
||||
\begin{lstlisting}[language=Python]
|
||||
text = (re.sub('[-\W]+', ' ', text))
|
||||
text = (re.sub('(?<=\d) (?=\d)', '', text))
|
||||
\end{lstlisting}
|
||||
|
||||
\subsection{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.
|
||||
\begin{lstlisting}[language=Python]
|
||||
''.join(
|
||||
c for c in unicodedata.normalize('NFD', text)
|
||||
if unicodedata.category(c) != 'Mn')
|
||||
\end{lstlisting}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
\chapter{Neural networks for classification model}
|
||||
\chapter{Impute missing text data}
|
||||
|
||||
Pyroch \parencite{Paszke.03122019}
|
||||
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.
|
||||
|
||||
\subsection{Feature imputation}
|
||||
|
||||
In an iterated round-robin fashion, at every step a missing feature column \textit{y} and other feature columns treated as input \textit{x} predicts the missing values of \textit{y}.
|
||||
|
|
|
|||
8
doc/chapters/chaptern.tex
Normal file
8
doc/chapters/chaptern.tex
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
\chapter{Multi level category vectorization techniques}
|
||||
|
||||
Vectorization of a text is a process of transforming a text into a real number representation. Scikit-learn api \parencite{sklearn_api}, provides python libraries for machine learning. Applying the ngram vectorization method transforms the text data into a real number.
|
||||
|
||||
\section {n-gram vectorization}
|
||||
|
||||
\section {Tf-iTf vectorization}
|
||||
4
doc/chapters/chapternn.tex
Normal file
4
doc/chapters/chapternn.tex
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
\chapter{Neural networks for classification model}
|
||||
|
||||
Pyroch \parencite{Paszke.03122019}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 77 KiB |
|
|
@ -13,6 +13,7 @@
|
|||
\usepackage{blindtext}
|
||||
\usepackage[inkscapeformat=png]{svg}
|
||||
\usepackage{booktabs}
|
||||
\usepackage{xurl}
|
||||
\usetikzlibrary{matrix,fadings,arrows,trees,calc,positioning,decorations,automata,fit,backgrounds}
|
||||
\pagecolor{red!5}
|
||||
|
||||
|
|
@ -222,6 +223,7 @@ Paszke, Adam et al. (2019).\\
|
|||
\linebreak
|
||||
Robertson, Sean (2023).\\
|
||||
\textit{Classifying names with a character level RNN.}\\
|
||||
\url{https://pytorch.org/tutorials/intermediate/char_rnn_classification_tutorial.html}
|
||||
|
||||
|
||||
\end{multicols*}
|
||||
|
|
|
|||
|
|
@ -37,3 +37,26 @@ https://stanford.edu/~shervine/teaching/cs-230/cheatsheet-recurrent-neural-netwo
|
|||
|
||||
what is softmax?
|
||||
|
||||
|
||||
Product categorization with machine learning is a task that involves automatically assigning products to specific categories or labels based on their features or attributes. It is a common problem in e-commerce, where large catalogs of products need to be organized and classified for various purposes such as search, recommendation, and inventory management.
|
||||
|
||||
Machine learning techniques can be employed to tackle product categorization by learning patterns and relationships from labeled training data. Here's a general approach to performing product categorization using machine learning:
|
||||
|
||||
Data Collection: Gather a labeled dataset of products, where each product is associated with its corresponding category or label. This dataset serves as the training data for the machine learning model.
|
||||
|
||||
Data Preprocessing: Clean and preprocess the product data to remove any irrelevant information, normalize text, handle missing values, and transform the data into a suitable format for the machine learning algorithm. This step may involve techniques such as tokenization, stemming, and removing stop words.
|
||||
|
||||
Feature Extraction: Extract relevant features from the product data that can help discriminate between different categories. Features can include textual information (product descriptions, titles), numerical attributes (price, dimensions), and categorical attributes (brand, color).
|
||||
|
||||
Model Selection: Choose an appropriate machine learning model for the task of product categorization. Commonly used models include decision trees, random forests, support vector machines (SVM), and neural networks. The choice of the model depends on the complexity of the problem, the size of the dataset, and the available computing resources.
|
||||
|
||||
Training: Split the labeled dataset into a training set and a validation set. Use the training set to train the selected machine learning model by feeding it with the labeled product data and their corresponding features. The model learns the patterns and relationships between the features and the categories.
|
||||
|
||||
Model Evaluation: Evaluate the trained model's performance using the validation set. Common evaluation metrics for multi-class classification tasks include accuracy, precision, recall, and F1 score. The evaluation helps assess the model's ability to correctly categorize unseen products.
|
||||
|
||||
Model Deployment: Once the model has been trained and evaluated satisfactorily, it can be deployed to categorize new, unseen products. The deployed model takes the product features as input and predicts the appropriate category or label for the product.
|
||||
|
||||
Iterative Refinement: Product categorization is an iterative process, and the model's performance can be improved by continuously refining the features, trying different machine learning algorithms, and retraining the model with additional labeled data.
|
||||
|
||||
It's important to note that the success of product categorization using machine learning heavily depends on the quality and representativeness of the labeled training data, as well as the selection and engineering of relevant features
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -41,7 +41,7 @@ class ElasticSearchDb:
|
|||
}
|
||||
}
|
||||
|
||||
self.create('english-false-prediction',request_body)
|
||||
# self.create('english-false-prediction',request_body)
|
||||
|
||||
|
||||
for val in docDict:
|
||||
|
|
|
|||
|
|
@ -13,36 +13,38 @@ import pandas as pd
|
|||
|
||||
def main():
|
||||
es =ElasticSearchDb("http://172.17.212.35:9200")
|
||||
helper = Helper()
|
||||
|
||||
df=DataFrame(es)
|
||||
# dfProductTaxonomyEn=df.getProductTaxonomy(0,10000)
|
||||
dfProductTaxonomyEn=df.getProductTaxonomy(10000,0)
|
||||
df_en = df.getNormal()
|
||||
# train = Train(df_en)
|
||||
# train.run(300000,30000,3000)
|
||||
predict = Predict()
|
||||
|
||||
predict.confusionMatix(df_en)
|
||||
# # df_prediction=pd.DataFrame(columns=["id",'name','category','predicted','value'])
|
||||
# # list_row_en = dict (id=None,name=None,category=None,predicted=None,value=None)
|
||||
# list =[]
|
||||
# for index, row in dfProductTaxonomyEn.iterrows():
|
||||
# predicted =predict.start(row["name"].lower())
|
||||
# predict.confusionMatix(df_en)
|
||||
df_prediction=pd.DataFrame(columns=["id",'name','category','predicted','value'])
|
||||
list_row_en = dict (id=None,name=None,category=None,predicted=None,value=None)
|
||||
list =[]
|
||||
for index, row in dfProductTaxonomyEn.iterrows():
|
||||
predicted =predict.start(row["name"].lower())
|
||||
actualCategory=helper.normalize(row["category"])
|
||||
|
||||
# if(predicted[0][1]!=row["category"].lower()):
|
||||
# list_row = dict (id=None,name=None,category=None,predicted=None,value=None)
|
||||
# list_row["id"] =row["id"]
|
||||
# list_row["name"] =row["name"]
|
||||
# list_row["category"] =row["category"]
|
||||
# list_row["predicted"] =predicted[0][1]
|
||||
# list_row["value"] =predicted[0][0]
|
||||
if(predicted[0][1]!=actualCategory.lower()):
|
||||
list_row = dict (id=None,name=None,category=None,predicted=None,value=None)
|
||||
list_row["id"] =row["id"]
|
||||
list_row["name"] =row["name"]
|
||||
list_row["category"] =row["category"]
|
||||
list_row["predicted"] =predicted[0][1]
|
||||
list_row["value"] =predicted[0][0]
|
||||
|
||||
# list.append(list_row)
|
||||
list.append(list_row)
|
||||
|
||||
|
||||
|
||||
# # new_row = pd.Series(list_row)
|
||||
# # df_prediction=pd.concat([df_prediction, new_row.to_frame().T], ignore_index=True)
|
||||
# es.createIndexerPrediction(list)
|
||||
# new_row = pd.Series(list_row)
|
||||
# df_prediction=pd.concat([df_prediction, new_row.to_frame().T], ignore_index=True)
|
||||
es.createIndexerPrediction(list)
|
||||
|
||||
|
||||
if __name__=="__main__":
|
||||
|
|
|
|||
Loading…
Reference in a new issue