<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE article  PUBLIC "-//NLM//DTD Journal Publishing DTD v3.0 20080202//EN" "http://dtd.nlm.nih.gov/publishing/3.0/journalpublishing3.dtd"><article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="3.0" xml:lang="en" article-type="research article"><front><journal-meta><journal-id journal-id-type="publisher-id">AM</journal-id><journal-title-group><journal-title>Applied Mathematics</journal-title></journal-title-group><issn pub-type="epub">2152-7385</issn><publisher><publisher-name>Scientific Research Publishing</publisher-name></publisher></journal-meta><article-meta><article-id pub-id-type="doi">10.4236/am.2018.96049</article-id><article-id pub-id-type="publisher-id">AM-85744</article-id><article-categories><subj-group subj-group-type="heading"><subject>Articles</subject></subj-group><subj-group subj-group-type="Discipline-v2"><subject>Physics&amp;Mathematics</subject></subj-group></article-categories><title-group><article-title>
 
 
  Anomaly Detection of Store Cash Register Data Based on Improved LOF Algorithm
 
</article-title></title-group><contrib-group><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Ke</surname><given-names>Long</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Yuhang</surname><given-names>Wu</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Yufeng</surname><given-names>Gui</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref><xref ref-type="corresp" rid="cor1"><sup>*</sup></xref></contrib></contrib-group><aff id="aff1"><addr-line>College of Science, Wuhan University of Technology, Wuhan, China</addr-line></aff><author-notes><corresp id="cor1">* E-mail:<email>guiyufeng@whut.edu.cn(YG)</email>;</corresp></author-notes><pub-date pub-type="epub"><day>05</day><month>06</month><year>2018</year></pub-date><volume>09</volume><issue>06</issue><fpage>719</fpage><lpage>729</lpage><history><date date-type="received"><day>23,</day>	<month>May</month>	<year>2018</year></date><date date-type="rev-recd"><day>26,</day>	<month>June</month>	<year>2018</year>	</date><date date-type="accepted"><day>29,</day>	<month>June</month>	<year>2018</year></date></history><permissions><copyright-statement>&#169; Copyright  2014 by authors and Scientific Research Publishing Inc. </copyright-statement><copyright-year>2014</copyright-year><license><license-p>This work is licensed under the Creative Commons Attribution International License (CC BY). http://creativecommons.org/licenses/by/4.0/</license-p></license></permissions><abstract><p>
 
 
  
    As the cash register system gradually prevailed in shopping malls, detecting the abnormal status of the cash register system has gradually become a hotspot issue. This paper analyzes the transaction data of a shopping mall. When calculating the degree of data difference, the coefficient of variation is used as the attribute weight; the weighted Euclidean distance is used to calculate the degree of difference; and 
   <em>k</em>-means clustering is used to classify different time periods. It applies the LOF algorithm to detect the outlier degree of transaction data at each time period, sets the initial threshold to detect outliers, deletes the outliers, and then performs SAX detection on the data set. If it does not pass the test, then it will gradually expand the outlying domain and repeat the above process to optimize the outlier threshold to improve the sensitivity of detection algorithm and reduce false positives. 
  
 
