def computeDensity(df, focusPoints, level=1): """ Computes the predicted density for a list of focus points for a level --- df: Output dataframe from bayes step ['TIMESTAMP', 'Z', MU', 'VAR'] where 'MU' and 'VAR' both contains series of 3-tuples focusPoints: list of focus points [(a, b), (c, d), (e, f)] where a through f are floats level: integer 0 or 1 representing floor2 or floor18 --- Returns: dict {timestamp: densityDistribution} Note: to query, just densityDistribution.query(point) """ print 'COMPUTING PREDICTED DENSITY' print 'Reference points = ' + str(focusPoints) print 'mazeName = ' + str(getMazeName(level)) return computedensities.compute(getMazeName(level), focusPoints, df, quiet=True)
return result_df def predictGPonFile(fileName): df = pd.read_csv(fileName+'_A.csv', converters={"SHORTEST_PATHS": ast.literal_eval}) testTimes = pd.read_csv(fileName+'_B.csv') result_df = predictGP(df, testTimes) result_df.to_csv(fileName+'_OUT.csv') if __name__ == '__main__': if len(sys.argv) > 1: predictGPonFile(sys.argv[1]) quit() df = pd.read_csv('testGP.csv') testTimes = pd.read_csv('test_times.csv') df['SHORTEST_PATHS'] = df['SHORTEST_PATHS'].str.split(',') result = predictGP(df, testTimes) import computedensities densityDistribution = computedensities.compute('floor18map', [(8,8), (89,60), (55,5)], result) print densityDistribution #userID = df['USER'][0] #result = predictGP(df[df['USER'] == userID]) #print result
def predictGPonFile(fileName): df = pd.read_csv(fileName + '_A.csv', converters={"SHORTEST_PATHS": ast.literal_eval}) testTimes = pd.read_csv(fileName + '_B.csv') result_df = predictGP(df, testTimes) result_df.to_csv(fileName + '_OUT.csv') if __name__ == '__main__': if len(sys.argv) > 1: predictGPonFile(sys.argv[1]) quit() df = pd.read_csv('testGP.csv') testTimes = pd.read_csv('test_times.csv') df['SHORTEST_PATHS'] = df['SHORTEST_PATHS'].str.split(',') result = predictGP(df, testTimes) import computedensities densityDistribution = computedensities.compute('floor18map', [(8, 8), (89, 60), (55, 5)], result) print densityDistribution #userID = df['USER'][0] #result = predictGP(df[df['USER'] == userID]) #print result