def getPredictionScoreOfTrainingSet(): """ Returns the score of the classifications on the validation set. """ hand_classified_set = loader.get_hand_classifiedset() algo_classified_set = loader.get_algo_classifiedset() total = 0 scores = [] for uid, actual in hand_classified_set.iteritems(): guess = algo_classified_set[uid] scores.append(util.score_prediction(guess, actual)) total = sum(scores) max_potential = len(hand_classified_set.keys()) * 6 return total / float(max_potential)
return render_template('classifypage.html', business=business, naics_dict=naics_dict, agent=agent) @app.route('/c/<agent>/<test>/<business_uid>/<naics_code>', methods=['POST']) def classifyBusiness(agent, test, business_uid, naics_code): if request.method == 'POST': loader.write_row_classified_set(business_uid, naics_code) if test != 'test': loader.write_row_hand_classified_set(business_uid, naics_code) return redirect('/classifier/' + agent) else: return abort(405) # 405 Method Not Allowed @app.route('/database') @app.route('/database/<int:page>', methods=['GET']) def databaseView(page=1): businesses = dbh.getBusinessPage(page) return render_template('database.html', businesses=businesses, hand_classified_set=hand_classified_set, algo_classified_set=algo_classified_set, naics_dict=naics_dict) if __name__ == "__main__": naics_items = loader.get_naics_data_for_level(6) hand_classified_set = loader.get_hand_classifiedset() algo_classified_set = loader.get_algo_classifiedset() unclassified_business_ids = loader.get_unclassified_business_ids() business_types = loader.get_business_types() naics_dict = loader.get_naics_dict() app.run(debug=True)
def __init__(self): self.hand_classified_set = loader.get_hand_classifiedset() self.algo_classified_set = loader.get_algo_classifiedset()
@app.route('/c/<agent>/<test>/<business_uid>/<naics_code>', methods=['POST']) def classifyBusiness(agent, test, business_uid, naics_code): if request.method == 'POST': loader.write_row_classified_set(business_uid, naics_code) if test != 'test': loader.write_row_hand_classified_set(business_uid, naics_code) return redirect('/classifier/' + agent) else: return abort(405) # 405 Method Not Allowed @app.route('/database') @app.route('/database/<int:page>', methods=['GET']) def databaseView(page=1): businesses = dbh.getBusinessPage(page) return render_template('database.html', businesses=businesses, hand_classified_set=hand_classified_set, algo_classified_set=algo_classified_set, naics_dict=naics_dict) if __name__ == "__main__": naics_items = loader.get_naics_data_for_level(6) hand_classified_set = loader.get_hand_classifiedset() algo_classified_set = loader.get_algo_classifiedset() unclassified_business_ids = loader.get_unclassified_business_ids() business_types = loader.get_business_types() naics_dict = loader.get_naics_dict() app.run(debug=True)