# Patent

## Title
Approximate K-means via cluster closures

## Abstract

A set of data points is divided into a plurality of subsets of data points. A set of cluster closures is generated based at least in part on the subset of data points. Each cluster closure envelopes a corresponding cluster of a set of clusters and is comprised of data points of the enveloped cluster and data points neighboring the enveloped cluster. A k-Means approximator iteratively assigns data points to a cluster of the set of clusters and updates a set of cluster centroids corresponding to the set of clusters. The k-Means approximator assigns data points based at least in part on the set of cluster closures.

## Background
BACKGROUND
The increasing popularity of image applications enable users to leverage use of cameras in mobile devices when performing some tasks. An image application may enable users to capture images on cameras of their mobile devices, which the image application can then submit as queries to perform a search. Typically, the image application evaluates candidate images that are similar to the query submitted to retrieve images that are relevant to the query.
An image may be represented by a vector such as that employed in a bag-of-features model (BoF model) in which image features may be treated analogously as words in a document. In document classification, a bag of words is a sparse vector of occurrence counts of words; that is, a sparse histogram over the vocabulary. In computer vision, a bag of visual words is a sparse vector of occurrence counts of a vocabulary of local image features.
To achieve this, the features of an image are detected. After feature detection, an image is abstracted by several local patches. Feature representation methods deal with how to represent the patches as numerical vectors. These vectors are called feature descriptors. One of the most famous descriptors is Scale-invariant feature transform (SIFT). SIFT converts each patch to 128-dimensional vector. After this step, the image is a collection of vectors of the same dimension (128 for SIFT), where the order of different vectors is of no importance. The final step for the BoF model is to convert vector represented patches to “codewords” (analogy to words in text documents), which also produces a “codebook” (analogous to a word dictionary). A codeword can be considered as a representative of several similar patches. Codewords are then defined as the centers of the learned clusters. The number of the clusters is the codebook size (analogous to the size of the word dictionary).
K-means has been widely used in computer vision and machine learning for clustering and vector quantization. In image retrieval and recognition, it is often used to learn the codebook for the popular bag-of-features model.
The standard k-Means algorithm, Lloyd's algorithm, is an iterative refinement approach that greedily minimizes the sum of squared distances between each point and its assigned cluster center. It consists of two iterative steps, the assignment and update step. The assignment step aims to find the nearest cluster for each point by checking the distance between the point and each cluster center; the update step updates the cluster centers based on current assignment. When clustering n points into k clusters, the assignment step costs O(nk). For applications with large nk, the assignment step in exact k-Means becomes prohibitively expensive.
In large-scale image retrieval, it is advantageous to learn a large codebook containing one million or more entries, which requires clustering tens or even hundreds of millions of high-dimensional feature descriptors into one million or more clusters. Another emerging application of large-scale clustering is to organize a large corpus of web images for various purposes such as web image browsing/exploring. Thus, efficient clustering of large data sets is desired.
SUMMARY
This disclosure describes techniques for efficient clustering of data sets. An approximate k-Means algorithm is implemented, which like the conventional k-Means algorithm, is an iterative algorithm. The approximate k-Means algorithm includes: initializing a data set by, among other things, randomly assigning data points to a set of k cluster centroids, C={c1, c2, c3, . . . ck}, or randomly generating a set of k cluster centroids and by creating a cluster closure around each of cluster centroid of a set of cluster centroids; and iteratively (i) assigning each data point of the data set to a cluster centroid of a cluster closure containing the data point and (ii) updating the data points in each cluster and calculating a new cluster centroid for each cluster closure.
This Summary is provided to introduce a selection of concepts in a simplified form that are further described below in the Detailed Description. This Summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter.



BRIEF DESCRIPTION OF THE DRAWINGS
The Detailed Description is set forth with reference to the accompanying figures. In the figures, the left-most digit(s) of a reference number identifies the figure in which the reference number first appears. The use of the same reference numbers in different figures indicates similar or identical items.
FIG. 1 illustrates an architecture to support an example environment to perform an image search by using an approximate k-Means algorithm to cluster datasets.
FIG. 2 is a flowchart to illustrate an example process showing functions to be used in the architecture of FIG. 1.
FIG. 3 is a flowchart to illustrate another example process showing functions to be used in the architecture of FIG. 1.
FIG. 4 is a schematic diagram that illustrates constructing an approximate neighborhood.
FIGS. 5A and 5B are schematic diagrams that illustrate an example process for constructing a cluster closure.
FIG. 6 is a block diagram to illustrate an example server usable with the environment of FIG. 1.



