class_docstr: Search structure which provides query speedup at the loss of recall.
  
  There are two components to this.
  
  = Cluster Indexes =
  Uses cluster pruning index structure as defined in:
  http://nlp.stanford.edu/IR-book/html/htmledition/cluster-pruning-1.html
  
  Refer to ClusterIndex documentation.
  
  = Multiple Indexes =
  The MultiClusterIndex creates multiple ClusterIndexes. This method
  gives better recall at the cost of allocating more memory. The
  ClusterIndexes are created by randomly picking representative clusters.
  The randomization tends to do a pretty good job but it is not perfect.
  Elements can be assigned to clusters that are far from an optimal match.
  Creating more Indexes (random cluster allocations) increases the chances
  of finding a good match.
  
  There are three perameters that impact recall. Will discuss them all
  here:
  1) MuitiClusterIndex(matrix_size)
      This impacts the tree structure (see cluster index documentation).
      Has a good default value. By increasing this value your index will
      behave increasingly like brute force search and you will loose query
      efficiency. If matrix_size is greater than your number of records
      you get brute force search.
  2) MuitiClusterIndex.search(k_clusters)
      Number of clusters to check when looking for records. This increases
      recall at the cost of query speed. Can be specified dynamically.
  3) MuitiClusterIndex(num_indexes)
      Number of indexes to generate. This increases recall at the cost of
      query speed. It also increases memory usage. It can only be
      specified at index construction time.
  
      Compared to (2) this argument gives better recall and has comparable
      speed. This statement assumes default (automatic) matrix_size is
      used.
       Scenario 1:
  
       (a) num_indexes=2, k_clusters=1
       (b) num_indexes=1, k_clusters=2
  
       (a) will have better recall but consume 2x the memory. (a) will be
       slightly slower than (b).
  
       Scenario 2:
  
       (a) num_indexes=2, k_clusters=1, matrix_size >> records
       (b) num_indexes=1, k_clusters=2, matrix_size >> records
  
       This means that each index does a brute force search. (a) and (b)
       will have the same recall. (a) will be 2x slower than (b). (a) will
       consume 2x the memory of (b).
  
       Scenario 1 will be much faster than Scenario 2 for large data.
       Scenario 2 will have better recall than Scenario 1.
