def introduction(): if g.user == None: return redirect(url_for('login')) if request.method == 'GET': example_index = request.args.get('example', default=0, type=int) create_table_from_csv(example_index) json_object = get_db_data_json(example_index) json_dataset = yaml.safe_load(json_object)["records"] dataset_stat = dataset_pre_analysis(json_dataset) dataset_face = dataset_preprocess(json_dataset, dataset_stat) db.session.add( User_Action('user made dataset selection {}'.format(example_index), session['user_id'])) db.session.add(User_Action('user at intro page', session['user_id'])) #log data db.session.commit() return render_template( 'introduction.html', json_data=json_object, dataset_face=dataset_face, example=str(example_index), title='Introduction') #render next page with passing json object else: return 'Invalid Data'
def cluster(): if g.user == None: return redirect(url_for('login')) if request.method == 'GET': example_index = request.args.get('example', default=0, type=int) k_value = request.args.get('k', default=2, type=int) unmapped = request.args.getlist('unmapped') unmapped_list = [str(x) for x in unmapped] unmapped_list = unmapped_list[0].split(',') # print('--------') # print(k_value) json_object = get_db_data_json(example_index) json_dataset = yaml.safe_load(json_object)["records"] dataset_stat = dataset_pre_analysis(json_dataset) dataset_face = dataset_preprocess(json_dataset, dataset_stat) # dataset_array, centroids, labels = clustering(k_value, json_dataset) dataset_array, centroids, labels = clustering(k_value, dataset_face, unmapped_list) if example_index == 2 and k_value == 4: f = open('example2.json', ) data = json.load(f) json_cluster = json.dumps(data) # print('--------') f.close() else: json_cluster = json4cluster(dataset_array, centroids, labels, example_index, dataset_face) # with open('cluster.json', 'w') as outfile: # json.dump(json_cluster , outfile) db.session.add( User_Action( 'user at cluster page with k value {} and unmapped features {}' .format(k_value, unmapped_list), session['user_id'])) #log data db.session.commit() return render_template('cluster2.html', example=str(example_index), json_data=json_object, dataset_face=dataset_face, centroids=centroids, k=k_value, json_cluster=json_cluster, title='Automatic Clustering') else: return 'Invalid Data'
def compare(): if g.user == None: return redirect(url_for('login')) if request.method == 'GET': example_index = request.args.get('example', default=0, type=int) json_object = get_db_data_json(example_index) json_dataset = yaml.safe_load(json_object)["records"] dataset_stat = dataset_pre_analysis(json_dataset) dataset_face = dataset_preprocess(json_dataset, dataset_stat) db.session.add(User_Action('user at compare page', session['user_id'])) #log data db.session.commit() return render_template('compare.html', example=str(example_index), json_data=json_object, dataset_face=dataset_face, title='Smilarity Comparison') else: return 'Invalid Data'
def feature_map(): if g.user == None: return redirect(url_for('login')) if request.method == 'GET': example_index = request.args.get('example', default=0, type=int) create_table_from_csv(example_index) json_object = get_db_data_json(example_index) json_dataset = yaml.safe_load(json_object)["records"] dataset_stat = dataset_pre_analysis(json_dataset) dataset_face = dataset_preprocess(json_dataset, dataset_stat) db.session.add( User_Action('user at feature mapping page', session['user_id'])) #log data db.session.commit() return render_template('feature_map.html', json_data=json_object, dataset_face=dataset_face, example=str(example_index), title='Make Your Emoji') else: return 'Invalid Data'