DETAILED DESCRIPTION
Overview
This disclosure describes techniques for performing efficient data clustering via a k-Means approximation for, among other things, generating a codebook that represents the data set. While this disclosure discusses applying k-Means approximation to data sets representing images, such discussion is provided as one, non-limiting, example of a data set for which clustering may be applicable. Other data sets, including data sets representing documents, may also be clustered by techniques and processes discussed herein and are covered by this disclosure.
A codebook may be used for searches on image collections, data collections that are large scale and located on the World Wide Web, databases, and/or directories. In an implementation, a user may provide an image as a query, and then a process uses the codebook to search for images that are similar in appearance to the image query. Details of a process for clustering data points via a k-Means approximation and for creating the codebook is described below. The codebook may be implemented in providing search results.
For example, envision that the user takes a photograph of house style “A,” such as a Cape Cod style house. The house is located in a community, in which the user desires to locate more houses that are similar in appearance to house style “A.” The user submits the photograph as an image query to a search engine. The search engine extracts features from the image and utilizes the codebook to locate images that are similar in appearance to house style “A.” The user may request the search for many reasons such as to determine possible paint colors on the house style; to determine different types of roof styles; to determine various styles of shutters, doors and window frames, and the like. The process performs the searches by looking for similar images on the World Wide Web, databases, directories, servers, blogs, websites, and the like. The search results may be ranked based on similarity to the image query. In yet other examples, the searches may be used in a variety of other applications, such as object classification, feature matching, content-based retrieval, and the like.
An approximate k-Means algorithm gathers a set of n data points {x1, x2, x3, . . . xn}, where each data point (x) is a d-dimensional vector, into k groups (or clusters), G={G1, G2, G3, . . . Gk}, where k is less than or equal to n, by minimizing the within-cluster sum of squared distortions:

J(C,G)=Σj=1kΣxiεGj∥xi−cj∥22,  (1)

where cj is the centroid of cluster Gj,





  
    
      
        
          
            
              c
              j
            
            =
            
              
                1
                
                  
                  
                    G
                    j
                  
                  
                
              
              ⁢
              
                
                  ∑
                  
                    
                      x
                      i
                    
                    ∈
                    
                      G
                      j
                    
                  
                
                ⁢
                
                  x
                  i
                
              
            
          
          ,
          
            

          
          ⁢
          and
        
        ⁢
        
          

        
        ⁢
        
          C
          =
          
            
              {
              
                
                  c
                  1
                
                ,
                
                  c
                  2
                
                ,
                
                  c
                  3
                
                ,
                
                  ...
                  ⁢
                  
                    
                  
                  ⁢
                  
                    c
                    k
                  
                
              
              }
            
            .
          
        
      
    
    
      
        (
        2
        )
      
    
  




To create a cluster closure, a process identifies “active points,” which are defined as data points that are within a threshold distance of a boundary between two clusters. A cluster closure (G) is defined as:

G=UxεGNx,  (3)

where x is a given data point that is an element of cluster G and Nx denotes data points that are in the neighborhood of the given data point x. Implementations of cluster closure are described by Jing Wang, Jingdong Wang, Qifa Ke, Gang Zeng, and Shipeng Li, CVPR '12 Proceedings of the 2012 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 3037-3044, which is incorporated herein in its entirety by reference.

