Package QSTK :: Package qstklearn :: Module parallelknn
[hide private]
[frames] | no frames]

Module parallelknn

source code

Created on Feb 1, 2011


Author: Shreyas Joshi

Organization: Georgia Institute of Technology

Contact: shreyasj@gatech.edu

Status: complete. "mode" untested

Functions [hide private]
 
par_query(allQueries, k, method='mean', noOfThreads=None)
Finds the k- nearest nrighbors in parallel. Based on function "query"
source code
 
query(allQueries, k, method='mean')
A serial implementation of k-nearest neighbors.
source code
 
addEvidence(newData)
This is the funtion to be called to add data. This function can be called multiple times- to add data whenever you like.
source code
 
main(args)
This function is just for testing. Will not be used as such...
source code
Variables [hide private]
  data = array([], dtype=float64)
  __package__ = 'QSTK.qstklearn'
Function Details [hide private]

par_query(allQueries, k, method='mean', noOfThreads=None)

source code 
Parameters:
  • allQueries - is another 2D numpy array. Each row here is one query point. It has no 'y' values. These have to be calculated.
  • k - no. of neighbors to consider
  • method - method of combining the 'y' values of the nearest neighbors. Default is mean.
  • noOfThreads - optional parameter that specifies how many threads to create. Default value: no. of threads = value returned by cpu_count
Returns:
A numpy array with the predicted 'y' values for the query points. The ith element in the array is the 'y' value for the ith query point.

query(allQueries, k, method='mean')

source code 
Parameters:
  • allQueries - is another 2D numpy array. Each row here is one query point. It has no 'y' values. These have to be calculated.
  • k - no. of neighbors to consider
  • method - method of combining the 'y' values of the nearest neighbors. Default is mean.
Returns:
A numpy array with the predicted 'y' values for the query points. The ith element in the array is the 'y' value for the ith query point. If there is more than one mode then only the first mode is returned.

addEvidence(newData)

source code 
Parameters:
  • newData - A 2D numpy array. Each row is a data point and each column is a dimension. The last dimension corresponds to 'y' values.

Note: Any dimensional data can be added the first time. After that- the data must have the same number of columns as the data that was added the first time.