Full text
For Jury Evaluation FACULDADE DE ENGENHARIA DA UNIVERSIDADE DO PORTO Reverse Engineering Static Content and Dynamic Behaviour of E-Commerce Websites for Fun and Profit João Pedro Matos Teixeira Dias Master in Informatics and Computing Engineering Supervisor: Hugo Sereno Ferreira, PhD Co-supervisor: Rui Gonçalves June 27, 2016
Reverse Engineering Static Content and Dynamic Behaviour of E-Commerce Websites for Fun and Profit João Pedro Matos Teixeira Dias Master in Informatics and Computing Engineering Approved in oral examination by the committee: Chair: External Examiner: Supervisor: June 27, 2016
Abstract Nowadays electronic commerce websites are one of the main transaction tools between on-line merchants and consumers or businesses. These e-commerce websites rely heavily on summarizing and analyzing the behaviour of customers, making an effort to influence user actions towards the optimisation of success metrics such as CTR (Click through Rate), CPC (Cost per Conversion), Basket and Lifetime Value and User Engagement. Knowledge extraction from the existing ecommerce websites datasets, using data mining and machine learning techniques, has been greatly influencing the Internet marketing activities. When faced with a new e-commerce website, the machine learning practitioner starts a web mining process by collecting historical and real-time data of the website and analyzing/transforming this data in order to be capable of extracting information about the website structure and content and its users’ behaviour. Only after this process the data scientists are able to build relevant models and algorithms to enhance marketing activities. This is an expensive process in resources and time since it will always depend on the condition in which the data is presented to the data scientist, since data with more quality (i.e. no incomplete data) will make the data scientist work easier and faster. On the other hand, in most of the cases, data scientists would usually resort to tracking domain-specific events throughout a user’s visit to the website in order to fulfill the objective of discovering the users’ behaviour and, for this, it is necessary to perform code modifications to the pages themselves, that will result in a larger risk of not capturing all the relevant information by not enabling tracking mechanisms in certain pages. For example, we may not know a priori that a visit to a Delivery Conditions page is relevant to the prediction of a user’s willingness to buy and therefore would not enable tracking on those pages. Within this problem context, the proposed solution consists in a methodology capable of extracting and combining information about a e-commerce website through a process of web mining, comprehending the structure as well as the content of the website pages, relying mostly on identifying dynamic content and semantic information in predefined locations, complemented with the capability of, using the user’s access logs, extracting more accurate models to predict the users future behaviour. This allows for the creation of a data model representing an e-commerce website and its archetypical users that can be useful, for example, in simulation systems. i
ii
Resumo Atualmente os websites de comércio eletrónico são uma das ferramentas principais para a realização de transações entre comerciantes online e consumidores ou empresas. Estes websites apoiamse fortemente na sumarização e análise dos hábitos de navegação dos consumidores, de forma a influenciar as suas ações no website com o intuito de otimizar métricas de sucesso como o CTR (Click through Rate), CPC (Cost per Conversion), Basket eLifetime Value eUser Engagement. A utilização de técnicas de data mining emachine learning na extração de conhecimento a partir dos conjuntos de dados existentes nos websites de comércio eletrónico tem vindo a ter uma crescente influência nas campanhas de marketing realizadas na Internet. Quando o provedor de serviços de machine learning se deparada com um novo website de comércio eletrónico, inicia um processo de web mining, fazendo recolha de dados, tanto históricos como em tempo real, do website e analisando/transformando estes dados de forma a tornar os mesmos utilizáveis para fins de extração de informação tanto sobre a estrutura e conteúdo de um website assim como dos hábitos de navegação dos seus utilizadores típicos. Apenas após este processo é que os data scientists são capazes de desenvolver modelos relevantes e algoritmos para melhorar e otimizar as atividades de marketing online. Este processo é, na sua generalidade, moroso em tempo e recursos, dependendo sempre da condição em que os dados são apresentados ao data scientist. Dados com mais qualidade (p.ex. dados completos), facilitam o trabalho dos data scientists e tornam o mesmo mais rápido. Por outro lado, na generalidade dos casos, os data scientists tem de recorrer a técnicas de monitorização de eventos específicos ao domínio do website de forma a atingir o objetivo de conhecer os hábitos dos utlizadores, tornando-se necessário a realização de modificações ao código fonte do website para a captura desses mesmos eventos, aumentando assim o risco de não capturar toda a informação relevante por não ativar os mecanismos de monitorização em todas as páginas do website. Por exemplo, podemos não ter conhecimento a priori que uma visita à página de Condições de Entrega é relevante para prever o desejo de um dado consumidor efetuar uma compra e, desta forma, os mecanismos de monitorização nessas páginas podem não ser ativados. No contexto desta problemática, a solução proposta consiste numa metodologia capaz de extrair e combinar a informação sobre um dado website de comércio eletrónico através de um processo de web mining, compreendendo a estrutura de páginas de um website, assim como do conteúdo das mesmas, baseando-se para isso na identificação de conteúdo dinâmico das páginas assim como informação semântica recolhida de locais predefinidos. Adicionalmente esta informação é complementada, usando dados presente nos registos de acesso de utilizadores, com modelos preditivos do futuro comportamento dos utilizadores no website. Torna-se assim possível a apresentação de um modelo de dados representando a informação sobre um dado website de comércio eletrónico e os seus utilizadores arquetípicos, podendo posteriormente estes dados serem utilizados, por exemplo, em sistemas de simulação. iii
iv
Acknowledgements Prima facie, I want to thank my supervisor Hugo Sereno Ferreira for all the shared knowledge and orientation given during the realization of this dissertation. I am also grateful to my co-supervisor, Rui Gonçalves, for all the feedback given as well as all technical insights on Scala and e-commerce world. I would like to thank all the people at ShiftForward for welcoming me and for the precious help given many times during my research, always providing me with what I needed. Also, I want to thank all the people and friends from NuIEEE UP (IEEE Student Branch of Universidade do Porto) for all support and all the help provided. Last but not least, I want to express my gratitude to all my friends and family, for the constant support and motivation, without which I would not be able to make this accomplishment. João Pedro Matos Teixeira Dias v
LIST OF FIGURES xii
List of Tables 2.1 Example of a pageview transaction matrix. . . . . . . . . . . . . . . . . . . . . . 22 2.2 Example of a market basket transactions. . . . . . . . . . . . . . . . . . . . . . . 23 2.3 Frequency of occurrence of each transaction [Sin04]. ............... 27 2.4 An example of a keyword-based user profile. . . . . . . . . . . . . . . . . . . . 29 4.1 Summary of the used data sources, applied techniques and outcomes. . . . . . . . 40 6.1 Session original characteristics. . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 6.2 Input syntheticuserdata............................... 63 6.3 Output userprofileinformation. .......................... 64 6.4 Output user clusters after clustering by session characterisation. . . . . . . . . . 65 6.5 Output user average interests after clustering by preferences. . . . . . . . . . . . 66 xiii
LIST OF TABLES xiv
Abbreviations B2B Business-to-business B2C Business-to-consumer CR Conversion rate CSP Contiguous Sequential Pattern CSS Cascading Style Sheets CTR Click-through rate DOM Document Object Model E-commerce Electronic Commerce EDA Exploratory Data Analysis GATC Google Analytics Tracking Code HTML HyperText Markup Language JSON JavaScript Object Notation kNN k-Nearest-Neighbour POC Proof of Concept SVM Supported Vector Machines URL Uniform Resource Locator W3C World Wide Web Consortium WCM Web content mining WSM Web structure mining WUM Web usage mining WWW World Wide Web XML eXtensible Markup Language xv
Chapter 1 Introduction2 Nowadays, thanks to the development of electronic commerce (e-commerce), a great percentage of the most basic of economic transactions - the buying and selling of goods - take place over4 electronic networks, mostly the Internet. This is a constantly growing business and it is expected that the number of e-commerce transactions will reach 38.5 billion in 2015 [Sta16].6 When a user enters on an e-commerce website marketing and advertising mechanisms are put in place, trying to influence the user behaviour to improve sales and increase profits. These8 mechanisms rely heavily on summarizing and analysing the behaviour of costumers. Data mining and machine learning techniques have been applied towards the development of these mechanisms,10 making a great significance in Internet marketing activities, and improving e-commerce sales and profits.12 There are a considerable number of companies today who develop and provide tools and mechanisms to e-commerce business owners in order to make them capable of improving their sales and14 take better data-driven decisions (i.e. marketing decisions). These tools are used with the objective to track and learn costumers habits, being the most of the times complemented with automatic16 recommendation systems. This makes e-commerce business owners more capable of doing more precise target marketing and advertisement, with, for example, recommending the most interesting18 product for each visitor, increasing overall sales, and profits. 1.1 Motivation20 When faced with a new e-commerce website, the machine learning practitioner typically spends a great amount of time collecting and analysing the static and dynamic data of the website. This22 process is essential to extract useful information about the website’s structure, content, and its users’ behaviour. Only after this process, the machine learning partitioner becomes able to build24 relevant models and algorithms to enhance online marketing activities. This is a great challenge because of the heterogeneous nature of the data, the semi-structured or unstructured way that data26 is presented and the data existent is so vast that we can easily get overwhelmed by it [ZS08]. 1
Introduction The process of extracting information from a website’s structure, content and users is mostly a repetitive and semi-automated task, which is reflected in the necessity of allocating dedicated 2 resources to it. In some cases, there is a need of analysing and track the website for a certain period of time after it comes to the hands of machine learning practitioner for data collection 4 proposes, implying a waste of time. Besides that, there is a great risk of relevant knowledge that may exist between data sources pass unnoticed. Improving this process to an automatic one can 6 bring some advantages, including the reduce of costs, as well as, the risks of information losses. 1.2 Aim and Goals 8 The aim of this dissertation is to develop a process capable of, given an e-commerce website, extracting useful information from its structure, content and its typical users’ behaviour using 10 state of the art techniques and methods, returning a consistent model representing the website content, relations between pages and its archetypical users. This has the objective of reducing the 12 time and resources required to analyse an e-commerce website on the machine learning end. It is also an objective improve the extraction of knowledge, making possible establish relationships 14 between a given website structure, content and usage, becoming the website more clear to the data scientist. 16 The expected final result of the present work is a functional prototype of a tool, as the process’s proof of concept, capable of, applying already researched techniques, extract useful information 18 from a website. The tool developed is aimed to be ready (as it is or with little changes) to be used by a data scientist in order to get a grasp of the site’s layout and its users’, aiming to make the data 20 collection and information extract task more efficient, easy and concise. 1.3 Expected Contributions 22 We propose a study of a new process for extracting and representing the information present on a given e-commerce website. The website pages and the connections between them are mapped 24 into a data structure, as well the navigational habits of its users. This process will consist of a allin-one approach, trying to mitigate possible data relationships losses from the typical, a partially 26 separate, tasks used to retrieve this data. The contributions of this dissertation can be summarized in the following points: 28 1. An all-in-one approach to extract information from an e-commerce website content, structure and its archetypical users; 30 2. A concise representation of this information in a consistent and adaptable model, in order to make the knowledge access and retrieval more direct and easy; 32 3. Mitigate possible flaws when collecting data, establishing relationships and connections between data sources that could otherwise pass unnoticed to the data scientist. 34 2
Introduction 1.4 Structure of this Dissertation In Chapter 2, it’s provided a contextualization on e-commerce area and background review of2 the related work in web mining and user profiling fields, going through web mining taxonomy, user profiling techniques, e-commerce peculiarities and the importance success metrics on e-4 commerce. The problem addressed in this dissertation is detailed in Chapter 3, presenting the major challenges but also possible solutions for those challenges.6 Chapter 4presents an high-level overview of the process to, on one hand, retrieve a website static content and place it into a structured representation, and, on the other hand, discover the8 website’s archetypical users through the representation of statistical models, user flows and usage patterns. Some details of the implementation realized are presented in Chapter 5. An evaluation10 of the process realized, including some results from techniques applied is made in Chapter 6. At last, some closing remarks and further work are presented in Chapter 7.12 3
Introduction 4
Chapter 2 Literature Review2 This chapter provides an overview of previous research on the area of extracting, analysing and modelling structure and content from e-commerce websites, but also, user profiling techniques to4 find and retrieve archetypical users on this websites, in this case, known as typical costumers. Firstly, it is done a contextualization on e-commerce in Section 2.1. The current research on6 mining the web, known as Web Mining is presented and analysed in Section 2.2. User profiling research and techniques are covered in Section 2.3. At last, some conclusions over the current8 state of the art are presented in Section 2.4. 2.1 E-commerce Overview10 E-commerce has become an essential tool for small and large businesses worldwide, not only as a tool of selling goods directly to consumers (B2C) or to other businesses (B2B) but also as a way12 of engaging them [EK08]. “Electronic commerce is the process of buying, selling, transferring, or exchanging14 products, services, and/or information via computer networks, including the Internet.” [TK11]16 E-commerce is one of the innovations with most impact over the consumer habits, mostly due to his unique features. E-commerce benefits of its ubiquity nature, since it works over the WWW,18 it is available everywhere at any time, through desktops, mobiles, and tablets. Besides that, the richness of information presented to the user make e-commerce a great bridge between merchants20 and customers [Hyd05]. When talking about e-commerce business is obligatory to mention Amazon1and eBay2, which22 were among the first Internet companies to make available electronic transactions to the users. But, as of today, this kind of transactions are available everywhere on the WWW, even through24 1http://www.amazon.com/ 2http://ebay.com/ 5
Literature Review •Link-based Classification: focus on the prediction of the category of a Web page, based on words that occur on the page, links between pages, anchor text, HTML tags and other 2 possible attributes found on the Web page; •Link-based Cluster Analysis: consists in finding naturally occurring sub-classes. The data 4 is segmented into groups, where similar objects are grouped together, and dissimilar objects are grouped into different groups. Different than the previous task, link-based cluster 6 analysis is unsupervised and can be used to discover hidden patterns from data; •Link Type: prediction of the reason of link existence, such as the type of link between two 8 entities or the purpose of a link; •Link Strength: technique of associating links with weights; 10 •Link Cardinality: used to predict the number of links between objects. Some of the most known algorithms in Web structure mining area are the PageRank and HITS 12 algorithm. PageRank [PBMW99], used by Google, calculates the importance of Web pages relying on the linked structure of the Web, giving weights to the Web pages according to the number 14 of inbound and outbound links presented on each page. In HITS concept [Kle99], are identified two kinds of pages from the Web structure: authorities (pages with good sources of content) and 16 hubs (pages with good sources of links). For a given query, HITS will find authorities and hubs. 2.2.2 Data Collection and Preprocessing 18 The main goal in data collection stage is to gather resources, retrieving data from the website’s pages and Web usage records (e.g. logs). 20 In one hand, Web pages contain information like text and multimedia that are essential for Web content mining, as is referred in section 2.2.1.1. On the other hand, the hyperlinks presents 22 in this pages are essential for Web structure mining as mentioned in section 2.2.1.3. Web log files are another information source which can be from mainly two sources: Applica- 24 tion Level, which can include data retrieved on the server side, the client side and the proxy side, and Web Server Level. These logs record the users’ behaviour very clearly, being essential for 26 Web usage mining, as stated in 2.2.1.2. 2.2.2.1 Web Server Logs 28 1192.168.1.133 - - [26/Jan/2016:15:42:49 -0700] "GET /informatica/ HTTP/1.1" 200 30 1895 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:43.0) Firefox/43.0" 2192.168.1.110 - - [26/Jan/2016:15:42:50 +0000] "GET /escritorio/ HTTP/1.1" 200 843 32 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) Chrome/47.0.2526.111 Safari/537.36" 3192.168.1.133 - - [26/Jan/2016:15:43:00 -0700] "GET /informatica/" 200 1895 "-" " 34 Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:43.0) Gecko/20100101 Firefox/43.0" 12
Literature Review 4192.168.1.110 - - [26/Jan/2016:15:43:05 +0000] "GET /escritorio/Papelaria/" 200 843 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) Chrome/47.0.2526.111 Safari/537.36"2 5192.168.1.187 - - [26/Jan/2016:15:43:11 -0700] "GET /desporto/Garmin-225 HTTP/1.1" 200 6936 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) Chrome/47.0 Safari/537.36"4 Listing 2.1: Example server log file excerpt. There are mainly four formats of logs used to register the interaction events of a user on6 a website, namely: Common Log File Format (NCSA), Combined Log Format, Extended Log Format (W3C) and IIS Log Format (Microsoft). All of this formats are in ASCII text format (e.g.8 plain text files), and are used to act as a health monitor for the websites and are the main source of user access data and user feedback. Each line of an access log is representative of a hit on the10 server. This server hit is not the same as a website page hit, since each file loaded in a website page hit (multimedia content and other Web resources) corresponds to an entry in the Web server12 access log. The information present in all formats is pretty similar, and, for explanation purposes, we will use as example the Combined Log Format (used by Apache HTTP Server) [Fou08], as14 presented in 2.2. 16 1LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" 18 Listing 2.2: Combined Log Format specification. Taking the first line in the listing 2.1 as example, in this format, by order we got: •192.168.1.133 (%h): IP address of the client (remote host) that requested the content.20 •- (%l): Client machines identd information. This is most of the times empty, showing up as an "-" that indicates missing data.22 •- (%u): Username information that is only filled when accessing password-protected content.24 •[26/Jan/2016:15:42:49 -0700] (%t): Time stamp with time-zone information corresponding to the visit as it is received by the server.26 •GET / HTTP/1.1 (\"%r\"): The HTTP request done. In this case correspond to a "GET" request.28 •200 (%>s): HTTP response status code. Different results are given depend on the user privileges and request type (i.e. access protected content gives code "500").30 •1895 (%b): Size of the content transferred in bytes. •- (\"%{Referer}i\"): Referrer URL corresponds to the page the visitor was on when they32 clicked to come to the current page. There are few User Agents (explained below) who send this information to the server.34 13
Literature Review •Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:43.0)Firefox/43.0 ( \"%{User-agent }i\"): The User Agent is the representation of whatever software (normally browser) was 2 used to access the content. Data collected from server logs generally features incomplete, redundant and ambiguous data. 4 For a more efficient process, it is essential to filter this noisy data using preprocessing techniques, resulting more accurate and concise data. Data preprocessing consists on data cleaning, unique 6 user identification, user session identification, access path supplement and transaction identification [MC10]. 8 According to Mobasher et al. [MCS00] and Li Mei et al. [MC10] data cleaning task is usually site-specific and involves tasks such as merging logs from multiple servers and parsing of the 10 logs. This process consists also on remove Web log redundant and inconsistent data which is not associated with the useful data, reducing the scope of data objects. After the data cleaning, there is 12 essential to do user identification in order to identify the unique users. This can be obtained using cookie technology, user identification techniques or heuristic rules. 14 User session identification consists of dividing each user’s access information into separate sessions. This can be archived using time-out estimation approach which means that when the 16 time interval between the page requests exceeds a specified value that user has started a new session [MCS00,CD10]. 18 Due to the widespread use of the page caching technology, the users’ access path can sometimes be incomplete. To compensate this, path completion technique is used to add the missing 20 requests to the user session information. This technique can resort to the website topology in order to complete the missing paths [MC10,CD10]. 22 In the context of classifying the user sessions according to their characteristics, the work by Suchacka et al. [SC13], defines three main characteristics within three levels (short, medium and 24 long), namely: •session length: number of page requested in the given session; 26 •session duration: the time elapsed from the first page request and the last one; •mean time per page: the average time that user spends browsing each page in the given 28 session. The transaction identification is based on the user’s session recognition, and its purpose is to 30 split or combine transactions depending on the demand of data mining tasks in order to make it appropriate for the specific data mining analysis that we want to archive [MC10]. 32 2.2.2.2 Application Layer Tracking Additionally to the Web server access logs, there exists information retrieved at the application 34 level, sometimes through logs too, but with the objective to record more information about the user interaction with the website. This is accomplished generally resorting to tracking domain- 36 specific events throughout the user’s visit to the website, using built-in tracking scripts on the Web 14
Literature Review pages (page-tagging) and, sometimes, resorting also to the use of HTTP cookies. One of the most used tools for this kind of data retrieval is Google Analytics4[Cut10], but there are others like2 Piwik5, Yahoo! Web Analytics6and Clicky7. Web Server Google Analytics server User Log File Processing Engine Visitor s browser ga.js Cookies Google Analytics Dashboard Database Figure 2.5: Google Analytics functional scheme [Cut10]. Using as example the Google Analytics process [Cut10], as shown in Figure 2.5, starts by4 the placing of a JavaScript snippet (page tag) in the Web pages that we want to track (Google Analytics Tracking Code - ga.js). The data collection starts when the user requests a page from a6 certain Web server, and the browser processes the response data. In this phase, the browser may contact also other servers that may contain parts of the requested page, like multimedia resources8 and scripts (as is the case of ga.js). Once GATC is loaded it starts identifies attributes of the visitor and her browsing environment,10 such as how many times that user as visited the website, where he came from, his operating system, his Web browser, among other information. After collecting this base data, the GATC sets or12 updates a number of first-party cookies where it stores information about the user. After this steps the data collected is sent to Google with the information that a visitor has viewed a certain page on14 the website and additional data like events, pageview duration, and others that can be selected in Google Analytics configurations dashboard, including specific add-ons for e-commerce websites.16 When Google Analytics server receives the data it stores the data in, for example, a logfile. Each line in this file contains numerous attributes of the information sent to Google, including:18 •When the data was collected (date and time); •Where the visitor came from (i.e. referring website or search engine);20 •How many times the visitor has been to the site (number of visits); 4http://analytics.google.com/ 5http://piwik.org/ 6http://Web.analytics.yahoo.com/ 7http://clicky.com/ 15
Literature Review •Where the visitor is located (geographic location); •Who the visitor is (IP address). 2 After storing the information in logfiles, the data collection process is complete. Now the process continues on the Google Analytics processing engine which parses and interpreters the 4 logfile. During processing, each line in the logfile is split into pieces, one piece for each attribute of the entry in the file. Google Analytics turns each piece of data into a data element called a 6 field. Later on, the fields are transformed into dimensions. For example, the IP address becomes the Visitor IP field and the city that the visitor is visiting from becomes the Visitor City field 8 and the City dimension. This transformation is needed since Google Analytics will use fields to manipulate the data and dimensions to build the reports using pattern discovery techniques, as 10 presented in 2.2.4. After this processes the data is saved in a database and if a user requests a report, the appropriate data is retrieved from the database and sent to the browser. 12 2.2.2.3 Web Crawlers When collecting data from a given website pages and structure, the most common approach is the 14 use of Web crawlers. A Web crawler is a program that, given one or more base URLs, downloads the Web pages associated with these URLs, extracts any hyperlinks contained in them that have 16 not been found before, and recursively continues to download the Web pages identified by these hyperlinks [Naj09]. 18 In practice, retrieving the content of a single Web page is an easy and fast process. Here is a simple crawler that uses the command-line tool wget: 20 1wget -r --html-extension --convert-links --mirror --progress=bar --no-verbose --no- 22 parent --tries=5 -level=5 $http://example.com/ 24 Start Initialize frontier with seed URLs Check for termination Pick URL from frontier Fetch page Parse Page and Information Storage Add URLs to frontier [done] [no URL] Crawling Loop End Figure 2.6: Flow of a basic sequential Web crawler [PSM04]. The basic concepts of a sequential Web crawler are shown in Figure 2.6 [PSM04]. The crawler maintains a list of unvisited URLs known as the frontier. This list is initialized with seed URLs 26 16
Literature Review (one or more). In each crawling loop the program chooses the next page to crawl from the frontier list, fetch the corresponding content and parses it, in order to retrieve URLs and store all the2 information/content needed. Finally, the new and unvisited URLs are added to the frontier. The process can finish when a certain number of pages has been crawled or when the frontier is empty.4 As suggested in section 2.2.1.3, the Web can be seen as a large graph with pages as its nodes and hyperlinks as its edges. Because of this, Web crawling can be considered as a graph search6 problem. One of the most important components of the crawler is the frontier, the to-do list of a crawler,8 that contains the URLs of unvisited pages. In graph search terminology, the frontier is an open list of unexpanded (unvisited) nodes. The frontier can be implemented as a FIFO queue, resulting in a10 breadth-first crawler, that can be used to blindly crawl the Web. In this case, the next URL comes from the head of the queue and new URLs found is added to the queue tail. The main problem12 with this approach is that we need to resort to linear search in order to find out if a newly extracted URL is already on the frontier, and, in certain cases, this can be a costly operation. On alternative14 approach to the frontier is the use of an hash-table [PSM04]. Other alternative consists on implementing the frontier as a priority queue, resulting in a pref-16 erential crawler, also known as a best-first crawler. The priority queue may be a dynamic array that is always kept sorted by the estimated score of unvisited URLs. At each step, the best URL is18 picked from the head of the queue. Every time a page is fetched, the URLs are extracted from it and scored based on some heuristic. Sometimes, a crawler may encounter a spider trap that leads20 it to a large number of different URLs that refer to the same page. One way to reduce the impact of this problem is to limit the number of pages that the crawler accesses from a given page [PSM04].22 After choosing the best approach to dealing with the frontier, we need to fetch the HTML page corresponding to each URL, using an HTTP client, sending an HTTP request for a page and24 reading the response. After the page being fetched, we need to parse its content to extract information that will be used to fill the frontier. Parsing may imply simple URL extraction, following the26 W3C standard for declaring links in web documents [Con], or more complex processes, tidying up the HTML content in order to analyse the HTML tag tree. Parsing might also involve steps to28 convert the extracted URL to a canonical form, remove stop-words from the page’s content and stem the remaining words. The process of identifying HTML tags for declaring links in a given30 HTML document, including the associated attribute-value pairs, is known as URL extraction and canonicalization [PSM04].32 The most important component on URL extraction and canonicalization as well as in other types of information extraction from HTML pages is the of the parser to be able of dealing with34 messy markup and be resilient to errors. It is important to consider besides the normal than ASCII text, it is also common to run across Unicode URLs and content. Additionally, it is common to36 find spider traps that look like the dynamic content but are actually an infinite generation of links [Liu11].38 After retrieving the HTML content, we are now able to navigate through the page and the DOM tree to find specific parts of the page that are important or relevant, and converting then that40 17
Literature Review information into a structured form, like JSON or another formal data schema, enabling us then to storage it in some kind database [Mat12]. 2 Due to the growth of the World Wide Web, websites have now a tremendous amount of pages, being this situation even more common in e-commerce websites due to the large catalogue of 4 categories and products. So, it becomes a hard task to crawl this sites in a reasonable timeframe [Yua09]. In response to this problem, some alternatives as been presented, as the one from 6 Yuan [Yua09], that proposes a multi-threading web crawler for e-commerce websites. Another approach, as proposed by Micarelli et al. [MG07], that consists of developing a focused crawler 8 that only retrieve documents that fit into a certain topic of interest, reducing the computational and network requirements. 10 2.2.3 Web Data Extraction The data present in the website’s page content is mostly semi-structured and/or unstructured data. 12 This results in the need of making this Web pages the more human readable and user-friendly possible, and not so machine understandable. In order to understand and retrieve the useful infor- 14 mation from this pages and transform it into structured data formats, it is needed the use of certain automatic techniques to extract, interpret and present the data, being this process called web data 16 extraction [PE11]. A Web page content is normally embedded in HTML and formatted using CSS. The purpose 18 of HTML is to structure the content, but this structure is totally dependent on the website’s author, so there is no standard structural design for e-commerce websites or any other website, being the 20 structure irregular for each website and, sometimes, between website’s pages [KFT14]. Also, as today, websites do not only contain static HTML, but also dynamic content that appears differently 22 to different users and interactive elements like forms, making the extraction process even more complex [PE11]. 24 The web data extraction process is accomplished by the use of wrappers. While every website uses its own way of build and display content to the user, the structure is relatively similar 26 on all pages of a kind on a website [Liu11,PE11]. For example, every product page on a given e-commerce website has a certain degree of similarity between them. For this reason, a wrap- 28 per designed for a page should work on all pages of that kind. Liu [Liu11] lists three different approaches to generating wrappers, namely: 30 •Manual approach; •Wrapper induction; 32 •Automatic extraction. 2.2.3.1 Manual Approach 34 The manual approach consists of observing a page and the respective source code, with a human trying to find some patterns in similar pages and writing then a program to extract the target 36 18
Literature Review data from those pages. This process has become simpler due to the appearing of several pattern specification languages, allowing the programmer to more easily define the fields to extract data2 from [Liu11]. The most common approach when manually extraction information from pages is using se-4 lectors [KFT14,PE11]. A selector is an expression which is able to describe a single or a list of items on a document, in this case, HTML documents. There are mainly tree types of selectors6 used when wrapping web content [PE11], namely: •XPath expressions: Extract a data value using an XPath expression. XPath expressions8 are used in lots of existent wrapper systems, but due to the increase of complexity of the websites it has become less useful than before [KFT14].10 •CSS selectors: This enable the extraction of data values from HTML documents navigating through the page’s DOM tree. This is much less complicated of write than XPath expres-12 sions, but they are nearly as expressive [KFT14]. •Regular Expressions: Regular expression enables us to extract data from strings, doing14 string matching. This is useful when the information that we want to extract is mixed with other text, or, when we can’t build the DOM tree from the HTML, which can happen, for16 example when the HTML code does not follow any standard [KFT14,PE11] Taking use of the selectors, we are capable of specifying the locations of the specific data18 that we want to extract on4 a given type of page, and transform the data into structured an easily accessible data.20 2.2.3.2 Wrapper Induction Wrapper induction is a supervised learning approach to extract information from web pages, being22 a semi-automatic approach. The human is responsible for creating a template, often by browsing a website and recording his actions, and proceed to the labelling of data records. After the manual24 process of labelling some data records, using this set of labelled training examples, the wrapper generation tool generalises the rules and applies them to similarly formatted pages. This can still26 be a very time-consuming task, especially if there is a lot of differently structured pages in the website [Liu11]. Another common problem is that, since the web is dynamic, the content and28 structure of the pages of a given website can change and it is needed to adapt and re-train the wrapper [PE11].30 In this category of wrappers, the first phase consists of extract data from a page, building a tree representation of the same. A sample of the type tree for a product page is given on Figure 2.7. A32 page can be seen as a sequence of tokens S(e.g. words, numbers and HTML tags). The extraction is archived using a tree structure called embedded catalogue tree (EC tree), as shown in Figure34 2.8, which models the data embedded in an HTML page. The tree root is the document containing the whole token sequence Sof the page, and the content of each child node is a subsequence of its36 19
Literature Review Tuple: Product String: Name Tuple: Details String: Model Double: Price String: Description Figure 2.7: Sample type tree of a generic product page [Liu11]. Page Name Details Model Price Description Figure 2.8: Sample EC tree of a generic product HTML page [Liu11]. parent node. For extracting the data, the wrapper uses the EC description and a set of extraction rules [Liu11]. 2 The second phase consists on to develop the wrapper learning algorithm, responsible for generating extraction rules. To generate the start rule for a node in the EC tree, some prefix tokens 4 of the node are identified, as the landmarks, that can uniquely identify the beginning of a node. To generate the end rule for a node, some suffix tokens of the node are identified, as the ending 6 landmarks. To extract useful information from the data records into structured data formats, data extraction rules are applied to each record [Liu11]. 8 2.2.3.3 Automatic Extraction Automatic extraction is an unsupervised approach for information extraction from web pages con- 10 tent. Using as input one or more pages, it automatically finds patterns or grammars in it, using them for extracting data. Since it is human-independent, it can easily scale up to a huge number 12 of pages formats and even different websites [Liu11,PE11]. Automatic extraction is possible because data records on a website are usually encoded using a very small number of fixed templates, 14 making possible find these templates by mining repeated patterns in multiple data records [Liu11]. One approach to accomplish automatic extraction is through string matching and tree match- 16 ing, that tries to find the encoding template from a set of encoded instances of the same type [Liu11,ZL05]. In the case of HTML documents, the common way to accomplish this is by de- 18 tecting repeated patterns from the HTML encoding strings, string matching. Tree matching is also useful since HTML encoding strings also form nested structures due to their nested HTML tags, 20 being this nested structures called DOM trees [Liu11]. 2.2.4 Pattern Discovery and Analysis 22 Pattern discovery consists on retrieving effective, novel, potentially, useful and ultimately understandable information and knowledge using mining algorithms. The methods for pattern discovery 24 include, among other techniques, exploratory data analysis, classification analysis, association rule discovery, sequential pattern discovery and cluster analysis. 26 20
Literature Review The pattern analysis complements the pattern discovery process by focusing on the filter and choose the most useful and interesting patterns found during the pattern discovery, in order to2 select the most valuable models for the business [MC10]. 2.2.4.1 Exploratory Data Analysis4 Exploratory data analysis (EDA) is an approach to analysing data sets with the goal of learning about its main characteristics, general patterns, and tendencies. EDA generally resorts to methods6 like graphical displays and suitable summaries to get a grasp on the most relevant content of the data [GHP07]. This allows a deeper overview of the data, retrieve relationships between variables8 and reveal interesting subsets of the data sets. In order to apply EDA methods, the data is aggregated in measurable variables such as days,10 sessions, visitors or country of origin. The insights on the data, like most visited pages by day, average view time of a page, the average length of a path through a site, most frequently accessed12 pages, common entry and exit page, can be extracted with the application of typical statistics methods over the data. Although this analysis can be superficial and let some important knowledge14 undiscovered, the information retrieved can be used for guidance on future work over the data, improving the efficiency and, possibly, improving the results of the data mining.16 As stated by Gentleman et al. [GHP07], there are essential four themes for EDA, namely Revelation,Resistance,Residuals and Reexpression.Revelation bases itself on the use of the18 suitable graphical display in order to look for patterns present in the data. Resistance methods are applied in order to mitigate the problem of extreme observations that can deviate from general20 patterns, making results more insensible to this observations. When fitting data in simple models such as a line, sometimes the useful knowledge is not fitted in this line but are the residuals that22 show up as deviations from the line drawn. This residuals we often learn about data patterns that are difficult to see by the initial data displays. Additionally, like mentioned before, sometimes24 there is a need to change the scale of the data or reexpress since the choose measure scale can hide some of the data patterns.26 2.2.4.2 Clustering Analysis and Visitor Segmentation Clustering is a data mining technique that aims to classify user or data items with similar charac-28 teristics in groups [MC10]. A cluster is a collection of records that are similar between themselves and dissimilar to records in another cluster. In the Web domain, there are mainly two types clusters30 that can be found: user clusters and page clusters. After mapping of user transactions into a multi-dimensional space as vectors of pageviews, as32 shown in Table 2.1, standard clustering algorithms like k-means can be applied in order to partition this data in groups that have similarities in them. The k-means algorithm decision is based on a34 measure of distance or similarity among the vectors. After applying any clustering algorithm, the clusters retrieved should be analysed, in order to see if they are useful and representative of the36 data. The process of cluster analysis is required since clusters may sometimes have thousands 21
Literature Review state represent the prior probabilities for transactions starting with pageviews A and B. The transitions into the final state represent the probabilities that the paths end with the specified originating 2 pageviews. For example, the transition probability from the state B to E is 24/62 =0.387 since out of the 62 occurrences of B in transactions, E occurs immediately after B in 24 cases [Sin04]. 4 A B C D E F B Start B A D 22 28 14 8 8 7 8 20 20 8 50 Figure 2.11: An example of modelling navigational trails in an aggregate tree. Another way of representing contiguous navigational paths is by inserting each path into a tree structure. This method, as presented by Spiliopoulou et al. [SF98], is part of the Web Utilisation 6 Miner system, extracts the visitor trails from Web logs and aggregates them by merging trails with the same prefix into a tree structure called aggregate tree. This aggregate tree is a trie,8 where each node corresponds to the occurrence of a page in a trail. Common trail prefixes are identified, and their respective nodes are merged into a trie node. This node is annotated with a 10 support value which consists on the number of visitors having reached the node across the same trail prefix. The main advantage of this method is that the search for navigational patterns can 12 be performed very efficiently and the confidence and support for the navigational patterns can be readily obtained from the node annotations in the tree. For example, from the trie present in 14 Figure 2.11, considering the navigational path <A,B,F>, the support for this sequence can be computed as the support of the last page in the sequence, F, divided by the support of the root 16 node: 7/50 =0.14, and the confidence of the sequence is the support of Fdivided by the support of its predecessor, B, or 7/14 =0.5. If there are multiple branches of the tree containing the 18 same navigational sequence, then the support for the sequence is the sum of the supports for all occurrences of the sequence in the tree and the confidence is updated accordingly. 20 28
Literature Review 2.3 User Profiling User profiling is the process that refers to a construction of a profile via the extraction of informa-2 tion from the website’s usage data. This is an essential part of any personalised recommendation system [Bou13]. The quality of the user profile affects the quality of recommendations directly.4 Only a system that understands user’s requirements and interests is capable of recommended satisfactory information to the user. In order to describe interests exactly, relevant information about6 the user characteristic and interests should be collected. This information is then used to build consistent user models.8 There are mainly three key areas in user profiling, as mentioned by Bouneffouf [Bou13], namely: the background of the user (acquired knowledge in different subjects), the user objectives10 and his interests. The background concerns all the information related to the user past experiences, including how the user is familiar with the working environment of the website. Objectives con-12 sists of the users need, for example, what he searches for. Finally, the user interests consist of the pages that the user has visited or other interactions that the user had on the Web page (time spend14 on a page, scroll and click events or even printing/saving a page). There exist two main kinds of user profiling, namely, behaviour-based or knowledge-based16 [HF08]. Behaviour-based approaches resort to monitoring techniques in order to get a grasp on the user behaviour activities, generally in an unobtrusive way, commonly using machine-learning18 techniques to discover patterns in their behaviour. Knowledge-based approaches design static models for users and match users to the closest model dynamically. Questionnaires and interviews20 are often used to obtain this information about the user. 2.3.1 User Profile Representation22 Modelling the user’s profile consists of designing a structure for storing all the information which characterises the user, describing his interests, his background, and his objectives. User profiles24 are generally represented as sets of weighted keywords, semantic networks, or weighted concepts, or association rules.26 2.3.1.1 Keyword-based Profiles Table 2.4: An example of a keyword-based user profile. Technology Weight 0.60 0.72 0.45 0.33 ... Keyword Laptop Smartphone Keyboard Screen ... Sports Weight 0.33 0.80 0.75 0.61 ... Keyword Football Running Ball Rugby ... Music Weight 0.37 0.45 0.55 0.23 ... Keyword Rock Flute Orchestra Symphony ... Keywords is the most common approach for representing user profiles since they can be au-28 tomatically extracted from the website’s pages and/or provided directly by the user. Keywords 29
Literature Review have generally associated weights, that consists of numerical representations of the keyword importance in the user profile. Each keyword can represent a topic of interest, and this keyword can 2 be grouped into categories in order to reflect a more standard representation of the user’s interests. An example of a weight keyword-based user profile is given in Table 2.4.4 One of the used techniques to give weights to keywords is the use of tf*idf weighting scheme. In this schema, each profile is represented in the form of a keyword vector, and the retrieved Web 6 pages by the system, e.g. in response to a search, are converted to similar weighted keyword vector. Created vectors are then compared to the profile using the cosine formula, and only the 8 corresponding pages for those vectors that are closest to the profile are then passed on to the user [TPSA07]. 10 Besides the simplicity of implementation of keyword-based profiles, the use of several vectors to represent the profile permits to take into account the different interests and their evolution 12 through time. On another side, the default version of this representation is in the lacks of structure and semantic (no connexion between terms). Additionally, one of the main drawbacks in 14 keyword-based profiles is that many words have multiple meanings (polysemy) which can conduct to inaccurate profiles since the keywords in the profile are ambiguous [GSCM07]. 16 2.3.1.2 Ontologies Representation An ontology, as specified by Middleton et al. [MSDR04], is a conceptualisation of a domain into 18 a human-understandable, but the machine-readable format, representation of entities, attributes, relationships, and axioms. Ontologies can, for example, be a rich conceptualisation of the work- 20 ing domain of an e-commerce website, representing the main concepts and relationships of the customers activities. These relationships could represent isolated information, such as a customer 22 last purchased item, or, they could represent an activity, such as the set of visited pages on a session. Ontologies are, in this way, used to refer to the classification structure and instances within 24 a knowledge base. Ontology-based user-profiling approaches have been used to take advantage of the knowledge 26 contained in ontologies, instead of attempting user-profile acquisition. This representation, as stated by Godoy et al. [GA05], allows overcoming the limitations of the connexion representation, 28 presenting the user’s profile in the form of a concepts hierarchy. Each class in the hierarchy represents the knowledge of an area interesting to the user. The relationship (generalisation / 30 specification) between the elements of the hierarchy reflects a more realistic interest of the user. This approach has also some problems related to the heterogeneity and diversity of the user’s 32 interests (i.e. users may have different perceptions of the same concept, which leads to inaccurate representations). 34 2.3.1.3 Semantic Network Profiles Semantic network profiles, as presented by Bouneffouf [Bou13], appears as a representation solu- 36 tion capable of address the polysemy problem present in some representations. In this approach, 30
Literature Review Painter 3.4 PAINTING 7.89 Color 3.6 POLLUTION 3.45 ENVIRONMENT 5.6 Air 3.2 RESTAURA TION 3.2 Classification 3.2 SCULPTURE 4.56 Museum 8.1 Painter 3.4 Chisel 5.2 11.6 2.1 9.6 12.9 4.78 8.00 5.2 15.3 3.5 1.0 Sculptor 5.2 9.5 Figure 2.12: An example of a user profile based on semantic networks. the user profiles are represented by a weighted semantic network, in which each node represents a concept. One of the approaches to building this representation is the Hybrid User Modelling2 System, proposed by Micarelli et al. [MS04]. In this technique, each user profile consists of three components, a header that includes the user’s personal data, a set of stereotypes and a list of in-4 terests. The stereotype consists of a prototypical representation of the user, containing a set of interests represented by a frame of slots. Each one of this slots comprises three concepts: domain,6 topic and weight. The domain identifies a user’s area of interest, the topic is the specific term that the user used to identify the interest, and a weight that represents the user’s degree of interest on8 the topic. The user model is, in this way, a structure embodying the semantic links and justification links as well as domain,topic, and weight.10 The semantic links include lists of keywords co-occurring in a page associated with the slot and the respective degree of affinity with the topic. The profile is given as a set of semantic networks,12 where each slot is a planet, a single and representative weighted term for a given concept, and each semantic links is a satellite, subsidiary nodes linked to the planets that represent additional14 weighted keywords associated with the concept, as shown in the example present in Figure 2.12. 2.3.1.4 Concept-based Profiles16 Concept-based representation of user profiles is similar to semantic network-based profiles. This is due to both of the solutions use conceptual nodes and establishes relations between them as a18 way to represent profiles, with the difference that, instead of the nodes represent specific or sets 31
Literature Review of related words, in concept-based profiles, the concepts are abstract topics interesting to the user. Besides this similarity, this representation also uses ideas from keyword-based profiles in the way 2 that its used a vector of weight features, but instead of features being used to represent keywords are used to represent concepts [GSCM07]. 4 Home Homemaking 0.05 Entertainment 0.01 Cooking 0.49 Videos 0.1 Lessons 0.3 Figure 2.13: An excerpt of a concept-based user profile [GSCM07]. An approach to representing this kind of profiles is the use a hierarchical view of concepts, as referred by Gauch et al. [GSCM07], since it enables the system to make generalisations, easily 6 adapt levels of the scheme and dynamically change. The most simple concept hierarchy based profiles are built from reference taxonomy or thesaurus. More complex ones are created using 8 reference ontologies, where relationships between concepts are explicit specified, resulting in a richer profile, containing information about a wide variety of different relationships. An example 10 of this approach is given on Figure 2.13. 2.3.2 User Profile Construction 12 User profiles are constructed from information sources using a variety of techniques based on machine learning or information retrieval, trying to build a profile which is the closest reflection of 14 the user interests and characteristics. Depending on the user profile representation picked, different approaches are needed in order to build them. Sometimes this become an even complicated task, 16 since, on one side, users may not be sure in his own interests, and, on the other side, often the user does not want or even can’t do efforts in order to create its profile [Bou13]. 18 The most simplistic approach for building the user profile is to explicit ask the user for keywords representative of his interests. This approach depends totally on the user because if he is not 20 32
Literature Review familiar with the system or the vocabulary used, it becomes a difficult task providing the proper keywords representative of his interests. One improvement to this technique is, as the same time2 that the user is navigating trough pages, suggesting keywords that may match the user interest, being incumbent upon the user the choose on whatever keywords are more interesting to them.4 Additionally, we got the machine learning approach which is, in the majority of the cases the most appropriated solution, since, most of the times, is not reasonable to ask a user a set of keywords6 describing his preferences, but instead observing the user’s behaviour through his interactions with the website in order to learn his profile [Bou13].8 Depending on the representation picked to mirror the user profile, there are different necessities for constructing them. In keyword-based profiles, the user profiles are initially created by10 extracting keywords representative of the website’s pages that the user visited and then it’s taken into consideration the most important keywords in each page, attributing to them a corresponding12 weight. The simplest approach to keyword-based profiles is the construction of a single keyword profile for each user. But, generally, is a better approach use multiple keyword profiles for each14 user, one per interest area, resulting a more accurate picture of the user. Using as an example a user with the interest in Sports and Cooking. If a single keyword vector is used it will point to the16 middle of this two different topics, given a user which is interested in athletes who cook or people who cook for Football games, but if instead is used a pair of vectors as representation, this two18 interest will be independent, representing the user more accurately [GSCM07]. Semantic network-based profiles are typically built by collecting explicit positive or negative20 feedback from users. As in the case of keyword-based profiles, the profile is built using keywords that are extracted from the user-rated pages. The main difference is that every keyword is added to22 a network of nodes, in which each node can represent an individual word or, in some approaches, a particular concept, and its associated words [GSCM07].24 In ontologies representation, the user profiles are created by automatically and implicitly analysing the user navigation habits. A profile is essentially the reference ontology whose con-26 cepts have weights indicating the perceived user interest in each of them. The pages that the user visits are automatically classified into the concepts, contained in the reference ontology and the re-28 sults of the classification are accumulated. By this process, the concepts in the reference ontology receive weights based on the amount of related information the user has browsed [GA05].30 Concept-based profiles differ from semantic network profiles in the way that they describe the profiles in terms of pre-existing concepts, instead of modelling the concepts as part of the user32 profile itself. Although, this profiles still depend on some way to determine which concepts fits in a certain user based on their feedback. This information can be collected from user feedback on34 pre-classified pages, or, instead, by collecting feedback on a wide variety of pages and then apply text classification techniques to find the concepts present in each page [GSCM07].36 33
Literature Review 2.4 Conclusion From the literature review, several conclusions could be made. E-commerce is a relatively new 2 field (as the Internet itself), but is increasing its impact, with an ascendant number of transactions and values every year. E-commerce site owners in order to increase profits and number of sales 4 resort to Web personalization for each user, using target marketing and recommendation systems. Here, data mining appears as a crucial component, where techniques have been applied to the Web 6 in order to understand the structure and content of the Web, as well the user behaviour. This focus of data mining resulted in the creation of a sub-area inside the data mining called Web mining, 8 which itself splits into three different, but sill connected areas, namely: Web content mining, Web structure mining, and Web usage mining. 10 Different data mining techniques and processes have been applied, and adapted, in order to meet the necessities of Web mining, and new tools for data collecting were born, like crawlers. 12 Problems associated with Web mining also show up, with solutions been discovered and applied, for example, the path completion technique applied to incomplete navigational paths. Also, well- 14 known processes of pattern discovery have been applied to the Web, like association rule mining, and new were born, like navigational pattern analysis. 16 In order to map archetypical website users, through profiles, various representation showed up as the result of research in the area, each one more adapted to specific cases and with different 18 degrees of complexity. Although, there is a lack of research for the cases when we want to collect and represent all the website data, not only the users but also the pages content and structure, 20 establishing relationships between all the different data sources. In this context, we think there is the lack of an established process or guidelines for getting a grasp on the e-commerce website, and 22 a possible process and guidelines for this described in chapter 4, as a possible solution to mitigate this lack of literature. 24 34
Chapter 3 Problem Statement2 E-commerce has a great role in our economy, as it can be seen by a large number of economic transactions that happen everyday over e-commerce websites [Sta16]. In this context, the e-4 commerce websites owners use diverse techniques to influence the user actions over the website, improving sales and increasing profits. Generally, the website’s owners resort to companies that6 provide machine learning services to make an analysis on the website, including the archetypical users analysis, and to develop models and algorithms that enhance the website’s marketing8 campaigns. When the machine learner partitioner is confronted with a new, and previously unknown, e-10 commerce website, the data scientists need to go through the website, understanding not only the business but also how the site is built, pages are interconnected and how the content is present to12 the user. They also need to analyse the logs from any event record system that the website may have enabled, to understand how the users navigate the website, discovering usage patterns and14 habits. In some, but less common, cases, the data scientists even need to enable a tracking system on the website, to discover user access patterns and common navigational trails.16 The process of pattern discovering and analysis applied to websites and its users are known as Web mining [Liu11], and it consists on analysing a website structure (Web structure mining),18 pages content (Web content mining) and usage data (Web usage mining). This process gives the machine learning partitioner the early knowledge needed to develop any strategy to increase the20 website’s owner profits. By creating a process capable of applying the Web mining most common techniques to an e-commerce website, we can potentially reduce the time and resources needed at22 an early stage by the service providers. This can also reduce the risk of some data relations and pattern going unnoticed that could have an important role on the data scientists final output.24 This chapter presents in the Section 3.1 an enumeration of the principal goals of this dissertation. In Section 3.2 are stated the principal difficulties and problems that we face, and, are also26 presented solutions accordantly to the literature review. At last, some conclusions are given in Section 3.3.28 35
Problem Statement 3.1 Goal Statement The dissertation principal goal is to get a grasp on the e-commerce website, the comprehending 2 structure as well as the pages content, and about the website’s users. This principal goal can be broken down into smaller objectives as it follows: 4 1. Collect the website structure, representing the pages and interconnections, as a directed graph; 6 2. Extract relevant information from the website’s pages and categorise them into pre-defined types; 8 3. Gather information about the websites users: •Identify different users and sessions, including information about navigational user 10 flow on the website; •Determine the users preferences and most visited page types; 12 •Characterise user sessions by established metrics; 4. Cross different information sources in order to find patterns and enrich the existent data; 14 5. Discover the website’s archetypical users; 6. A consistent model representing all the website information designed to be easily adaptable. 16 We consider that the data scientist after having this information in his possession is able to provide more refined models and algorithms to the e-commerce site owner. 18 3.2 Issue Analysis and Target Conditions The goal of this dissertation embraces some challenges, especially in the area of the web data 20 mining. Due to the web heterogeneity, every website has unique characteristics depending on the website’s designers and authors. But, since every e-commerce websites have a common tar- 22 get purpose of listing and selling goods to customers, these websites have some similarities in organization and content available [Pur11]. 24 The area of web mining is an already well-studied field, and Liu [Liu11] makes a deep overview in the area, presenting the common strategies when mining the web as well as com- 26 mon problems and possible solutions. Following the dissertation goals, the first challenge that we face is how to collect the website 28 pages and structure, due to the dimensions of some websites. In this case, the typical approach is via a crawler, that can work differently depending on the final objectives of the crawling task as 30 defined by Pant et al. [PSM04]. The next objective is to extract useful information from pages and categorise the pages taking 32 into account this information. To accomplish this task the process consists of using a wrapper 36
Problem Statement capable of extracting the information, and different approaches can be used when to design a wrapper, as presented by Eckerstorfer et al. [PE11].2 At last, we got to understand the website’s users. For this, we need to preprocessing the usage data, extracting individual users and sessions [CD10], discovering patterns like navigational flows,4 preferences and typical visited pages. After the extraction being complete, we may proceed to its analysis and finish with the extraction of the website’s archetypical users [Liu11]. An essential6 component on characterising sessions by its attributes is presented by Suchacka et al. [SC13]. The resultant model should represent all the collected and processed data and be easily adapt-8 able for new information or new data crossing tasks. By this, the main challenge here is to design a model in a way that is capable of giving a representative overview of the website, being this in-10 formation model useful for any future data mining or machine learning task, including simulations of the users interaction with the website [Dua16].12 3.3 Conclusion This chapter approaches the main goals of this dissertation, detailing the objectives and challenges,14 and gives a contextualization of this objectives with the information collected in the literature review. It was noticed that large part of the challenges here addressed were already approached16 in past research and solutions developed. By this way, the approach realized in this dissertation to accomplish the main goals, as detailed in Chapter 4, reflect some of the well-studied solutions18 developed by other authors. The problem here addressed can facilitate the data scientists task when faced with a new e-20 commerce website, giving, in a structured flow, that extracts the useful information about the website and users. This can be really useful when a new website is presented to the machine22 learning practitioner and want to quickly get a grasp of the website structure, content and users. 37
High-level Overview Firstly we need to define what are the common page types on an e-commerce website and what information can be extracted depending on each type. For this purpose it was chosen a set of 2 common page types in e-commerce websites [Coo00], as it follows: •Generic Page: Includes all the pages with generic information, like, for example, pages with 4 delivery conditions or terms of service. •Product List Page: This page type comprehends all pages where are the present list of 6 products to the user, like, for example when making a search or seeing all the product of a given category. 8 •Product Page: Consists of website’s pages that present a specific product to the user, like, for example, a laptop. 10 •Shopping Cart Page: Are defined by the pages where the user interact with buying operations, like, for example, the page for managing the selected products for purchase. 12 Page type identification can be done either by using machine learning techniques or by the help of a heuristic. In this case, we take advantage of URL structure by retrieving information 14 from pre-defined places and by classifying them based on those places. The type page distinction is, in this way, made by taking advantage of CSS selectors and/or regular expressions [PE11]. The 16 CSS selectors allow us to select elements in an HTML file by using specific HTML patterns, in a similar way to what regular expressions do. The presence of certain human pre-defined patterns in 18 a website’s page allow us to classify the page into one of the presented page types, what concludes the pre-processing phase. 20 In order for a link to be categorised as Product Page, it must have present one or more of the following components: product description, classification by users, comment section, unique 22 price tag, product title and/or product reference. For the Product List Page type the page must contain a list of different products, and, in most times contain some kind of pagination navigation 24 functionality. The Cart Page type is identified by containing one or, in most cases, more than one of the following: total price tag, the list of products, paying and check-out buttons. At last, any 26 page that does not fall into one of the previous is classified into Generic Page type, but can be also detected a presence of certain keywords in the page text using regular expressions, like, for 28 example, "Terms and Conditions", "Customer Services" or "Delivery Options". 4.2.2.2 Information Post-processing 30 After completing the information collection and pre-processing phases, we are now able to extract specific page information depending on what page type it falls into. Depending on the e-commerce 32 website that we are dealing with, the information that we are capable of extracting can vary. For any page type there is common information that can be extract, namely, information if the page 34 has dynamic parts like, for example, suggested products sections, and also, information if the page has a link to the shopping cart page. 36 44
High-level Overview For pages that fall into the Product Page type, we can, generally, extract the following information about a product [GR11]:2 •Name: Any product page has a title or name associated with the product presented to the user.4 •Category and Sub-categories: Mostly of the product pages has a breadcrumb trail with the product category and sub-categories. This is presented to the user as a navigational aid on6 the website. •Price and Concurrency: Associated with any product there is one or more prices (i.e. in the8 case of price discount) and its concurrency. •Description: The product description.10 •User Classification: Some e-commerce websites have the functionality of giving ratings or classifications for products and this information can be extracted also.12 In the case of Product List Page type we can usually extract the categories of the product presented, using the breadcrumb trail present on those pages. Finally in Generic Page types we14 can extract the title of the page that describes the information presented. Cart Page type of pages does not give us any extra information that we can extract beyond being a page that displays16 shopping cart related information. 4.2.3 Website Usage Mining18 The interaction of the users on a given e-commerce website is recorded in the form of logs. This information present in this logs as well as the format is different depending on the layer that these20 interaction events are recorded and the technologies used [PCP11]. The objective of this process is to be able of dealing with this differences, and a set of essential fields were picked, being this22 one common to all log formats and origin layer. Within this, the essential information for identifying different users, sessions, and navigational24 flow is extracted from the logs into a standard format. Then using this uniformed information it is possible to split the records by user, and then split by sessions [MCS00].26 4.2.3.1 Information Retrieval and Pre-processing The website’s usage logs are the result of the user interaction in the website during a time span that28 can correspond to, for example, the visits and iterations of all users on a website during a month. The user navigation through the website can be recorded at the application layer, using, for30 example, JavaScript snippets on all the website’s pages, or/and they can also be recorded at server layer when the HTTP requests reach the server. On one hand, data captured at the application32 layer is generally more rich in information and is stored using more advanced data formats like, for example, JSON or XML. On the other hand, data collected at the server layer corresponds only34 45
High-level Overview to the information present on each HTTP request, being more poor and simple, usually stored in plain text files on the server [Mih09]. 2 Due to the differences in how the events are recorded in the two layers and the different information present in them [PCP11], it was set a set of fields commons to all the logs format analysed. 4 By pre-processing each entry of the log files, it is created a new entry consisting of the following fields: 6 •User identifier: An unique identifier associated to each user request. •Time stamp: A time stamp identifying the date and time of a user request. 8 •Request URL: The visited page by the user. 4.2.3.2 Information Post-processing 10 After pre-processing the log data into a uniformed entries, we are now able to identify unique users using the User identifier field of each entry, as well as the different user sessions using the 12 Time stamp data and, also, the website’s pages visited by the user. With this information, we are capable of building a user profile that corresponds to the sessions of a certain user. 14 A new session starts when a certain user makes the first request to one of the website’s pages. This session lasts from that moment until the last request made is a pre-defined time distant from 16 a new request. Each session has now information that includes: •User navigational trail: Refer to the sequence of website’s pages that a user visits during a 18 session [MCS00]. Can be useful for Sequential and Navigational pattern analysis as showed in Section 2.2.4.20 •Session duration: Corresponds to the total time that a user session lasts [SC13]. •Session length: Corresponds to the total of visited pages by the user on that session [SC13]. 22 •Mean time per page: Refers to the mean time that the user spends on each page during a session [SC13]. 24 In addition to the information extracted from each session, the user profile now has information about the total of page views of a user across all sessions, average session time and average mean 26 time per page. After the extraction of this fields, the users sessions are analysed and categorized, using the 28 three basic characteristics determined by Suchacka et al. [SC13], namely, session length,session duration,mean time per page, and classify this characteristics into three different degrees, namely, 30 short,medium and long. This categorization is based on the interval of values of certain parameters as showed in equations 4.1,4.2,4.3, using the values intervals proposed by Suchacka et al. [SC13]. 32 session length = short,if number of requests =1 medium,if number of requests ∈[2,13] long,if number of requests ≥14 (4.1) 46
High-level Overview session duration = short,if session duration =60s medium,if session duration ∈[60,960]s long,if session duration ≥960s (4.2) mean time per page = short,if mean time per page =60s medium,if mean time per page ∈[60,180]s long,if mean time per page ≥180s (4.3) 4.3 Website Data Crossing Being the process of retrieving information about an e-commerce website’s structure, page’s con-2 tent and users completed, as well as this information processed into structured and uniformed data formats, we are now able to cross the information from this different sources and get a better4 overview of the website. On one hand, crossing information about the website graph structure and the categories ex-6 tracted from the website’s pages content, makes possible getting the website category tree. On the other hand, crossing information from the website’s pages content and usage records we’re able to8 build keyword-based user profiles. 4.3.1 Website’s Category Tree10 Homepage Sports Electronics Cameras TVs Hiking Gear Computers Tablets Sportswear Footwear Fishing Hunting Laptops Desktops Rugby Boots Running Shoes Basket Shoes Figure 4.2: An example of a website’s category tree. After extracting the categories from the website’s pages content we have a set of categories on each page, and by taking in consideration the directed graph structure of the web we can build a12 tree of categories. Each category is represented by a node, and each node is connected at most to 47
High-level Overview one parent node, that corresponds to a more generic category, and can have an undefined number of children nodes that correspond to more specific categories. An example of a website’s category 2 tree is presented in Figure 4.2. 4.3.2 Keyword-based User Profiles 4 Using the information extracted from the website’s pages content, namely the product category information, we are now able to build keyword-based user profiles, in which the categories are the 6 keywords representative of the users preferences on the website. It is associated with each category with an affinity level (percentage) that represents the number of page views on pages of a certain 8 category (e.g. Electronics)over the total page views of the user across all sessions, as expressed in equation 4.4.10 P(Electronics) = ∑Session(n) Session(i=1)∑PageView[Electronics](i) ∑Session(n) Session(i=1)∑PageViews(i)(4.4) In addition to the preferences information, it is also added to the user the ratio of page types visited. Finding what types of pages the users visit can help to distinguish the buyer users from the 12 non-buyers. For example, visiting pages of the type Shopping Cart Page can indicate that the user is more willing to buy on that website. This consists of establishing a probability of visit a page 14 of a certain type (e.g. Shopping Cart Page) over the total user page views, as showed in equation 4.5.16 P(Shopping Cart Page) = ∑Session(n) Session(i=1)∑PageView[Shopping Cart Page](i) ∑Session(n) Session(i=1)∑PageViews(i)(4.5) With this information, we have now preferences and page types information associated with each user profile, characterising the user and its typical behaviour on the website. 18 4.4 Pattern Discovery and Analysis After the collection and treatment of the data, as well as data crossing processes, we are now able 20 to build more accurate behavioural profiles on the website users, finding the website’s archetypical users. For this propose, from the options presented in Section 2.2.4, it was applied clustering using 22 the k-means algorithm, over the data. 4.4.1 Keyword-based User Profiles Clustering 24 One of the approaches for building archetypical user models was based on using the preferences information present on the built keyword-based profiles. Due to the great diversity of e-commerce 26 websites, this preferences can have more or less granularity and this can be or not a problem. For this purpose, we can use the extracted website category tree to build profiles with pre-defined 28 48
High-level Overview levels of granularity. For example, there is a lot of sub-categories under the informatics category, e.g. laptops, and there are sub-categories under the laptops sub-category, e.g. laptops with an 17in2 screen, and, depending on the website and the generalisation that we want to archive, it becomes useful to define the level of granularity that we want in the preferences before proceeding to apply4 clustering algorithms to the data, aggregating sub-categories into upper-level categories. After choosing and setting up the granularity level that we want in the categories, and being6 this our clustering variables, we can now apply the k-means algorithm to find similar users and group them into clusters [MC10,Liu11].8 At the end of this step, we can extract the centroids of each cluster that represent the preferences of the users in each cluster. In the eventuality of new data, we can easily predict in what10 cluster the user belongs to. It is also counted the number of users in each cluster, that can be used to determine the relevance of a cluster in the total of website’s visitors. In this case, the session12 categorization information is calculated as the average of all the users in the cluster. 4.4.2 Session Type Based Clustering14 This approach consists on using the session based categorization model developed by Suchacka et al. [SC13], and, using as clustering variables the session length,session duration,mean time16 per page, we can group the users applying the k-means clustering algorithm over this variables [MC10,Liu11].18 The result of this clustering step will be clusters of user with similar sessions, e.g. users that have long session length with short mean time per page and medium session duration. It is also20 preserved the number of users in each cluster, that can be used to determine the relevance of certain session types over the total visitors of the website. In this case, the preference information22 is calculated as the average of all preferences of the users in the cluster. 4.5 Website Information Model24 The final output of this dissertation consists of an information data model representing the website’s structure, content, and archetypical users. A conceptual model for this is presented in Figure26 4.3. The website category tree is defined as a relation of categories and sub-categories, in each28 sub-category can belong at most to one upper-level category. A page in this model is identified with a unique ID and a URL that is also unique, the HTML content of the page. From this page30 exists a set of outbound pages that link to other pages, representing this way the directed graph corresponding to the website’s structure. Makes also part of this concept the information about32 dynamic parts on the page, if the page has the connection to the cart page and product information like category, price and product name.34 A user contains a unique ID that represents it, a collection of sessions, preferences and typical page types, total user page views, average session time, average number of page views by session36 49
High-level Overview and average mean time per page. A session by itself contains the user navigational trail of visited pages, the session duration, mean time per page and total page views on the session. The prefer- 2 ences are represented by a category and an affinity value, and for the typical page, types visited the same concept is applied. 4 At last, the archetypical users contains information about the total users in that cluster, preferences of that user group, an average of the typical page types visited by the users in the cluster, as 6 well as the session categorization information (session time,page views by session and mean time per page). 8 Page Category URL HTML Content 1..* 0..* Page Type Is Dynamic Number of Dynamic Parts ID Page Type Type: Product List Page, Product Page, Cart Page, Generic Page Outbound Pages 0..* 1..* [Opt] Category [Opt] Price [Opt] Product Name Has link to Cart Page User Sessions Session Trail Preference Category Preferences Affinity 1 0..* 1 1..* 1..* 0..* Duration Mean Time Per Page Total Page Views Total Page Views Average Session Time Average Page Views by Session Average Mean Time Per Page Typical Page Types Typical Page Type Page Type Affinity 1 0..* 1..* 0..* 1 0..* Achetypical User Preferences Total Page Views Session Time Category Page Views by Session Category Mean Time Per Page Category Typical Page Types 1 1..* [Opt] Page Title User Count ID 0..* 0..* Page 0..1 1..* Category Figure 4.3: A representation of the website information meta-model. 4.6 Conclusion This chapter presented an high-level overview of the guidelines for extracting and structuring 10 information from an e-commerce website, as a chain process. This extraction process involves data from the pages content, website’s structure, and its usage records. There are applied different 12 50
High-level Overview techniques of extracting information from each data source due to their uniqueness. Besides the extraction and structuring component, it needs to processing this information and also to cross the2 information from the different sources, with the final objective of finding patterns and connections between the data to enhance process’s output.4 The explained approach and guidelines presented on this chapter is considered innovative in the area of providing machine learning services to e-commerce website owners. The defined6 process details a clear workflow for the extraction of information, restructuring of collected data, with special attention on data crossing and user behaviour modelling for e-commerce websites. It8 is important to state that this approach is a concept that shows the advantages of using data mining techniques, especially web mining techniques, as a facilitator to data scientists when analysing a10 new and previously unknown e-commerce website. The steps here detailed were mostly described for a generic scenario, but the proof-of-concept and experiments were conducted under simpler12 scenarios. As described, some extensions or modifications may be needed to use this approach for more heavy and complicated scenarios. Chapter 5addresses some implementation details and14 chapter 6details the conducted experiments and the results obtained. 51
High-level Overview 52
Chapter 5 Implementation Details2 This chapter covers some implementation details on the developed proof-of-concept in the context of this dissertation, with the objective of demonstrating its feasibility and applicability. The4 POC implementation architecture, technologies used and design patterns applied are here detailed. These implementation decisions were made taking into account the objective of the tool be easily6 adaptable and scalable if needed. The process described in the previous chapter was implemented using the Scala programming8 language (v2.11.8) [Ode16] and using the open source build tool SBT (v0.13.11) [Har16]. Due to the heterogeneity of e-commerce websites and the available information change between them, it10 was chosen a NoSQL database system, in this case, MongoDB (v3.2.4) [Mon16], that allows us to quickly make modifications and adapt/rewrite the documents stored in the database.12 5.1 Desiderata In the context of the development of the proof-of-concept, some base requirements were taken14 into account, since these functionalities are essential for the validation of the process and model proposed in this dissertation. The proof-of-concept requirements as it follows:16 1. Collect the data present on the website and usage records; 2. Transform the collected data into structured data formats, containing all the relationships18 and essential information; 3. Establish new relationships between the different data sources (website structure, content,20 and usage records); 4. Categorise the website’s pages by page type and category.22 5. Extract the website’s category tree; 6. Identify unique users and sessions;24 53
Evaluation 6.1 Data Sources Analysis and Description In detail, looking at the data sources used, we can split them into the two experiments, being 2 called from now on the general purpose e-commerce website and the niche dedicated e-commerce website. There are some relevant differences between the two websites, starting by the different 4 sizes, but also including the different content distribution, structure and usage logging, which make them two great sample scenarios. 6 Firstly, we have the general purpose e-commerce website that has Portugal as the main target audience. In this case, we have access to the site itself, as it is a public available data source, 8 to extract the website’s structure and content. At the usage data, we have taken a sample of the events recorded by the website application layer tracking system, being this data encoded in JSON 10 format. This sample consists of: •Sample size: 1000000 lines of events (4.95GB of data); 12 •Sample record duration: 236325 seconds (aprox. 2 days, 17 hours and 38 minutes). The second, and last, e-commerce website studied, is the niche dedicated e-commerce website 14 which target audience consists on the gaming enthusiasts costumers that are resident in Portugal. In this case, the data source consists also of the public available website, and, from synthetic 16 data representing possible user interaction with the website. This synthetic data is recorded using the Fiddler Web Debugger (v4.6.2.3) [Tel16] and reflects the HTTP requests done by a selected 18 browser, thereby mimicking the server records, giving us a plain text file as output. Since we are creating this data, we can model specific user profiles, enabling us to validate the archetypical user 20 output. 6.2 Experimental Parameters and Configurations 22 To carry out the experiments, there is the need of providing human-provided information to the proof-of-concept. This consists on a priori knowledge that is common to any e-commerce web- 24 site (and even to every website) and some website-specific information that we are capable of extracting in a couple of minutes. 26 Firstly, we need to provide some data to our crawler. In first place we need to provide the website’s base URL, the start page (generally the website homepage/root) and the website encoding 28 format (commonly UTF-8). Then it is provided with a set of ignore lists in order to optimize the crawling phase, removing unrelated and/or useless data. 30 The first ignore list contains information about multimedia resources or other common files on the web that does not bring any explorable data in the context of this dissertation (e.g. images, 32 fonts, videos, PDFs). Another ignore list includes all the ignored URL parameters. This is due to the great majority 34 of the query parameters are used, in one hand, for tracking purposes, and, in another hand, for making search and readjust query results (i.e. reorder by name, filter by price or brand). 36 60
Evaluation Finally, the last ignore list contains a list of keywords that, when present in the URL, the URL is ignored. Examples of this are, for example, the website’s associated blog, social networks2 connections or other links that point to pages that are considered irrelevant. In the page content extraction and categorization phase, as it is used a manual wrapper to4 extract the content, it is needed to pass, in the case, a list of CSS selectors, from where the information we want to extract is present, and from which it is made the categorization of pages into6 the pre-defined types. In the current experiment the needed fields were the page category (or/and subcategories)8 (i.e. ul.breadcrumb li:not(:first-child)), product price (i.e. div#price), product name (i.e. h1.product-title), a product list unique identifier (i.e. .products.view-grid), a dynamic part10 identifier (i.e. div#popular-products") and a cart page identifier (i.e. div#sc-active-cart #sc -saved-cart). Using this extracted fields we can now categorise the different pages types, for12 example, a page with a price tag is Product Page type. At the usage analysis stage, there are two configurations that we need to provide, describing14 the log file encoding format (plain text or JSON), as this format diverges between logs. Another configuration need for any kind of log is the date format string, for example, yyyy-MM-dd’T’HH:mm16 :ss.SSS’Z’. In the case of plain text files containing information about HTTP requests, we need to pro-18 vide the delimiter character, commonly the tab (\t), and the position where each required field is present in each event line (the index value). As we want to extract the User identifier,Time stamp20 and Request URL, we need to provide the index of this elements. A detail in this component is that the logs captured at server layer represent each request HTTP made to the server, not only pages22 but also the other resources like multimedia. Again, as it is needed in the crawler, we need to pass a list of ignored file extensions in order to filter this logs. For application layer logs, we just need24 to pass the key from where we want to extract the data, since, due to the key-value standard of JSON files.26 At last, we need to split our session, being set a threshold of 30 minutes from the last request to create a new session for the given user. To categorise our sessions the default values were used,28 as present in equations 4.1,4.2 and 4.3. For the clustering step, we used the per default number of 20 clusters, 20 maximum iterations30 and set a minimum threshold of 20 users to the cluster be considered. 6.3 Experimental Results32 6.3.1 Niche Dedicated E-commerce Website Applying the crawler on the Niche Dedicated E-commerce Website, we got web graph consisting34 of: •Total of website’s pages crawled (web graph nodes): 2687 pages;36 •Total of valid links found (web graph edges): 361344 links. 61
Evaluation The crawling process takes approximately 20 minutes and 38 seconds, and a visualization of the crawling process, with the frontier count and visited pages count is showed in the chart 2 on Figure 6.1. We can notice that at the beginning of the crawling we have a lot of new links discovered, but this tends to decrease as we process new pages, until there exist no more new links 4 to visit. 0 150 300 450 600 750 900 1050 1200 1350 1500 1650 1800 1950 2100 2250 2400 2550 2700 0 34 67 100 132 162 192 221 251 281 309 340 369 399 430 460 491 520 551 582 615 644 675 708 737 767 797 827 858 889 920 950 982 1012 1043 1075 1105 1135 1166 1196 1225 Number of Pages Elapsed Time (seconds) Frontier Visited Pages Figure 6.1: Chart representing the crawling of the Niche Dedicated E-commerce Website, considering the crawling time in seconds, pages visited and frontier size. After wrapping the page content, we categorized each page into the pre-defined page types. 6 This information is shown in the chart present in Figure 6.2. Crossing the information from pages types and website structure we got the category tree with: 8 •Number of base categories: 25; •Total number of subcategories: 103. 10 As mentioned before, on this website we do not have access to the usage records, and, due to that, we used synthetic data to validate the user component of the process. To realize this 12 evaluation, we defined a navigate flow and analysing the records, compared this flow with the archetypical user found. 14 The details about the synthetic data correspond to one user and three sessions. We can’t proceed to cluster over this data set because of the sample be this small, but we can construct a 16 62
Evaluation Generic Page Product List Page Product Page Cart Page Page's Count 39 897 1750 1 0 200 400 600 800 1000 1200 1400 1600 1800 2000 Figure 6.2: Chart representing the number of pages by page type on the Niche Dedicated E- commerce Website user profile and compare them to the initial interaction on the site. The original data consist of a total of 49 visited pages. The two first sessions had a medium session length and session duration2 and the third had a large session length. Every sessions is considered to have a short mean time per page. This data values are shown in Table 6.1.4 Table 6.1: Session original characteristics. Mean time per page Session length Session duration Session 1 6s 10 70s Session 2 6s 10 70s Session 3 9s 29 261s Synthetic data of the pages types visited by the user during his navigation through the website’s pages is presented in Table 6.2a. The count of the pages visited by category by the user during his6 navigation through the website’s Product Pages and Product List Pages is presented in 6.2b. Table 6.2: Input synthetic user data. (a) Page types visited information. Type Page views Generic Page 2 Product List Page 27 Product Page 16 Shopping Cart Page 4 (b) Categories visited information. Category Page views Computadores 7 Portáteis 18 Cartões de Memória 5 Motherboards 5 Teclados / Ratos 8 The resulting user profile page types information, as percentages, is presented in Table 6.3a8 and the resulting user profile categories information, as percentages also, is shown in Table 6.3b. 63
Evaluation Table 6.3: Output user profile information. (a) Page types visited information. Type Page views (%) Generic Page 4.1% Product List Page 55.1% Product Page 32.7% Shopping Cart Page 8.2% (b) Categories visited information. Category Page views (%) Computadores 16.3% Portáteis 41.9% Cartões de Memória 11.6% Motherboards 11.6% Teclados / Ratos 18.6% Resumed (average) session information on the user profile: •Average Session Time: 133.7 seconds; 2 •Mean time per page:short; •Session length:medium;4 •Session duration:medium As we can see from the input synthetic data, and the resulting data present on the resulting 6 user profile, there is a coherent representation (summary) of the original data. 6.3.2 General Purpose E-commerce Website 8 Applying the crawler on the website, we got web graph consisting of: •Total of pages crawled (graph nodes): 621303 pages; 10 •Total of valid edges found: 11044225 links. After wrapping the page content, we categorized each page into the pre-defined page types. 12 This information is shown in the chart present in Figure 6.3. Crossing the information from pages types and website structure we got the category tree with: 14 •Number of base categories: 14; •Total number of subcategories: 1618. 16 From the analysed 4.5GB of usage records, we could identify the following data: •Unique users: 111141; 18 •User sessions: 135056. •Average visited pages by user: 4.6; 20 •Average session duration: 125.07s; •Total page views: 511354 22 64
Evaluation Generic Page Product List Page Product Page Cart Page Page's Count 71 120446 500785 1 0 100000 200000 300000 400000 500000 600000 Figure 6.3: Chart representing the number of pages by page type on the General Purpose E- commerce Website From the total of unique users found, a random sample of 50000 users was extracted, and the k-means clustering algorithm applied. Using the session information as variable, we get the results2 shown in Table 6.4, corresponding to 5 clusters and 26 costumers ignored as outliers. From this data we can notice a large bounce rate within the websites costumers.4 Table 6.4: Output user clusters after clustering by session characterisation. Session / ID 1234567 Session duration short long short medium long medium short Session length short medium medium short long medium short Mean time per page short short short medium long medium medium Total costumers in cluster 23832 19171 3498 1318 1304 744 107 Applying the k-means algorithm over the user preferences we got the results presented in Table 6.5, corresponding to 5 clusters with 26 costumers ignored as outliers. From this data, we6 can notice that, in the majority of the cases, the users visited products across all categories, but there is a great representation of specific user preferences too.8 6.4 Conclusion This chapter presents the evaluation of the process developed in this dissertation, with the use of10 the developed proof-of-concept. We proceeded to test two different e-commerce websites with completely different sizes and12 complexities. By the results presented we show that this process easily adapted itself to each scenario, giving us a representation of the site structure, comprehending its pages and links, of14 65
Evaluation Table 6.5: Output user average interests after clustering by preferences. Category / ID 12345 Gastronomia e Vinhos 0.008985 0.000000 0.000057 0.000003 0.000000 Videojogos 0.061125 0.000376 0.000341 0.000385 0.000500 Electrodomésticos 0.028051 0.000331 0.990399 0.004939 0.001665 Casa e Decoração 0.049797 0.000272 0.000840 0.000245 0.000122 Informática 0.073354 0.991600 0.002164 0.042208 0.001646 Escritório e Mobiliário 0.030038 0.000177 0.000134 0.000158 0.000000 Imagem e Som 0.021971 0.002158 0.002552 0.947096 0.000406 Auto e Moto 0.065300 0.000074 0.000575 0.000424 0.000649 Desporto e Lazer 0.007411 0.000068 0.000244 0.000678 0.988864 Telemóveis e Acessórios 0.354897 0.001775 0.000455 0.003425 0.001174 Moda e Acessórios 0.052598 0.002915 0.001291 0.000017 0.000305 Livros 0.008806 0.000035 0.000000 0.000006 0.000000 Saúde e Beleza 0.104844 0.000035 0.000416 0.000072 0.002242 Brinquedos e Puericultura 0.132807 0.000149 0.000532 0.000344 0.002426 Total costumers in cluster 32352 6280 5568 4345 1431 the content by extracting categories and other relevant information from the pages (especially the product pages). 2 At last, it is demonstrated how we can find archetypical users, clustering them by session type and by preferences. To validate coherence of the user profiles created, the simple case modelled 4 with synthetic data show us that it works as it is supposed to. This evaluation shows that this process is applicable to the e-commerce websites, optimizing 6 the data scientists work, especially in the earliest stages. 66
Chapter 7 Conclusion2 From the analysis of the state of the art of research in e-commerce, web mining, and user profiling, several conclusions could be made. These conclusions essentially defined the process and our4 approach in general. The e-commerce overview gives us a brief introduction to the area for which we are devel-6 oping our process and model. Special attention was given to the e-metrics generally used on e-commerce, recommendation systems and typical e-commerce websites and structure. This anal-8 ysis shows us the importance that a consistent data model can have when improving the e-metrics or developing/testing new recommendation systems.10 Since we were dealing with the web, the data sources are so large and diverse that a new field was born, called Web Mining. The research on this area becomes crucial when retrieving12 and dealing with the data coming from the e-commerce websites. There are two main sources of information on the web, the websites, and the usage logs. This applies to e-commerce too, and,14 different techniques exists to retrieve the website’s pages and hyperlinks with the use of crawlers, extract the pages content trough different wrappers, and, finally, identify users and sessions trough16 different methods. Finally, it is important to mention that different methods were already researched and validate18 for finding patterns within the data collected, with special attention to the usage data, for which we can apply user profiling techniques to build and represent user profiles. From this profiles, we20 can apply pattern discovery and analysis techniques to find the website’s archetypical users. In order to develop an information model representation of an e-commerce website through its22 entire scope (website’s structure, content, and users) we needed to get to know the data we were dealing with.24 Since the web pages lack of a rigid structure, being the data unstructured or semi-structured, firstly we needed to retrieve this data and transforming it into structured data. At this stage, it is26 important to conclude that, despite the web being unstructured by default, there are some common guidelines that almost every e-commerce website follows, that allowed us to design a process28 that works with different e-commerce websites. In the context of this dissertation, for extracting 67
Conclusion content, a manual wrapper was used, but it can be replaced by another technique without changing the process chain. 2 Also, the Web Usage Mining techniques that can be employed on a given problem depend primarily on the available data’s characteristics. Data captured at the application layer is richer 4 than the data from the server logs, since they can capture dynamic events on the page, like when a user clicks on a button. We proceed to a simplification, in order to be capable of dealing with 6 server layer and application layer logs, filtering the data and only using common data in the two records. 8 After retrieving and structuring the data, and, in order to develop and enrich the model, we proceeded to find the connections between the different data collected. These relations are shown 10 in the diagram on fig. 4.3. It is also realized some data crossing between the different sources, in order to retrieve new data from the existent data. It is an example of this crossing the building of 12 the website’s category tree, using data from the pages and website structure. The flux of data and crossing details is given on fig. 4.1.14 In order to get to know the website’s typical users, after proceeding to the collection and processing, pattern discovery algorithms were applied to find usage patterns and similar users. In this 16 case, we applied the k-means clustering algorithm to find similar user groups. Other techniques may be applied to, to get other patterns or user models, and easily integrated into the information 18 model developed. A functional prototype was developed, which serves as a proof-of-concept of the process and 20 model. However, simplifications and choices were made, not exploring the full potential of the Web Mining, and much more work can be done in this area, improving the process and final 22 results. Using the developed POC, we proceed to apply the process to two different e-commerce web- 24 sites and model the resultant data into the theoretical model. The two websites were picked since they differ on the target market and have completely different sizes (pages and connections). 26 Within the given results, we think that this approach is valid and the model consistent enough to be applied to other e-commerce websites. The model itself is very adaptable, and new or differ- 28 ent data can easily be integrated or removed. 7.1 Main Contributions 30 Within this dissertation work, we can consider that the application of Web Mining techniques to the web, and to e-commerce, in order to improve profits, is not new, and a lot of research has been 32 done in this field, principally when dealing with usage data. So, the principal contributions of this dissertation consists on: 34 •An all-in-one process, including some of the existent research on the Web Mining field, to collect and structure data from an e-commerce website’s content, structure and users. 36 68
Conclusion •Crossing of the data collected from diverse sources to find inexplicit relations, enriching the process output.2 •An information model of the e-commerce website, containing the collected and structured information, but also containing data resulted from the crossing of different sources and4 pattern discovery tasks. This model is easily adaptable to new data, resulting from crossing different sources.6 7.2 Further Work Some further developments can be applied to each of the conceived processes. Starting with the8 crawling step, for each new page, we extract the hyperlinks present on it, without taking into consideration the relevance of the links on the page. For example, links that are inside complex10 sub-menus are possible less relevant than the links that show in the page header. For this, some kind of relevance index should be calculated and associated with each link. This can be useful12 when combining the user’s navigational path with the relevance associated with each link, but also can be used as an improvement in the crawling task.14 Another improvement to the Web Structure Mining process consists on, besides identifying the dynamic parts on a page (i.e. parts that contain dynamic connections to related products),16 associate a boolean to each link, identifying the same as dynamic or not. Advancing to the content extraction stage, the manual wrapper approach was used, but there18 is space to experiment with the other approaches, including the wrapper induction and automatic extraction presented on the literature review. Some of this alternative methods can prove to be a20 better approach retrieving data from the website’s pages. There was made two data crossings, for retrieving the website’s category tree and to enrich the22 users profiles getting information from the categories that the user visited. Here exists space to experiment with the crossing of data from other sources, for example, getting information about the24 specific products that the user visited can enable us to get knowledge like if a user has preference over some range of prices or brands.26 At the last stage, in the process of finding the website’s archetypical users, in our approach we used cluster through the use of the k-means algorithm. Here exists much more space to experiment28 with other clustering algorithms, and other pattern discovery techniques, as enumerated in the literature review.30 The output information model can be adapted to any of this proposed enhancements, but the model itself can mature to became more representative of the e-commerce website.32 Furthermore, the process here designed as well as the model can be adaptable to another website beyond e-commerce ones, getting to know how the web graph of the website is defined,34 how many pages and connections between pages exists, and how the users move and interact with the website in their sessions.36 69
REFERENCES [Yos16] Yoshida, Kenji and Nakamura, Manabu. nscala-time. Organization for nscala-time, 2016. Available at https://github.com/nscala-time/nscala-time, ver- 2 sion 2.10.0. [Yua09] Wenqing Yuan. Research on prototype framework of a multi-threading web crawler 4 for E-commerce. Proceedings - International Conference on Management and Service Science, MASS 2009, pages 1–5, 2009. 6 [Zah16] Zaharia, Matei. Apache Spark MLlib. Apache Software Foundation, 2016. Available at https://spark.apache.org/mllib/, version 1.6.1. 8 [ZDH07] Huang Z., Zeng D., and Chen H. A comparison of collaborative-filtering algorithms for ecommerce. IEEE Intelligent Systems, 22(5):68–78, 2007. cited By 89. 10 [ZL05] Yanhong Zhai and Bing Liu. Web data extraction based on partial tree alignment. ... the 14th international conference on World Wide Web, pages 76–85, 2005. 12 [ZS08] Qingyu Zhang and Richard Segall. Web Mining: a Survey of Current Research, Techniques, and Software. International Journal of Information Technology & Decision 14 Making (2008), 07(January), 2008. 76
Appendix A Additional Visualizations of2 Experiments The following images are an additional visualization of the data (exploratory data analysis) resul-4 tant from the experiments realized in the context of this dissertation. The images are the result of the proof-of-concept, with the help of GraphStream1graph library.6 1GraphStream - A Dynamic Graph Library, 2016. Available at http://graphstream-project.org, version 1.3.0. 77
Additional Visualizations of Experiments Figure A.1: Visualization of the Niche Dedicated E-commerce Website category tree. 78
Additional Visualizations of Experiments Figure A.2: Visualization of the Niche Dedicated E-commerce Website web graph. 79
Additional Visualizations of Experiments Figure A.3: Visualization of the General Purpose E-commerce Website category tree. 80