In some implementations, the neighborhood Nx of a given data point may be determined via an ensemble approach using one or more random spatial partitions.
While aspects of described techniques can be implemented in any number of different computing systems, environments, and/or configurations, implementations are described in the context of the following example computing environment.
Illustrative Environment
FIG. 1 illustrates an example architectural environment 100, in which efficient searches, performed on a computing device, may occur by employing the approximate k-Means algorithm to cluster datasets representing images to generate a codebook. The environment 100 includes an example computing device 102, which is illustrated as a laptop computer. The computing device 102 is configured to connect via one or more network(s) 104 to access a search service 106 for a user 108. It is noted that the computing device 102 may take a variety of forms, including, but not limited to, a portable handheld computing device (e.g., a personal digital assistant, a smart phone, a cellular phone), a tablet, a personal navigation device, a desktop computer, a portable media player, or any other device capable of connecting to one or more network(s) 104 to access the search service 106 for the user 108.
The computing device 102 may have additional features and/or functionality. For example, the computing device 102 may also include additional data storage devices (removable and/or non-removable) such as, for example, magnetic disks, optical disks, or tape. Such additional storage may include removable storage and/or non-removable storage. Computer-readable media may include, at least, two types of computer-readable media, namely computer storage media and communication media. Computer storage media may include volatile and non-volatile, removable, and non-removable media implemented in any method or technology for storage of information, such as computer readable instructions, data structures, program modules, or other data. A system memory, the removable storage and the non-removable storage are all examples of computer storage media. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD), or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store the desired information and which can be accessed by the computing device 102. Any such computer storage media may be part of the computing device 102. Moreover, the computer-readable media may include computer-executable instructions that, when executed by the processor(s), perform various functions and/or operations described herein.
In contrast, communication media may embody computer-readable instructions, data structures, program modules, or other data in a modulated data signal, such as a carrier wave, or other transmission mechanism. As defined herein, computer storage media does not include communication media.
The network(s) 104 represents any type of communications network(s), including wire-based networks (e.g., cable), wireless networks (e.g., cellular, satellite), cellular telecommunications network(s), Wi-Fi networks, and IP-based telecommunications network(s). The search service 106 represents a service that may be operated as part of any number of online service providers, such as a search engine, or for applications such as image retrieval, and the like.
The search service 106 may operate in conjunction with a graph application 110 that executes on one or more of the image servers 112(1)-(S). The graph application 110 performs the processes described, such as searching for images similar to an image query 114 by using a codebook 116 that may be generated based at least in part by partitioning a set of data points with a partition module 120, and employing a k-Means approximator module 120, which utilizes a cluster closure module 122, to cluster the data points. For instance, the graph application 110 receives the image query 114 of a Cape Cod style house. The architecture of the Cape Cod style house illustrates the distinct features of the house, such as the steep, pitched roof with end gables, a large chimney in the center, and little ornamentation on the outside, and these features may be used to represent the image of the Cape Cod style house. The graph application 110 performs searches for images having similar features to the steep, pitched roof and the large chimney in the center of the image query 114 by using the codebook 116, which may be book of a bag-of-features image representation. The codebook 116 may be machine-learned by the graph application 110.
In the illustrated example, the search service 106 is hosted on one or more servers, such as the image server(s) 112(1), 112(2), . . . , 112(S), accessible via the network(s) 104. The image servers 112(1)-(S) may be configured as plural independent servers, or as a collection of servers that are configured to perform larger scale functions accessible by the network(s) 104. The image server(s) 112 may be administered or hosted by a network service provider that provides the search service 106 to and from the computing device 102. The search service 106 may be implemented by the image servers 112 and the graph application 110 to and from the mobile device 102.
A database 124 may be a separate server or may be hosted on a representative set of image servers 112 that are accessible via the network(s) 104. The database 124 may store information, such as image collections, image results, hash tables, algorithms to perform the processes described, and the like.
FIGS. 2 and 3 illustrate flowcharts showing example processes. The processes are illustrated as a collection of blocks in logical flowcharts, which represent a sequence of operations that can be implemented in hardware, software, or a combination. For discussion purposes, the processes are described with reference to the computing environment 100 shown in FIG. 1. However, the processes may be performed using different environments and devices. Moreover, the environments and devices described herein may be used to perform different processes.
For ease of understanding, the processes are delineated as separate steps represented as independent blocks in the figures. However, these separately delineated steps should not be construed as necessarily order dependent in their performance. The order in which the processes are described is not intended to be construed as a limitation, and any number of the described process blocks maybe be combined in any order to implement the processes, or alternate processes. Moreover, it is also possible for one or more of the provided steps to be omitted.
FIG. 2 is a flowchart of an example process 200 showing high-level functions performed by the graph application 110 in accordance with one non-limiting embodiment. The process 200 may be divided into multiple phases, and all of the phases may be used in the environment of FIG. 1, may be performed separately or in combination, and without any particular order.
At 202, a data set is acquired and initialized by the graph application 110. The data set may be comprised of n data points, e.g., {x1, x2, x3, . . . xn}, where each data point (x) is a d-dimensional vector. In some instances, a data point may represent an image. The data set may be initialized by the partition module 118 partitioning the data set into multiple groups. In some implementations, every data point (xi) may be randomly assigned to a cluster (cj). In other implementations, cluster centroids may be randomly generated and distributed through the space spanning the data set. In some instances, a distance array (D) may be initialized. The elements of the distance array may correspond to data points of the data set, and the elements of the distance array may be set to a predetermined value. In some implementations, the predetermined value may be larger than a largest distance of the space spanning the data set.
At 204, cluster closure members, or active points, are identified for each cluster (Gj) by the graph application 110. In some implementations, a neighborhood set for each data point may be generated by pre-assembling the data points using one or more random partition trees. The cluster closure module 122 may generate a cluster closure by expanding each data point in the cluster into its neighborhood set, as illustrated in FIG. 3.
At 206, data points are assigned to clusters based at least in part on cluster closures by the graph application 110. For each cluster closure {Gj}, the k-Means approximator module 120 may determine the data points (x) contained by the cluster closure (Gj), and for each of those data points (xisεGj, s=1, 2, . . . , Gj), the k-Means approximator module 120 may (i) determine the distances between the respective data point and the respective cluster centroids (cm), and (ii) assign the respective data point to the cluster (G) corresponding to the closest cluster centroid: if ∥xis−cj(t)∥22<D[i], then zi(t+1)=j, and D[i]=∥xis−cj(t)∥22, where cj(t) is the cluster centroid of Gj at the tth iteration, zi(t) denotes the cluster (j) to which the ith data point is assigned at the tth iteration, and i is the global index for x and s is the index into Gj for the data point x.
At 208, the k-Means approximator module 120 updates the data points in each cluster, Gj(t+1)={xi|zj(t+1)=j}, and determines a new cluster centroid for each cluster,




  
    c
    j
    
      (
      
        t
        +
        1
      
      )
    
  
  =
  
    
      1
      
        
        
          G
          j
          
            (
            
              t
              +
              1
            
            )
          
        
        
      
    
    ⁢
    
      
        ∑
        
          
            x
            i
          
          ∈
          
            G
            j
            
              (
              
                t
                +
                1
              
              )
            
          
        
      
      ⁢
      
        
          x
          i
        
        .
      
    
  