class_docstr_tok: ["Search","structure","which","provides","query","speedup","at","the","loss","of","recall",".","There","are","two","components","to","this",".","=","Cluster","Indexes","=","Uses","cluster","pruning","index","structure","as","defined","in",":","http",":","\/\/nlp.stanford.edu\/IR-book\/html\/htmledition\/cluster-pruning-1.html","Refer","to","ClusterIndex","documentation",".","=","Multiple","Indexes","=","The","MultiClusterIndex","creates","multiple","ClusterIndexes",".","This","method","gives","better","recall","at","the","cost","of","allocating","more","memory",".","The","ClusterIndexes","are","created","by","randomly","picking","representative","clusters",".","The","randomization","tends","to","do","a","pretty","good","job","but","it","is","not","perfect",".","Elements","can","be","assigned","to","clusters","that","are","far","from","an","optimal","match",".","Creating","more","Indexes","(","random","cluster","allocations",")","increases","the","chances","of","finding","a","good","match",".","There","are","three","perameters","that","impact","recall",".","Will","discuss","them","all","here",":","1",")","MuitiClusterIndex","(","matrix_size",")","This","impacts","the","tree","structure","(","see","cluster","index","documentation",")",".","Has","a","good","default","value",".","By","increasing","this","value","your","index","will","behave","increasingly","like","brute","force","search","and","you","will","loose","query","efficiency",".","If","matrix_size","is","greater","than","your","number","of","records","you","get","brute","force","search",".","2",")","MuitiClusterIndex.search","(","k_clusters",")","Number","of","clusters","to","check","when","looking","for","records",".","This","increases","recall","at","the","cost","of","query","speed",".","Can","be","specified","dynamically",".","3",")","MuitiClusterIndex","(","num_indexes",")","Number","of","indexes","to","generate",".","This","increases","recall","at","the","cost","of","query","speed",".","It","also","increases","memory","usage",".","It","can","only","be","specified","at","index","construction","time",".","Compared","to","(","2",")","this","argument","gives","better","recall","and","has","comparable","speed",".","This","statement","assumes","default","(","automatic",")","matrix_size","is","used",".","Scenario","1",":","(","a",")","num_indexes=2",",","k_clusters=1","(","b",")","num_indexes=1",",","k_clusters=2","(","a",")","will","have","better","recall","but","consume","2x","the","memory",".","(","a",")","will","be","slightly","slower","than","(","b",")",".","Scenario","2",":","(","a",")","num_indexes=2",",","k_clusters=1",",","matrix_size",">",">","records","(","b",")","num_indexes=1",",","k_clusters=2",",","matrix_size",">",">","records","This","means","that","each","index","does","a","brute","force","search",".","(","a",")","and","(","b",")","will","have","the","same","recall",".","(","a",")","will","be","2x","slower","than","(","b",")",".","(","a",")","will","consume","2x","the","memory","of","(","b",")",".","Scenario","1","will","be","much","faster","than","Scenario","2","for","large","data",".","Scenario","2","will","have","better","recall","than","Scenario","1","."]
docstr: Create a search index composed of multtiple ClusterIndexes. See
  class docstring for a description of the method.
  
  Args:
      features: A matrix with rows that represent records
          (corresponding to the elements in records_data) and columns
          that describe a point in space for each row.
      records_data: Data to return when a doc is matched. Index of
          corresponds to records_features.
      distance_type: Class that defines the distance measure to use.
      matrix_size: Ideal size for matrix multiplication. This controls
          the depth of the tree. Defaults to 2 levels (approx). Highly
          reccomended that the default value is used.
      num_indexes: Number of ClusterIndexes to construct. Improves recall
          at the cost of memory.
docstr_tok: ["Create","a","search","index","composed","of","multtiple","ClusterIndexes",".","See","class","docstring","for","a","description","of","the","method",".","Args",":","features",":","A","matrix","with","rows","that","represent","records","(","corresponding","to","the","elements","in","records_data",")","and","columns","that","describe","a","point","in","space","for","each","row",".","records_data",":","Data","to","return","when","a","doc","is","matched",".","Index","of","corresponds","to","records_features",".","distance_type",":","Class","that","defines","the","distance","measure","to","use",".","matrix_size",":","Ideal","size","for","matrix","multiplication",".","This","controls","the","depth","of","the","tree",".","Defaults","to","2","levels","(","approx",")",".","Highly","reccomended","that","the","default","value","is","used",".","num_indexes",":","Number","of","ClusterIndexes","to","construct",".","Improves","recall","at","the","cost","of","memory","."]
code: def __init__(
      self,
      features,
      records_data,
      distance_type=pysparnn.matrix_distance.CosineDistance,
      matrix_size=None,
      num_indexes=2,
  ):
      """Create a search index composed of multtiple ClusterIndexes. See
      class docstring for a description of the method.
  
      Args:
          features: A matrix with rows that represent records
              (corresponding to the elements in records_data) and columns
              that describe a point in space for each row.
          records_data: Data to return when a doc is matched. Index of
              corresponds to records_features.
          distance_type: Class that defines the distance measure to use.
          matrix_size: Ideal size for matrix multiplication. This controls
              the depth of the tree. Defaults to 2 levels (approx). Highly
              reccomended that the default value is used.
          num_indexes: Number of ClusterIndexes to construct. Improves recall
              at the cost of memory.
      """
  
      self.indexes = []
      for _ in range(num_indexes):
          self.indexes.append(
              (
                  ClusterIndex(
                      features, records_data, distance_type, matrix_size
                  )
              )
          )
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import collections
  import random
  import numpy
  import pysparnn.matrix_distance
label_desc: Use image node_id 1 to create a new MultiClusterIndex object from inherited base classes: object with example: obj = MultiClusterIndex(features, records_data, distance_type, matrix_size, num_indexes)