Module Expr Str Import alias alias alias alias alias Import alias alias ImportFrom alias Import alias alias alias Import alias identifier ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam NameParam NameParam defaults Num Str Num body Expr Str Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str Expr Str If UnaryOpNot CompareEq NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr ListLoad SubscriptLoad AttributeLoad NameLoad attr Index Num BinOpAdd SubscriptLoad AttributeLoad NameLoad attr Index Num Num Assign SubscriptStore NameLoad ExtSlice Slice Slice Num SubscriptLoad AttributeLoad NameLoad attr Index Num NameLoad Assign SubscriptStore NameLoad ExtSlice Slice Index SubscriptLoad AttributeLoad NameLoad attr Index Num NameLoad orelse Assign NameStore NameLoad Assign AttributeStore NameLoad attr NameLoad If CompareIs AttributeLoad NameLoad attr NameLoad body Assign AttributeStore NameLoad attr NameLoad orelse Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad keyword Num decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign AttributeStore NameLoad attr Call NameLoad SubscriptLoad AttributeLoad NameLoad attr ExtSlice Slice Slice Num keyword AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str If CompareIs NameLoad NameLoad body Assign NameStore AttributeLoad NameLoad attr If CompareIs NameLoad NameLoad body Assign NameStore AttributeLoad NameLoad attr If CompareIs AttributeLoad NameLoad attr NameLoad body If CompareIs AttributeLoad NameLoad attr NameLoad body Return NameLoad Expr Call AttributeLoad NameLoad attr Assign TupleStore NameStore NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad If CompareEq NameLoad Num body Assign NameStore Call AttributeLoad NameLoad attr Num Num Assign NameStore Call AttributeLoad NameLoad attr Num Num Assign NameStore Call NameLoad Lambda arguments args NameParam defaults Call NameLoad Lambda arguments args NameParam defaults SubscriptLoad NameLoad Index Num SubscriptLoad AttributeLoad NameLoad attr Index NameLoad NameLoad If CompareEq NameLoad Str body Return SubscriptLoad Call NameLoad Lambda arguments args NameParam defaults SubscriptLoad Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr NameLoad Index Num NameLoad Index Num orelse If CompareEq NameLoad Str body Return Call AttributeLoad NameLoad attr Call NameLoad Lambda arguments args NameParam defaults Call AttributeLoad NameLoad attr NameLoad NameLoad orelse If CompareEq NameLoad Str body Return Call AttributeLoad NameLoad attr Call NameLoad Lambda arguments args NameParam defaults Call AttributeLoad NameLoad attr NameLoad NameLoad orelse If CompareEq NameLoad Str body Return Call AttributeLoad NameLoad attr NameLoad orelse If CompareEq NameLoad Str body Return TupleLoad Call AttributeLoad NameLoad attr NameLoad NameLoad decorator_list decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore Call NameLoad NameLoad Return Call AttributeLoad NameLoad attr ListComp Call NameLoad NameLoad Call AttributeLoad Call AttributeLoad NameLoad attr attr Str comprehension NameStore Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args defaults body Assign NameStore Str Assign NameStore Num Assign NameStore Num Assign NameStore Num Assign NameStore BinOpMult TupleLoad TupleLoad Num Num NameLoad Assign NameStore TupleLoad Num Num Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad keyword Str Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr For NameStore Call NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr ListLoad SubscriptLoad NameLoad Slice Num Print NameLoad Str NameLoad Assign NameStore Call AttributeLoad NameLoad attr Print BinOpSub NameLoad NameLoad Str NameLoad Str BinOpDiv BinOpSub NameLoad NameLoad Call NameLoad NameLoad Str decorator_list FunctionDef arguments args defaults body Expr Call NameLoad decorator_list If CompareEq NameLoad Str body Expr Call NameLoad
N/A N/A 
(c) 2011, 2012 Georgia Tech Research Corporation
This source code is released under the New BSD license.  Please see
http://wiki.quantsoftware.org/index.php?title=QSTK_License
for license details.