The cluster centroids, cj(t+1), correspond to the mean of the data points currently assigned to the corresponding updated cluster Gj(t+1).

At 210, the graph application 110 determines whether the clustering process is finished. The graph application 110 may determine that the clustering process has finished based at least in part on number of active points that change clusters in successive iterations. For example, if the number of active points that change clusters in sequential iterations is less than a threshold level, then the graph application 110 may determine that the clustering process is finished.
If negative, the graph application 110 returns to 204 for another iteration If affirmative, the process continues at 212, where the graph application 110 may determine the codebook 116 based at least in part on the set of cluster centroids C={c1, c2, c3, . . . ck}.
FIG. 3 is a flowchart of another example process 300 showing high-level functions performed by the graph application 110 in accordance with a second non-limiting embodiment.
At 302, a data set is acquired and initialized by the graph application 110. The data set may be comprised of n data points, e.g., {x1, x2, x3, . . . xn}, where each data point (x) is a d-dimensional vector. The partition module 118 may generate one or more random partition trees from the data set, however in some implementations, a single random partition tree is created from the data set. In some implementations, every data point (xi) may be randomly assigned to a cluster (cj). In other implementations, cluster centroids may be randomly generated and distributed through the space spanning the data set. In some instances, a distance array (D) may be initialized. The elements of the distance array may correspond to data points of the data set, and the elements of the distance array may be set to a predetermined value. In some implementations, the predetermined value may be larger than a largest distance of the space spanning the data set.
At 304, cluster closure members, or active points, are identified for each cluster (Gj) by the graph application 110. The cluster closure module 122 may generate a cluster closure in which members may be identified using one or more existing random partition trees.
At 306, data points are assigned to clusters based at least in part on cluster closures by the k-Means approximator module 120.
At 308, the k-Means approximator module 120 updates the data points in each cluster, Gj(t+1)={xi|zj(t+1)=j}, and determines a new cluster centroid for each cluster,




  
    c
    j
    
      (
      
        t
        +
        1
      
      )
    
  
  =
  
    
      1
      
        
        
          G
          j
          
            (
            
              t
              +
              1
            
            )
          
        
        
      
    
    ⁢
    
      
        ∑
        
          
            x
            i
          
          ∈
          
            G
            j
            
              (
              
                t
                +
                1
              
              )
            
          
        
      
      ⁢
      
        
          x
          i
        
        .
      
    
  




At 312, the graph application 110 determines whether the rate of convergence is satisfactory. For example, if the graph application 110 determines that a change to the within-cluster sum of squared distortions (see equation 1) in successive iterations is less than a threshold amount, then the graph application 110 determines that the rate of convergence is unsatisfactory. If affirmative, the clustering process continues at 314. If negative, the clustering process continues at 312.
At 312, the partition module 118 creates another random partition tree from the data set. Increasing the number of existing random partition trees expands the number of active points, and thereby increasing the number of active points that are in a neighborhood of a given data point.
At 314, the graph application 110 determines whether the clustering process is finished. The graph application 110 may determine that the clustering process has finished based at least in part on number of active points that change clusters in successive iterations. For example, if the number of active points that change clusters in sequential iterations is less than a threshold level, then the graph application 110 may determine that the clustering process is finished.
If negative, the graph application 110 returns to 304 for another iteration If affirmative, the process continues at 316, where the graph application 110 may determine the codebook 116 based at least in part on the set of cluster centroids C={c1, c2, c3, . . . ck}.
Construct Neighborhood Nx 
FIG. 4 is a flowchart illustrating an example process 400 for constructing an approximate neighborhood.
The graph application 110 receives a set of data points 402. The data points may be from a collection of images on a website, images of people, places or things, medical images, fingerprint images, video content, and the like. The set of data points may take many forms, such as video sequences, views from multiple cameras, or multi-dimensional data from a medical scanner. For instance, the set of data points may be represented by X={x1, x2, xn} with xiεRd where Rd represents a d-dimensional Euclidean space.
The partition module 118 partitions the set of data points 402 into subsets 404 and 406. The partition module 118 performs a random division by using a methodology of a hyperplane or a hypersphere to partition the set of data points 402. This process makes nearby data points lie in a same subset. For instance, the partition module 118 divides the set of data points X into two non-overlapping subsets such as, a first set of data points on the top side represented by Xt and a second set of data points on the bottom side represented by Xb to satisfy a criteria that Xt∪Xb=X and Xt∩Xb=Ø.
The partition module 118 may continue to randomly and hierarchically partition the subsets 404 and 406 into subsets further subsets 408-414.
A single approximate neighborhood for each data point (x) can be derived from a random partition (RP) tree, and the final neighborhood may be assembled by combining the results from multiple random spatial partitions. For example, a leaf node (e.g., subset 408) of a single RP tree contains a set of points V={xj}, where the set of points V is a subset of the set of data points 402, and all the points in V may be considered to be mutually neighboring to each other. Thus the neighborhood of a point x in the set V can be straightforwardly computed by Nx=V.
Since RP trees are efficient to construct, the above neighborhood computation is also efficient. While a cluster closure from one single RP tree may miss some active points, using multiple RP trees effectively handles this problem. The neighborhoods of x from all the RP trees may be united:

Nx=UlVl,  (4)

where V1 is the leaf set from the l-th RP tree that contains the data point x. Note that a data point x may belong to multiple cluster closures. Also note that, in some implementations, the neighborhood of a given data point is computed only once.

Construct Cluster Closure

FIGS. 5A and 5B schematically illustrate an example process for constructing a cluster closure.
A set of data points 500 may be conceptualized as being comprised of: assigned data points 502, represented by a solid black circular shape; identified active data points 504, represented by a solid grey circular shape; and non-neighboring data points 506, represented by a solid white circular shape.
A cluster Gj having a boundary 508, which is represented by a solid black line, is comprised of assigned data points 502 during a current iteration. The cluster Gj has a current cluster centroid 510 that is represented by a square shape.
Each one of the identified active data points 504 is within a neighborhood depth (ND) of a given one of the assigned data points 502. For a given assigned data point 502, the cluster closure module 122 may determine whether there exists any of data point that is within the neighborhood depth (ND) of the given assigned data point 502, and if such a data point exists and the data point is not another assigned data point, the cluster closure module 122 may identify the data point as an identified active data point 504. The cluster closure module 122 may utilize one or more random partition trees to locate the data points that are within the neighborhood depth (ND) of a given assigned data point 502. For example, the cluster closure module 122 may partition the set of data points 402 into multiple subsets 408-414 and may regard each data point contained by a given subset as being within the neighborhood depth (ND) of every other data point contained by the given subset. In some implementations, the cluster closure module 122 may locate neighboring data points for all of the assigned data points 502. In other implementations, the cluster closure module 122 may locate neighboring data points for assigned data points 502 that within a threshold distance of the boundary 508.
The union of the assigned data points 502 and all of the identified active data points 504 comprise data points that currently make up a cluster closure (Gj), represented by the dashed line 512.
For each cluster (Gj) of the set of clusters G={G1, G2, G3, . . . Gk}, the cluster closure module 122 determines a corresponding cluster closure (Gj) to form a set of cluster closures G={G1, G2, G3, . . . Gk}. Each cluster closure (Gj) envelopes an associated cluster (Gj) and contains data points of the associated cluster (Gj) and data points that neighbor the associated cluster (Gj).
At each iteration, the k-Means approximator module 120 may verify whether a data point belonging to a cluster closure (Gj) should be assigned to the corresponding cluster (Gj). For each cluster (Gj) of the set of clusters G={G1, G2, G3, . . . Gk}, the k-Means approximator module 120 calculates the distance between the cluster centroid 510 of cluster (Gj) and each data point belonging to the cluster closure (Gj). Whenever a calculated distance between the cluster centroid 510 of cluster (Gj) and a given data point is less that a previously calculated distance between the given data point and a cluster centroid for any cluster, the k-Means approximator module 120 updates a corresponding entry in the distance array and assigns the given data point to the cluster (Gj).
For example, assume a set of clusters is given by G={G1, G2, G3, . . . G6} and the corresponding set of cluster closures is given by G={G1, G2, G3, . . . G6} and a given data point is determined to belong to cluster closures G1 and G2, then the k-Means approximator module 120 calculates the distance between the given data point and the cluster centroid 510 of cluster G1 and the cluster centroid 510 of cluster G2 but does not calculate the distance between the given data point and cluster centroids of other clusters (i.e., G3, G4, G5, G6).
In some embodiments, assigning data points to clusters may be implemented in another way. For each data point x, candidate cluster centroids are computed by checking the cluster memberships Zx of the data points within the neighborhood of x. In this instance, Zx={z(y)|yεNx}, and z(y) is the cluster membership of data point y. Then the best cluster candidate for x can be found by checking the clusters {cj|jεZx}. In this implementation, the assignments are computed independently and may be computed in parallel. Similarly, the updated cluster centroids (i.e., the mean for each the cluster) may be computed independently and may computed in parallel. Clustering performance in which assignment and updating are performed in parallel is described by Jing Wang, Jingdong Wang, Qifa Ke, Gang Zeng, and Shipeng Li, CVPR '12 Proceedings of the 2012 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 3037-3044.
Example Server Implementation
FIG. 6 is a block diagram to illustrate an example server usable with the environment of FIG. 1. The image server 112 may be configured as any suitable system capable of services, which includes, but is not limited to, implementing the search service 106 for image searches, such as providing the search engine to perform the image search. In one example configuration, the image server 112 comprises at least one processor 600, a memory 602, and a communication connection(s) 604. The processor(s) 600 may be implemented as appropriate in hardware, software, firmware, or combinations thereof. Software or firmware implementations of the processor(s) 600 may include computer-executable or machine-executable instructions written in any suitable programming language to perform the various functions described.
In an implementation, a computer-readable storage media stores instructions, that when executed on the processor 600, presents a user interface to receive an image query. The instructions further include generating the codebook 116 based at least on a set of cluster centroids determined by the k-Mean approximator module 120 utilizing the partition module 118 and the cluster closure module 122.
Similar to that of computing environment 100 of FIG. 1, memory 602 may store program instructions that are loadable and executable on the processor(s) 600, as well as data generated during the execution of these programs. Depending on the configuration and type of computing device, memory 602 may be volatile (such as random access memory (RAM)) and/or non-volatile (such as read-only memory (ROM), flash memory, etc.).
The communication connection(s) 604 may include access to a wide area network (WAN) module, a local area network module (e.g., WiFi), a personal area network module (e.g., Bluetooth), and/or any other suitable communication modules to allow the image server 112 to communicate over the network(s) 104.
Turning to the contents of the memory 602 in more detail, the memory 602 may store an operating system 606, a search service module 608, the graph application 110, and one or more applications 610 for implementing all or a part of applications and/or services using the search service 608.
The one or more other applications 610 may include an email application, online services, a calendar application, a navigation module, a game, and the like. The memory 602 in this implementation may also include the graph application 110, the codebook 116, the partition module 118, the k-Means approximator module 120, and the cluster closure module 122.
The graph application 110 may perform the operations described with reference to the figures or in combination with the search service module 608, and/or the partition module 118, the k-Means approximator module 120, and the cluster closure module 122.
The partition module 118, the k-Means approximator module 120, and the cluster closure module 122 may perform the operations separately or in conjunction with the graph application module 110, as described with reference to FIGS. 2-5.
The server 112 may include (or have access to) the database 124 to store images, algorithms, hash table, lists, and the like. Alternatively, this information may be stored on other databases.
The server 112 may also include additional removable storage 612 and/or non-removable storage 614 including, but not limited to, magnetic storage, optical disks, and/or tape storage. The disk drives and their associated computer-readable media may provide non-volatile storage of computer readable instructions, data structures, program modules, and other data for the computing devices. In some implementations, the memory 602 may include multiple different types of memory, such as static random access memory (SRAM), dynamic random access memory (DRAM), or ROM.
The server 112 as described above may be implemented in various types of systems or networks. For example, the server may be a part of, including but is not limited to, a client-server system, a peer-to-peer computer network, a distributed network, an enterprise architecture, a local area network, a wide area network, a virtual private network, a storage area network, and the like.
Various instructions, methods, techniques, applications, and modules described herein may be implemented as computer-executable instructions that are executable by one or more computers, servers, or computing devices. Generally, program modules include routines, programs, objects, components, data structures, etc. for performing particular tasks or implementing particular abstract data types. These program modules and the like may be executed as native code or may be downloaded and executed, such as in a virtual machine or other just-in-time compilation execution environment. The functionality of the program modules may be combined or distributed as desired in various implementations. An implementation of these modules and techniques may be stored on or transmitted across some form of computer-readable media.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described. Rather, the specific features and acts are disclosed as example forms of implementing the claims.

