コード例 #1
0
ファイル: views.py プロジェクト: sssllliang/interviewPrep
def predict_timestamps():
    if not flask.request.json:
        flask.abort(400)
    dp.setHours2Predict(TU.parseHours(flask.request.json))  
    hours = list(TU.formatHours(dp.getHours2Predict()))
    pred = dp.getPredictions()
    return json.dumps(TU.outStr(hours,pred)), 201 
コード例 #2
0
    fig3 = plt.figure()
    plt.boxplot(aDays.values())
    plt.title('Demand vs day of week')
    plt.xlabel('Day')
    plt.ylabel('Demand')
    plt.show()
    
def writeCSV(filename, data):
    out = csv.writer(open(filename, 'wb'), delimiter=',') 
    for d in data:
        print d
   	out.writerow(d.split(','))
    
#reload(DP)
#reload(TU)

fd =  open('uber_demand_prediction_challenge.json')

jsonData = json.load(fd)
fd.close()
dp = DP.DemandPrediction()
dp.setTrainingData(jsonData)
dp.train()
mayHours = DP.genHours('2012-05-01T00:00:00+00:00', '2012-06-01T00:00:00+00:00')
dp.setHours2Predict(mayHours)
pred = dp.getPredictions()


writeCSV('mayPredictions2.csv',TU.outStr(TU.formatHours(mayHours),pred) )