</p></abstract><kwd-group><kwd>Cash Register Data</kwd><kwd> Anomaly Detection</kwd><kwd> &lt;em&gt;K&lt;/em&gt;-Means Clustering</kwd><kwd> Optimized LOF Algorithm</kwd><kwd> SAX Test</kwd></kwd-group></article-meta></front><body><sec id="s1"><title>1. Introduction</title><p>Along with the development of living standards, the purchasing power of residents is also increasing. In Shopping malls, as the market with the most extensive sales of goods, a large number of commodities and customers in domestic generate huge amounts of cash register information every day. The anomaly detection of such information and maintaining the normal operation of the cash register system are critical [<xref ref-type="bibr" rid="scirp.85744-ref1">1</xref>] [<xref ref-type="bibr" rid="scirp.85744-ref2">2</xref>] .</p><p>At present, the anomaly detection of data based on the LOF algorithm has achieved lots of research results. For example, Chen Wei [<xref ref-type="bibr" rid="scirp.85744-ref3">3</xref>] improved the LOF algorithm by considering the influence of neighboring points, and constructed a fuzzy LOF algorithm. In the study of Hu Wei [<xref ref-type="bibr" rid="scirp.85744-ref4">4</xref>] , the LOF algorithm was combined with SVM to detect abnormal data. Therefore, applying LOF algorithm to detect abnormal data is a feasible method.</p><p>This paper applies the LOF algorithm to calculate the local degree of data outliers. Then a loose threshold is set to screen outliers. After deleting the outliers, the similarity between the screening data and reasonable data is measured by SAX test. If not, it will expand the abnormal limit, increase screening power, and perform loop testing and optimization. Through the gradual adjustment and optimization of the outlier threshold, false alarms can be avoided to the greatest extent.</p></sec><sec id="s2"><title>2. Preliminary Data Processing</title><sec id="s2_1"><title>2.1. Data Sources</title><p>Firstly, we choose the transaction system data in late January of a shopping mall to analyze. We have a total of 12,954 transaction records. The data samples includes: transaction date, time, volume, success rate, response time. Some transaction data are as follows <xref ref-type="table" rid="table1">Table 1</xref>.</p></sec><sec id="s2_2"><title>2.2. Principles of Optimized K-Means Clustering</title><p>The k-means clustering algorithm first selects k objects as the initial clustering center randomly. Then the distance between each object and each seed cluster center is calculated and each object is assigned to the nearest cluster center. The cluster centers and the objects assigned to them represent a cluster. After all objects have been assigned, the cluster centers of each cluster are recalculated based on the existing objects in the cluster. This process will be repeated until some termination condition is met. The termination condition may be that no object is reassigned to different clusters, and at that point the squared error sum is locally minimum.</p><p>The basic operation is as follows:</p><p>1) Take k elements randomly from element set d as the respective centers of k clusters.</p><p>2) Calculate the degree of dissimilarity between the remaining elements to the centers of k clusters, and assign these elements to clusters with the lowest</p><table-wrap id="table1" ><label><xref ref-type="table" rid="table1">Table 1</xref></label><caption><title> Part of the transaction data</title></caption><table><tbody><thead><tr><th align="center" valign="middle" >Date</th><th align="center" valign="middle" >Time</th><th align="center" valign="middle" >Volume</th><th align="center" valign="middle" >Success Rate</th><th align="center" valign="middle" >Response Time</th></tr></thead><tr><td align="center" valign="middle" >1.23</td><td align="center" valign="middle" >0:00</td><td align="center" valign="middle" >178</td><td align="center" valign="middle" >94.94%</td><td align="center" valign="middle" >105</td></tr><tr><td align="center" valign="middle" >1.23</td><td align="center" valign="middle" >0:01</td><td align="center" valign="middle" >158</td><td align="center" valign="middle" >98.73%</td><td align="center" valign="middle" >87</td></tr><tr><td align="center" valign="middle" >1.23</td><td align="center" valign="middle" >0:02</td><td align="center" valign="middle" >129</td><td align="center" valign="middle" >98.45%</td><td align="center" valign="middle" >97</td></tr><tr><td align="center" valign="middle" >1.23</td><td align="center" valign="middle" >0:03</td><td align="center" valign="middle" >111</td><td align="center" valign="middle" >99.1%</td><td align="center" valign="middle" >93</td></tr><tr><td align="center" valign="middle" >1.23</td><td align="center" valign="middle" >0:04</td><td align="center" valign="middle" >124</td><td align="center" valign="middle" >95.16%</td><td align="center" valign="middle" >95</td></tr><tr><td align="center" valign="middle" >1.23</td><td align="center" valign="middle" >0:05</td><td align="center" valign="middle" >105</td><td align="center" valign="middle" >95.24%</td><td align="center" valign="middle" >96</td></tr></tbody></table></table-wrap><p>dissimilarity, respectively. The dissimilarity algorithm is as follows:</p><p>d i s k = ω i ∑ i = 1 n ( x i − x k i )</p><p>Among them, x i is an attribute value of an i-th element. x k i is the i-th attribute value of the k-th cluster center. ω i is attribute value weight. In order to avoid the influence of the dimension, the variation coefficient of each attribute variable is used as the weight, and the formula is:</p><p>ω i = S i / x &#175; i</p><p>Among them, S i is variance of attribute variables. x &#175; i is average value for attribute variables.</p><p>3) According to the clustering result, take the arithmetic average of the respective dimensions of all the elements in the cluster and recalculate the centers of the k clusters. The formula is:</p><p>x k i = ∑ x i / n k</p><p>Among them, x i is the i-th attribute of all elements in the k-th cluster. n k is the number of all elements in the k-th cluster.</p><p>4) Regroup all elements in d according to the new center.</p><p>5) Repeat step 4 until the clustering result no longer changes.</p><p>6) Output the result.</p></sec><sec id="s2_3"><title>2.3. Choosing Optimal Cluster K Value Based on CH Index</title><p>The CH indicator describes the compactness by intra-class dispersion matrices. And the disparity matrix between classes describes the degree of separation. The indicators are defined as:</p><p>C H ( k ) = t r B ( k ) / ( k − 1 ) t r W ( k ) / ( n − k )</p><p>Among them, “n” denotes the number of clusters. “K” denotes the current class. “ t r B ( k ) ” denotes the trace of the disparity matrix between classes and “ t r W ( k ) ” denotes the trace of the intra-class dispersion matrix.</p><p>From the definition of the CH indicator, it can be known that the greater the CH indicator is, the closer the class itself is and the more dispersed is the class and another class, that is, the clustering result is better. In order to measure the effectiveness of the clustering results, the CH indicator was selected to measure the effectiveness of the cluster. K values ranged from 2 to 8, and cluster centers were randomly selected for clustering. Each k value was clustered 10 times and its average CH value results are as follows <xref ref-type="fig" rid="fig1">Figure 1</xref>.</p><p>According to the result graph, when the k value is 4, the clustering result is optimal.</p></sec><sec id="s2_4"><title>2.4. Trading Period Clustering Results</title><p>Select k = 4 as the number of clusters, apply transaction time, volume, success rate, response time as the transaction category attribute, and cluster the transaction date to obtain the clustering result (<xref ref-type="fig" rid="fig2">Figure 2</xref>).</p><p>According to the results of the specific classification, the date of transaction data is basically divided into four periods: before the Spring Festival, after the Spring Festival, on the working day, and on the non-workdays.</p><p>K-means clustering is performed on the daily time period according to the above date classification. All dates in the four date categories are selected. The average value of each category attribute is obtained, and the timeline data of the transaction data is plotted (<xref ref-type="fig" rid="fig3">Figure 3</xref>).</p><p>From the trend of line chart, we know that the daily transaction volume trends are basically the same in all time periods. The transaction volume gradually increases from 0 o’clock. At midday, there is a small downtrend in transaction volume and then it rises and eventually begins to decrease. The trough periods and peak periods are more obvious. Therefore, the k-means clustering</p><p>analysis is also performed on it, and the k value is set to 2 to obtain the time clustering result as shown in the following <xref ref-type="table" rid="table2">Table 2</xref>.</p><p>The trough periods and peak periods are basically the same in all periods. The clustering results are good.</p></sec></sec><sec id="s3"><title>3. The Mathematical Model</title><sec id="s3_1"><title>3.1. Calculating Local Outliers of Trading Data Based on LOF Algorithm</title><sec id="s3_1_1"><title>3.1.1. Principles of LOF Algorithm</title><p>Basic variable definition:</p><p>1) The distance between two points, p and o, is the difference between two points of data, where the trading volume distance is:</p><p>d 1 ( p , o ) = x 1 ( p ) − x 1 (0)</p><p>The distance of transaction success rate is:</p><p>d 2 ( p , o ) = x 2 ( p ) − x 2 (0)</p><p>The distance of response time distance is:</p><p>d 3 ( p , o ) = x 3 ( p ) − x 3 (0)</p><table-wrap id="table2" ><label><xref ref-type="table" rid="table2">Table 2</xref></label><caption><title> Clustering results at various periods</title></caption><table><tbody><thead><tr><th align="center" valign="middle" ></th><th align="center" valign="middle" >First trough period</th><th align="center" valign="middle" >Peak period</th><th align="center" valign="middle" >Second trough period</th></tr></thead><tr><td align="center" valign="middle" >Before the Spring Festival</td><td align="center" valign="middle" >0:00 - 8:19</td><td align="center" valign="middle" >8:19 - 20:23</td><td align="center" valign="middle" >20:23 - 23:59</td></tr><tr><td align="center" valign="middle" >After the Spring Festival</td><td align="center" valign="middle" >0:00 - 8:35</td><td align="center" valign="middle" >8:35 - 19:51</td><td align="center" valign="middle" >19:51 - 23:59</td></tr><tr><td align="center" valign="middle" >Workdays</td><td align="center" valign="middle" >0:00 - 7:54</td><td align="center" valign="middle" >7:54 - 20:36</td><td align="center" valign="middle" >20:36 - 23:59</td></tr><tr><td align="center" valign="middle" >Non-workdays</td><td align="center" valign="middle" >0:00 - 7:58</td><td align="center" valign="middle" >7:58 - 20:30</td><td align="center" valign="middle" >20:30 - 23:59</td></tr></tbody></table></table-wrap><p>2) The k-th distance: The distance from the point k away from the point p to p, excluding p.</p><p>3) The k-th distance neighborhood: The k-th distance neighborhood of point p, that is, all points within the k-th distance of, including the k-th distance. Therefore, the number of k-th neighbors of p.</p><p>4) Reachable distance:</p><p>r e a c h - d i s t a n c e ( p , o ) = max { d k ( o ) , d ( p o ) }</p><p>5) Local accessible density: the higher the density is, the more likely it is to belong to the same cluster. The lower the density, the more likely it is to be an outlier. The local reachable density of point p is expressed as:</p><p>l r d k ( p ) = 1 ∑ o ∈ N k ( p ) r e a c h - d i s t ( p , o ) / | N k ( p ) |</p><p>6) Local outlier factor: indicates the degree of abnormality of the data objects, and its size reflects the degree of isolation of the data object relative to the points in its data area, which referred to as:</p><p>L O F k ( P ) = ∑ o ∈ N k ( p ) l r d k ( o ) l r d k ( p ) | N k ( p ) |</p><p>The basic operation is as follows [<xref ref-type="bibr" rid="scirp.85744-ref5">5</xref>] [<xref ref-type="bibr" rid="scirp.85744-ref6">6</xref>] [<xref ref-type="bibr" rid="scirp.85744-ref7">7</xref>] :</p><p>1) Query the neighborhood of each data object p in the overall data set d, and obtain the neighborhood N k ( p ) recalculation distance.</p><p>2) Sort the distance, and calculate the k-th distance and the k-th field.</p><p>3) Calculate the reachability density of each transaction data.</p><p>4) Calculate the local outlier factor for each transaction data.</p><p>5) Sort and output local outlier factors for each transaction data.</p></sec><sec id="s3_1_2"><title>3.1.2. The Results of Local Outlier Degree Calculation</title><p>Based on the periods divided in question 1, the average transaction time, success rate, and response time for each of the eight periods were used to calculate the degree of outliers at each time point. Taking the maximum value of outliers as the abnormal condition under the mean value, the abnormal regions in each period are set as follows <xref ref-type="table" rid="table3">Table 3</xref>.</p><p>According to this, the degree of local outliers of the transaction data factors at any time of the day can be determined, and the abnormality can be determined based on the abnormality threshold. The following are the outlier excursions and abnormal point discrimination charts at each time on the 1.23 day (<xref ref-type="fig" rid="fig4">Figure 4</xref>, <xref ref-type="fig" rid="fig5">Figure 5</xref>).</p></sec></sec><sec id="s3_2"><title>3.2. Optimizing Anomaly Threshold Based on SAX Algorithm</title><sec id="s3_2_1"><title>3.2.1. Principles of SAX Algorithm</title><p>Symbolic Aggregate Appro-Ximation (SAX) is a data compression and information extraction method that can discretize data sequences and convert them into</p><table-wrap id="table3" ><label><xref ref-type="table" rid="table3">Table 3</xref></label><caption><title> Abnormality threshold of all factors</title></caption><table><tbody><thead><tr><th align="center" valign="middle" ></th><th align="center" valign="middle" >Abnormal volume of transaction volume</th><th align="center" valign="middle" >Abnormal volume of transaction success rate</th><th align="center" valign="middle" >Abnormal volume of transaction response rate</th></tr></thead><tr><td align="center" valign="middle" >Peak period on the workdays</td><td align="center" valign="middle" >(1.6179, ∞)</td><td align="center" valign="middle" >(1.2724, ∞)</td><td align="center" valign="middle" >(2.5193, ∞)</td></tr><tr><td align="center" valign="middle" >Trough period on the workdays</td><td align="center" valign="middle" >(1.3588, ∞)</td><td align="center" valign="middle" >(2.3952, ∞)</td><td align="center" valign="middle" >(7.6093, ∞)</td></tr><tr><td align="center" valign="middle" >Peak period on the non-workdays</td><td align="center" valign="middle" >(1.8366, ∞)</td><td align="center" valign="middle" >(1.3604, ∞)</td><td align="center" valign="middle" >(4.3227, ∞)</td></tr><tr><td align="center" valign="middle" >Trough period on the non-workdays</td><td align="center" valign="middle" >(1.3994, ∞)</td><td align="center" valign="middle" >(7.2853, ∞)</td><td align="center" valign="middle" >(8.6643, ∞)</td></tr><tr><td align="center" valign="middle" >Peak period before the Spring Festival</td><td align="center" valign="middle" >(2.0111, ∞)</td><td align="center" valign="middle" >(1.3745, ∞)</td><td align="center" valign="middle" >(3.2204, ∞)</td></tr><tr><td align="center" valign="middle" >Trough period before the Spring Festival</td><td align="center" valign="middle" >(1.7611, ∞)</td><td align="center" valign="middle" >(2.9421, ∞)</td><td align="center" valign="middle" >(5.5650, ∞)</td></tr><tr><td align="center" valign="middle" >Peak period after the Spring Festival</td><td align="center" valign="middle" >(2.0286, ∞)</td><td align="center" valign="middle" >(1.6719, ∞)</td><td align="center" valign="middle" >(6.8982, ∞)</td></tr><tr><td align="center" valign="middle" >Trough period after the Spring Festival</td><td align="center" valign="middle" >(2.0914, ∞)</td><td align="center" valign="middle" >(2.7498, ∞)</td><td align="center" valign="middle" >(8.8315, ∞)</td></tr></tbody></table></table-wrap><p>symbol sequences according to the characteristics of data density [<xref ref-type="bibr" rid="scirp.85744-ref8">8</xref>] . The algorithm steps are as follows:</p><p>1) Z-score standardization of all data is converted into data that conforms to the standard normal distribution. The conversion function is:</p><p>x * = x − μ σ</p><p>2) A segmented aggregate approximate conversion PAA is performed on the original time series. The total length is n, and the normalized time series are divided into w groups one by one in chronological order. Then find the arithmetic mean value m of each set of sequences, and use m to replace the value of the entire sequence set, reduce the dimension of the original data by about n/w, and change the fluctuating time series into a staircase sequence.</p><p>3) Divide the probability density curve of N(0, 1) into a interval functions according to probability, replace the PAA segment with discrete letters, and complete the symbolization of the sequence.</p><p>4) Similarity measure and comparison of symbol sequences. Assuming that P, Q are two symbol sequences, and denotes the value of the ith element of the corresponding symbol sequence, then the distance between symbol sequences is defined as:</p><p>D ( P , Q ) = n w ∑ i = 1 w ( d i s t ( p i , q i ) ) 2</p><p>where</p><p>d i s t ( p i , q i ) = { 0 ,     | p i − q i | ≤ 1 b max ( p i , q i ) − 1 − b min ( p i , q i ) − 1       | p i − q i | ≥ 1</p><p>b is the area split point under the normal distribution curve.</p></sec><sec id="s3_2_2"><title>3.2.2. The Results of Symbolic Aggregate Approximation</title><p>After eliminating the outliers in the original sequence, symbolic aggregation approximation processing is performed on the transaction data. Taking the 23rd in April transaction volume as an example, the PAA conversion graph is as follows <xref ref-type="fig" rid="fig6">Figure 6</xref>.</p><p>After replacing the interval segment with discrete letters, the symbolized data is as follows <xref ref-type="fig" rid="fig7">Figure 7</xref>.</p></sec><sec id="s3_2_3"><title>3.2.3. Approximate Abnormal Threshold Based on Symbolic Aggregation</title><p>Calculate the approximate result of the symbol aggregation for the average data of each time period, and calculate the distance between the symbolization result and the mean value at each period of the transaction data, and perform the following test:</p><p>1) If d i s t ( p i , q i ) = 0 , keep the original abnormal threshold;</p><p>2) If d i s t ( p i , q i ) &gt; 0 , increase the abnormality threshold.</p><p>After expanding the abnormal threshold, new abnormal points are deleted,</p><p>and the data is checked and corrected again until all the time periods have passed the test. The correction of the threshold value can increase the sensitivity of the anomaly detection model and minimize the false alarms and omissions of abnormal data. Based on the initial abnormality threshold SAX test results are as follows <xref ref-type="table" rid="table4">Table 4</xref>.</p><p>From <xref ref-type="table" rid="table4">Table 4</xref>, it can be seen that the initial abnormality threshold of transaction volume is good, and the transaction success rate and response time abnormality thresholds need to be optimized. After optimization by the cyclic SAX test, the optimized abnormality threshold is as follows <xref ref-type="table" rid="table5">Table 5</xref>.</p><table-wrap id="table4" ><label><xref ref-type="table" rid="table4">Table 4</xref></label><caption><title> The results of initial anomaly threshold SAX test</title></caption><table><tbody><thead><tr><th align="center" valign="middle" ></th><th align="center" valign="middle" >The test results of transaction volume</th><th align="center" valign="middle" >The test results of transaction success rate</th><th align="center" valign="middle" >The test results of transaction response time</th></tr></thead><tr><td align="center" valign="middle" >Peak period on the workdays</td><td align="center" valign="middle" >0</td><td align="center" valign="middle" >105.2836</td><td align="center" valign="middle" >148.3655</td></tr><tr><td align="center" valign="middle" >Trough period on the workdays</td><td align="center" valign="middle" >0</td><td align="center" valign="middle" >78.3514</td><td align="center" valign="middle" >284.9316</td></tr><tr><td align="center" valign="middle" >Peak period on the non-workdays</td><td align="center" valign="middle" >0</td><td align="center" valign="middle" >109.3652</td><td align="center" valign="middle" >372.7653</td></tr><tr><td align="center" valign="middle" >Trough period on the non-workdays</td><td align="center" valign="middle" >0</td><td align="center" valign="middle" >239.5185</td><td align="center" valign="middle" >109.8498</td></tr><tr><td align="center" valign="middle" >Peak period before the Spring Festival</td><td align="center" valign="middle" >0</td><td align="center" valign="middle" >0</td><td align="center" valign="middle" >38.5632</td></tr><tr><td align="center" valign="middle" >Trough period before the Spring Festival</td><td align="center" valign="middle" >0</td><td align="center" valign="middle" >35.9762</td><td align="center" valign="middle" >0</td></tr><tr><td align="center" valign="middle" >Peak period after the Spring Festival</td><td align="center" valign="middle" >0</td><td align="center" valign="middle" >0</td><td align="center" valign="middle" >67.3628</td></tr><tr><td align="center" valign="middle" >Trough period after the Spring Festival</td><td align="center" valign="middle" >0</td><td align="center" valign="middle" >0</td><td align="center" valign="middle" >79.2295</td></tr></tbody></table></table-wrap><table-wrap id="table5" ><label><xref ref-type="table" rid="table5">Table 5</xref></label><caption><title> The results of optimized anomaly threshold SAX test</title></caption><table><tbody><thead><tr><th align="center" valign="middle" ></th><th align="center" valign="middle" >Abnormal volume of transaction volume</th><th align="center" valign="middle" >Abnormal volume of transaction success rate</th><th align="center" valign="middle" >Abnormal volume of transaction response rate</th></tr></thead><tr><td align="center" valign="middle" >Peak period on the workdays</td><td align="center" valign="middle" >(1.6179, ∞)</td><td align="center" valign="middle" >(1.4524, ∞)</td><td align="center" valign="middle" >(2.9893, ∞)</td></tr><tr><td align="center" valign="middle" >Trough period on the workdays</td><td align="center" valign="middle" >(1.3588, ∞)</td><td align="center" valign="middle" >(2.6052, ∞)</td><td align="center" valign="middle" >(7.7593, ∞)</td></tr><tr><td align="center" valign="middle" >Peak period on the non-workdays</td><td align="center" valign="middle" >(1.8366, ∞)</td><td align="center" valign="middle" >(1.8204, ∞)</td><td align="center" valign="middle" >(4.4827, ∞)</td></tr><tr><td align="center" valign="middle" >Trough period on the non-workdays</td><td align="center" valign="middle" >(1.3994, ∞)</td><td align="center" valign="middle" >(7.9753, ∞)</td><td align="center" valign="middle" >(8.7343, ∞)</td></tr><tr><td align="center" valign="middle" >Peak period before the Spring Festival</td><td align="center" valign="middle" >(2.0111, ∞)</td><td align="center" valign="middle" >(1.3745, ∞)</td><td align="center" valign="middle" >(3.2704, ∞)</td></tr><tr><td align="center" valign="middle" >Trough period before the Spring Festival</td><td align="center" valign="middle" >(1.7611, ∞)</td><td align="center" valign="middle" >(2.9621, ∞)</td><td align="center" valign="middle" >(5.5650, ∞)</td></tr><tr><td align="center" valign="middle" >Peak period after the Spring Festival</td><td align="center" valign="middle" >(2.0286, ∞)</td><td align="center" valign="middle" >(1.6719, ∞)</td><td align="center" valign="middle" >(6.9082, ∞)</td></tr><tr><td align="center" valign="middle" >Trough period after the Spring Festival</td><td align="center" valign="middle" >(2.0914, ∞)</td><td align="center" valign="middle" >(2.7498, ∞)</td><td align="center" valign="middle" >(8.9415, ∞)</td></tr></tbody></table></table-wrap></sec><sec id="s3_2_4"><title>3.2.4. The Accuracy of Anomaly Detection</title><p>According to the initial abnormality threshold and the optimized abnormality threshold, the trading data is anomalously detected. The detection accuracy rate is as follows <xref ref-type="table" rid="table6">Table 6</xref>.</p><table-wrap id="table6" ><label><xref ref-type="table" rid="table6">Table 6</xref></label><caption><title> The accuracy of transaction volume</title></caption><table><tbody><thead><tr><th align="center" valign="middle" ></th><th align="center" valign="middle" >The accuracy of transaction volume</th><th align="center" valign="middle" >The accuracy of transaction success rate</th><th align="center" valign="middle" >The accuracy of response time</th></tr></thead><tr><td align="center" valign="middle" >Initial abnormality threshold</td><td align="center" valign="middle" >97.2%</td><td align="center" valign="middle" >93.1%</td><td align="center" valign="middle" >96.4%</td></tr><tr><td align="center" valign="middle" >Optimized abnormality threshold</td><td align="center" valign="middle" >97.2%</td><td align="center" valign="middle" >98.5%</td><td align="center" valign="middle" >99.1%</td></tr></tbody></table></table-wrap><p>From <xref ref-type="table" rid="table6">Table 6</xref>, we can see that, except for the transaction volume threshold, the transaction success rate and response time anomaly detection accuracy rate are significantly improved, indicating that the optimization anomaly threshold has better properties than the initial anomaly threshold.</p></sec></sec></sec><sec id="s4"><title>4. Conclusions and Suggestions</title><p>From the above results, it can be known that the LOF algorithm can measure the degree of local outliers of data points well and thus can be used in anomaly detection. However, the abnormal threshold setting is often subjective. Based on the SAX algorithm, the deletion of outlier data can be tested, which can effectively find the deficiency of artificially set abnormal threshold, so as to adjust and improve. Applying SAX to test the adjusted abnormality threshold can greatly improve the accuracy of anomaly detection.</p></sec><sec id="s5"><title>Cite this paper</title><p>Long, K., Wu, Y.H. and Gui, Y.F. (2018) Anomaly Detection of Store Cash Register Data Based on Improved LOF Algorithm. Applied Mathematics, 9, 719-729. https://doi.org/10.4236/am.2018.96049</p></sec></body><back><ref-list><title>References</title><ref id="scirp.85744-ref1"><label>1</label><mixed-citation publication-type="other" xlink:type="simple">Yin, X.X., et al. (2012) Supermarket Cash Register Management System Analysis and Design. Market Modernization, 2, 6-7.</mixed-citation></ref><ref id="scirp.85744-ref2"><label>2</label><mixed-citation publication-type="other" xlink:type="simple">Prater, E., Frazier, G.V. and Reyes, P.M. (2005) Future Impacts of RFID on E-Supply Chains in Grocery Retailing. Supply Chain Management: An International Journal, 10,134-142.</mixed-citation></ref><ref id="scirp.85744-ref3"><label>3</label><mixed-citation publication-type="journal" xlink:type="simple"><name name-style="western"><surname>Chen</surname><given-names> M. </given-names></name>,<etal>et al</etal>. (<year>2016</year>)<article-title>Research on Credit Card Fraud Detection Based on Fuzzy Local Outlier Factor (LOF)</article-title><source> Financial Theory and Practice</source><volume> 10</volume>,<fpage> 54</fpage>-<lpage>57</lpage>.<pub-id pub-id-type="doi"></pub-id></mixed-citation></ref><ref id="scirp.85744-ref4"><label>4</label><mixed-citation publication-type="other" xlink:type="simple">Hu, W., et al. (2016) Intelligent Distribution Network Fault Identification Method Based on LOF and SVM. Power Automation Equipment, 36, 7-12.</mixed-citation></ref><ref id="scirp.85744-ref5"><label>5</label><mixed-citation publication-type="other" xlink:type="simple">Li, L., Huang, L.S., Yang, W., Yao, X.H. and Liu, A. (2015) Privacy-Preserving LOF Outlier Detection. Knowledge and Information Systems, 42, 579-597.  
https://doi.org/10.1007/s10115-013-0692-0</mixed-citation></ref><ref id="scirp.85744-ref6"><label>6</label><mixed-citation publication-type="other" xlink:type="simple">Kang, B., Kim, D. and Kang, S.-H. (2011) Real-Time Business Process Monitoring Method for Prediction of Abnormal Termination Using KNNI-Based LOF Prediction. Expert Systems with Application: An International Journal, 12, 6061-6068.</mixed-citation></ref><ref id="scirp.85744-ref7"><label>7</label><mixed-citation publication-type="other" xlink:type="simple">Zhou, P., et al. (2017) An Improved LOF Outlier Detection Algorithm. Computer Technology and Development, 27, 115-118.</mixed-citation></ref><ref id="scirp.85744-ref8"><label>8</label><mixed-citation publication-type="other" xlink:type="simple">Lin, J., Keogh, E., Lonardi, S. and Chiu, B. (2003) A Symbolic Representation of Time Series with Implications for Streaming Algorithms. Proceedings of the 8th ACM SIGMOD Workshop on Research Issues in Data Mining and Knowledge Discovery, San Diego, 13 June 2003, 2-11. https://doi.org/10.1145/882082.882086</mixed-citation></ref></ref-list></back></article>