## Claims

1. A method implemented at least partially by a processor, the method comprising:
constructing a codebook of a set of data points, wherein the codebook comprises a set of cluster centroids of a corresponding set of clusters, wherein each cluster of the set of clusters includes a corresponding subset of the set of data points, each cluster of the set of clusters being defined by a respective cluster boundary, the constructing comprising:
identifying neighboring data points located within a threshold distance from at least one of a cluster boundary or a data point included in a subset of the set of data points included in a cluster of the set of clusters;
constructing a cluster closure for each cluster of the set of clusters to create a corresponding set of cluster closures, each cluster closure of the set of cluster closures including a cluster of the set of clusters and an area exterior a respective cluster boundary of the cluster, the area included in each cluster closure and exterior the respective cluster boundary of the respective cluster being within the threshold distance; and
iteratively assigning at least one neighboring data point of the neighboring data points to one cluster of the set of clusters, the assigning comprising:
identifying a subset of cluster closures from the set of cluster closures whose areas exterior their respective cluster boundaries include the at least one neighboring data point, wherein the subset of cluster closures includes one cluster closure corresponding to the one cluster, and wherein the subset of cluster closures includes at least two cluster closures and less than all of the set of cluster closures;
based at least in part on identifying the subset of cluster closures, calculating distances between the at least one neighboring data point and cluster centroids of each cluster corresponding to the subset of cluster closures;
based at least in part on a comparison of the distances between the at least one neighboring data point and the cluster centroids of each of the subset of cluster closures, assigning the at least one neighboring data point included in the subset of cluster closures to the one cluster; and
updating a corresponding subset of data points of the one cluster to include the at least one neighboring data point and calculating an updated cluster centroid for the one cluster based at least in part on the updated corresponding subset of data points.