A simple wrapper for scipy.spatial.kdtree.KDTree for doing KNN
 N/A math random sys bisect time N/A numpy scipy.spatial.distance scipy.spatial cKDTree N/A cProfile pstats gendata N/A numpy np kdtknn N/A object N/A N/A 
    A simple wrapper of scipy.spatial.kdtree.KDTree
    
    Since the scipy KDTree implementation does not allow for incrementally adding
    data points, the entire KD-tree is rebuilt on the first call to 'query' after a
    call to 'addEvidence'. For this reason it is more efficient to add training data
    in batches.
     __init__ N/A N/A self k method leafsize N/A 3 mean 10 N/A N/A 
        Basic setup.
         N/A N/A self leafsize leafsize N/A N/A self data None N/A N/A self kdt None N/A N/A self rebuild_tree True N/A N/A self k k N/A N/A self method method N/A addEvidence N/A N/A self dataX dataY N/A None N/A N/A 
        @summary: Add training data
        @param dataX: Data to add, either entire set with classification as last column, or not if
                      the Y data is provided explicitly.  Must be same width as previously appended data.
        @param dataY: Optional, can be used 
        
        'data' should be a numpy array matching the same dimensions as any data 
        provided in previous calls to addEvidence, with dataY as the 
        training label.
         N/A  Slap on Y column if it is provided, if not assume it is there  N/A N/A N/A dataY None N/A N/A data N/A N/A numpy zeros N/A N/A N/A dataX shape N/A 0 N/A N/A N/A dataX shape N/A 1 1 N/A N/A data N/A N/A N/A 0 N/A N/A dataX shape N/A 1 dataX N/A N/A data N/A N/A N/A N/A N/A dataX shape N/A 1 dataY N/A N/A data dataX N/A N/A self rebuild_tree True N/A N/A N/A self data None N/A N/A N/A self data data N/A N/A N/A self data N/A N/A numpy append N/A self data data axis 0 N/A rebuildKDT N/A N/A self N/A N/A N/A 
        Force the internal KDTree to be rebuilt.
         N/A N/A self kdt N/A cKDTree N/A N/A self data N/A N/A N/A -1 leafsize N/A self leafsize N/A N/A self rebuild_tree False N/A query N/A N/A self points k method N/A None None N/A N/A 
        Classify a set of test points given their k nearest neighbors.
        
        'points' should be a numpy array with each row corresponding to a specific query.
        Returns the estimated class according to supplied method (currently only 'mode'
        and 'mean' are supported)
         N/A N/A k None N/A N/A k N/A self k N/A N/A method None N/A N/A method N/A self method N/A N/A N/A self rebuild_tree True N/A N/A N/A N/A self data None N/A N/A None N/A N/A N/A self rebuildKDT N/A N/A na_dist na_neighbors N/A N/A N/A self kdt query points k N/A N/A k 1 N/A N/A na_dist N/A N/A na_dist reshape -1 1 N/A na_neighbors N/A N/A na_neighbors reshape -1 1 N/A n_clsses N/A map N/A N/A N/A rslt N/A N/A map N/A N/A N/A p N/A N/A p N/A -1 N/A N/A self data N/A rslt na_neighbors N/A N/A method mode N/A N/A N/A N/A map N/A N/A N/A x N/A N/A N/A N/A N/A N/A scipy stats stats mode x N/A 0 n_clsses N/A 0 N/A N/A N/A method mean N/A N/A N/A N/A numpy array N/A map N/A N/A N/A x N/A N/A N/A numpy mean x n_clsses N/A N/A N/A method median N/A N/A N/A N/A numpy array N/A map N/A N/A N/A x N/A N/A N/A numpy median x n_clsses N/A N/A N/A method raw N/A N/A N/A N/A numpy array n_clsses N/A N/A N/A method all N/A N/A N/A N/A N/A numpy array n_clsses na_dist N/A N/A getflatcsv N/A N/A fname N/A N/A N/A inf N/A open fname N/A N/A N/A numpy array N/A N/A map float N/A N/A N/A N/A s strip split , N/A s N/A N/A inf readlines N/A testgendata N/A N/A N/A N/A N/A fname test2.dat N/A querys 1000 N/A d 2 N/A k 3 N/A bnds N/A N/A N/A -10 10 d N/A clsses N/A 0 1 N/A data N/A getflatcsv fname N/A kdt N/A kdtknn k method mode N/A N/A N/A kdt addEvidence data N/A N/A N/A kdt rebuildKDT N/A stime N/A N/A time time N/A x N/A xrange querys N/A N/A pnt N/A N/A numpy array N/A N/A gendata gensingle d bnds clsses N/A reslt N/A N/A kdt query N/A N/A numpy array N/A N/A pnt N/A -1 N/A pnt -> reslt N/A etime N/A N/A time time N/A N/A etime stime / querys = N/A N/A etime stime N/A float querys avg wallclock time per query N/A test N/A N/A N/A N/A N/A N/A testgendata N/A N/A N/A __name__ __main__ N/A N/A N/A test