def resultGUI(): error = None if request.method == 'GET': return redirect('/') else: price = int(request.form['price']) platforms = request.form.getlist('plat') types = request.form.getlist('typ') listGame = model.process(search_url=model.get_search_link(types), price=price, platform_list=platforms) return render_template('result.html', error=error, result_list=listGame)
def processrdd(rdd): try: transactions = rdd.map(lambda p : p['payload']) records = transactions.map(lambda p : p.split(",")) rowRecord = records.map(lambda p : Row(Timestamp=p[0],FeaA=p[1],FeaB=p[2],FeaC=p[3],FeaD=p[4],FeaE=p[5])) for x in records.collect(): print(x) for y in records.collect(): print(y) transactionsDataFrame = spark.createDataFrmae(rowRecord) output = process(transactionsDataFrame) for x in output: print(x) except: pass
def on_status(self, status): sj = status._json if sj['user']['id_str'] in good_user_ids: # with open(tweets_location + sj['user']['id_str'] + '.json', 'a') as f: # f.write(json.dumps(sj) + '\n') # # checking out time delays # print("received tweet: " + sj['text']) # time.sleep(150) # RESULT: APPEARS TO CUE TWEETS THAT FIRED WHILE PROCESSING, # BUT DOES NOT DO THE PROCESSING AT THE SAME TIME # THAT IS, THE TWO PARTS OF EACH TWEET PRINT FOLLOWING EACHOTHER # AND IMMEDIATELY AFTER THE SECOND, THE NEXT CUED ONE PRINTS ITS # FIRST PART # ASYNC PARAMETER APPEARS NOT TO MATTER # (WHICH MAKES SENSE BECAUSE I THINK IT JUST MEANS # IT DOESN'T BLOCK AFTER FILTER CALL) retweeted = 'retweeted_status' in sj.keys() if retweeted: text = sj['retweeted_status']['text'] else: text = sj['text'] success, to_tweet = model.process(text, sj['user']['id_str'], retweeted) if success: print(sj['text'] + '\n', to_tweet) sys.stdout.flush() api.update_status("{} https://twitter.com/{}/status/{}".format( to_tweet, sj['user']['screen_name'], sj["id_str"])) else: print("uncategorized: ", sj['text']) sys.stdout.flush() # # m_result = model.categorize(sj['text']) # if m_result[0]: # print(sj['text'], m_result[1]) # sys.stdout.flush() # message = "Tweet by {} (retweeted: {})".format(sj['user']['screen_name'], 'yes' if 'retweeted_status' in sj.keys() else 'no') # api.update_status("{} https://twitter.com/{}/status/{}".format(message,sj['user']['screen_name'],sj["id_str"]))#, in_reply_to_status_id = sj["id_str"]) if log: with open(log_location, 'a') as f: f.write('stored tweet ' + sj["id_str"] + ' from ' + sj['user']['screen_name'] + " (" + sj['user']['id_str'] + ")\n")
def model_image(): image_url = md.process(request.files['files']) return render_template('processat.html', value=image_url)
cur_streaming = True else: if cur_streaming: breakdown.append(str(cur_segment)) cur_segment = 1 cur_streaming = False else: cur_segment += 1 return ' '.join(breakdown) for root, dirs, files in sorted(os.walk(PACK_DIR)): for fn in files: if fn.endswith('.sm'): song_fn = os.path.join(root, fn) print(song_fn) X = [] with open(song_fn, 'r') as f: lines = f.readlines() song = model.process(lines) difficulties = sorted(song['charts']) for difficulty in difficulties: chart_data = song['charts'][difficulty] breakdown = get_breakdown(chart_data) print(difficulty) print(breakdown) print('*' * 80)
#Make sure we are running inside a virtualenv if not hasattr(sys, 'real_prefix') and detector.GLOBAL_WINDOWS==False: print "No virtualenv set. Please activate a virtualenv before running." sys.exit() if __name__=='__main__': loader = dataloader(label_file, image_directory, num_images) if(reprocess): data = loader.get_data() image_paths, labels=zip(*data) process = preprocess(image_paths) processed = process.process_images() feature_extractor = feature.feature() features = feature_extractor.extract_features(processed) #loader.write_csv('vecs.csv', map(list, zip(labels, features))) else: rows = loader.load_features('vecs.csv') print np.array(rows).shape labels, features = zip(*rows) print features model = model.model_w_cv(features, labels, n_fold_cv) model.process(12000, 1.5) #model = model(features, labels, n_fold_cv) #print model.fixed_params(0.4, 1.5) #model.optimise_sgd()