2. The method of claim 1, wherein the identifying the neighboring data points located within the threshold distance from the at least one of the cluster boundary or the data point included in a cluster of the set of clusters comprises partitioning data points of the set of data points.

3. The method of claim 2, wherein the partitioning the data points comprises using a methodology of a random hierarchical binary partition.

4. The method of claim 2, wherein the partitioning the data points comprises recursively dividing the data points into subsets.

5. The method of claim 1, wherein the at least one neighboring data point is not contained by any other cluster closure that is not a member of the subset of cluster closures.

6. The method of claim 1, wherein each of the subset of cluster closures includes a corresponding cluster, at least one of the corresponding clusters comprising the one cluster.

7. The method of claim 1, wherein the assigning the at least one neighboring data point to the one cluster further comprises comparing the distances between the at least one neighboring data point and centroids of the subset of cluster closures to determine a minimum distance, wherein the at least one neighboring data point is assigned to the one cluster corresponding to the minimum distance.

8. The method of claim 6, wherein the corresponding clusters comprise a first subset of clusters corresponding to the subset of cluster closures, wherein the set of clusters is comprised of the first subset of clusters and a second subset of clusters, the first subset and the second subset being non-intersecting, wherein distances between the at least one neighboring data point and cluster centroids are not calculated for any current cluster centroid corresponding to the second subset of clusters.

9. The method of claim 1, further comprising determining the threshold distance based at least in part on one or more random spatial partitions.

10. One or more computer-readable storage media storing instructions that, when executed by a processor, cause one or more processors to perform acts comprising:
identifying neighboring data points for each data point of a set of data points based at least in part on the neighboring data points being located within a threshold distance from at least one data point of the set of the data points;
iteratively clustering the set of data points into a set of k-mean clusters, wherein each cluster of the set of k-mean clusters has a corresponding cluster centroid that is an arithmetic mean of data points assigned to each cluster, each cluster of the set of k-mean clusters being defined by a cluster boundary, the clustering comprising:
constructing a set of cluster closures for the set of k-mean clusters, individual ones of the set of cluster closures being defined by a corresponding cluster closure boundary comprising an area including individual ones of the set of k-mean clusters such that each cluster closure is comprised of data points located interior to the corresponding cluster boundary and neighboring data points located exterior to the corresponding cluster boundary and within the corresponding cluster closure boundary, each cluster closure boundary being located a threshold distance from at least one of the corresponding cluster boundary or a data point of the data points located interior to the corresponding cluster boundary,
iteratively assigning a neighboring data point to a cluster of the set of k-mean clusters, the assigning comprising:
identifying a subset of cluster closures of the set of cluster closures whose areas each include a first neighboring data point, the subset of cluster closures each including a respective cluster of the set of k-mean clusters, wherein the subset of cluster closures includes at least two cluster closures and less than all of the set of cluster closures;
based at least in part on identifying the subset of cluster closures, calculating a distance between the first neighboring data point and each of the corresponding cluster centroids of the respective clusters of the subset of cluster closures;
based at least in part on the distances, assigning the first data point to one of the respective clusters; and

for each cluster of the set of k-mean clusters, updating a cluster centroid of a corresponding cluster based at least in part on neighboring data points assigned to the corresponding cluster; and

generating a codebook based at least in part on a set of cluster centroids, wherein the set of cluster centroids is comprised of updated cluster centroids of the set of k-mean clusters.

