Changeset 7


Ignore:
Timestamp:
07/09/15 12:58:10 (9 years ago)
Author:
tim
Message:

.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/train

    r6 r7  
    323323   
    324324    start = time.time()
    325     wt = WorkerThreads(2, trainAux)
     325    wt = WorkerThreads(4, trainAux)
    326326   
    327327    num_trials = 20
     
    429429
    430430start = time.time()
    431 #cProfile.run('results = trainMidhinge(db, unusual_case, greater, 100)')
    432 results = trainMidhinge(db, unusual_case, greater, 100)
     431cProfile.run('results = trainMidhinge(db, unusual_case, greater, 100)')
     432#results = trainMidhinge(db, unusual_case, greater, 100)
    433433#db.addClassifierResults(results)
    434434print("midhinge result:", results)
  • trunk/lib/nanownlib/stats.py

    r6 r7  
    229229
    230230def subseries(db, probe_type, unusual_case, size=None, offset=None, field='packet_rtt'):
    231     cursor = db.conn.cursor()
    232     cursor.execute("SELECT max(c) FROM (SELECT count(sample) c FROM probes WHERE type=? GROUP BY test_case)", (probe_type,))
    233     population_size = cursor.fetchone()[0]
     231    population_size = db.populationSize(probe_type)
    234232
    235233    if size == None or size > population_size:
     
    248246   
    249247    params = {"probe_type":probe_type, "unusual_case":unusual_case, "offset":offset, "size":size}
     248    cursor = db.conn.cursor()
    250249    cursor.execute(query, params)
    251     for row in cursor:
    252         size -= 1
    253         yield dict(row)
    254 
     250    ret_val = [dict(row) for row in cursor.fetchall()]
     251    #for row in cursor:
     252    #    size -= 1
     253    #    yield dict(row)
     254
     255    size -= len(ret_val)
    255256    if size > 0:
    256257        params['offset'] = 0
    257258        params['size'] = size
    258259        cursor.execute(query, params)
    259         for row in cursor:
    260             yield dict(row)
    261    
     260        ret_val += [dict(row) for row in cursor.fetchall()]
     261        #for row in cursor:
     262        #    yield dict(row)
     263   
     264    return ret_val
     265
    262266
    263267# if test_cases=None, include all of them.  Otherwise, include only the specified test cases.
  • trunk/lib/nanownlib/storage.py

    r4 r7  
    1414    conn = None
    1515    cursor = None
     16    _population_sizes = None
     17   
    1618    def __init__(self, path):
    1719        exists = os.path.exists(path)
     
    1921        self.conn.execute("PRAGMA foreign_keys = ON;")
    2022        self.conn.row_factory = sqlite3.Row
     23        self._population_sizes = {}
    2124       
    2225        if not exists:
     
    8689            self.conn.close()
    8790
     91    def populationSize(self, probe_type):
     92        if probe_type in self._population_sizes:
     93            return self._population_sizes[probe_type]
     94
     95        try:
     96            cursor = self.conn.cursor()
     97            cursor.execute("SELECT max(c) FROM (SELECT count(sample) c FROM probes WHERE type=? GROUP BY test_case)", (probe_type,))
     98            self._population_sizes[probe_type] = cursor.fetchone()[0]
     99            return self._population_sizes[probe_type]
     100        except Exception as e:
     101            print(e)
     102            return 0
     103       
    88104    def _insert(self, table, row):
    89105        rid = _newid()
Note: See TracChangeset for help on using the changeset viewer.