11. The computer-readable storage media of claim 10, wherein the acts further comprise:
generating a random partition tree of the set of data points, wherein the random partition tree is comprised of a plurality of leaf nodes, each leaf node corresponds to a subset of the set of data points and is comprised of a corresponding plurality of data points of the set of data points, and wherein for each data point, neighboring data points that are within a neighborhood depth of a respective data point are identified utilizing the leaf nodes of the random partition tree.

12. The computer-readable storage media of claim 11, wherein the acts further comprise:
determining whether a rate of convergence for the clustering of the set of data points exceeds a threshold amount; and
performing another iteration of the clustering of the set of data points responsive to the rate of convergence being greater than or equal to the threshold amount.

13. The computer-readable storage media of claim 12, wherein the random partition tree is a first random partition tree, and wherein the acts further comprise:
responsive to the rate of convergence being less than the threshold amount,
generating a second random partition tree of the set of data points responsive to the rate of convergence being less than the threshold amount, wherein the second random partition tree is comprised of a plurality of leaf nodes, each leaf node comprised of a corresponding plurality of data points of the set of data points,
identifying neighboring data points for each data point utilizing leaf nodes of all of the partition trees, and
performing another iteration of the clustering of the set of data points based at least in part on the set of cluster closures identifying neighboring data points for each data point via the leaf nodes of all of the partition trees.

14. The computer-readable storage media of claim 13, wherein the acts further comprise:
determining whether a current rate of convergence for the clustering of the set of data points exceeds the threshold amount;
performing another iteration of the clustering of the set of data points responsive to the current rate of convergence being greater than or equal to the threshold amount; and
responsive to the current rate of convergence being less than the threshold amount,
generating at least a third random partition tree of the set of data points, wherein the third random partition tree is comprised of a plurality of leaf nodes, each leaf node comprised of a corresponding plurality of data points of the set of data points,
identifying neighboring data points for each data point utilizing leaf nodes of all of the first, the second, and the at least third partition trees, and
performing another iteration of the clustering of the set of data points based at least in part on the set of cluster closures identifying neighboring data points for each data point via the leaf nodes of all of the first, the second, and the at least third partition trees.

15. The computer-readable storage media of claim 10, wherein the assigning the neighboring data point to a cluster of the set of k-mean clusters includes assigning, in parallel, data points of the set of data points to corresponding clusters of the set of k-mean clusters.

16. The computer-readable storage media of claim 10, wherein the updating the cluster centroid of the corresponding cluster includes updating, in parallel, each corresponding cluster centroid for each cluster of the set of k-mean clusters.

17. A system comprising:
one or more processors; and
a memory that includes a plurality of computer-executable components, the plurality of computer-executable components comprising:
a partition module that generates at least one random partition tree having leaf nodes from a set of data points, each leaf node comprised of a subset of the data points;
a cluster closure module configured to generate a set of cluster closures based at least in part on the at least one random partition tree, each cluster closure being defined by a corresponding cluster closure boundary and comprising a cluster closure area including a corresponding cluster of a set of clusters, each cluster of the set of clusters being defined by a cluster boundary and comprising a corresponding plurality of data points of the set of data points, each cluster closure boundary being located a threshold distance from at least one of the corresponding cluster boundary or a data point of the plurality of data points included in the corresponding cluster, and each cluster closure area comprised of neighboring data points located exterior a cluster boundary of a corresponding cluster and within a cluster closure boundary of a corresponding cluster closure;
a k-Means approximator module that assigns a given neighboring data point to a given cluster of the set of clusters based at least in part on:
identifying a subset of cluster closures, from the set of cluster closures, whose cluster closure areas include the given neighboring data point, wherein the subset of cluster closures comprises at least two cluster closures and less than all of the set of cluster closures;
based at least in part on identifying the subset of cluster closures, calculating a distance between the given neighboring data point and a corresponding cluster centroid for each cluster closure in the subset of cluster closures having the given neighboring data point; and
based at least in part on the distances between the given neighboring data point and the corresponding cluster centroids for each cluster closure in the subset of cluster closures, assigning the given neighboring data point to the given cluster; and

a graph application that generates entries a codebook based at least in part on a set of cluster centroids that corresponds to cluster centroids of the set of clusters, and that compares a received query with the entries in the codebook to provide search results for the received query.

18. The system of claim 17, wherein the k-Means approximator module assigns data points to clusters of the set of clusters in parallel.

19. The system of claim 17, wherein the k-Means approximator assigns the given neighboring point to the given cluster of the set of clusters based at least in part on determining that a distance between the given neighboring data point and a cluster centroid for the given cluster is shorter than distances between the corresponding cluster centroids for each cluster closure in the subset of cluster closures having the given neighboring data point.