def run_analysis(img: ImageData) -> dict: """ Analyzes and returns information on the given image. :param img: :return: """ tags = [] a_start = timer() results = run_predict(img.data) a_end = timer() b_start = timer() tags += analyze_results(results) # tags += analyze_colors(img.data) b_end = timer() width, height, orientation = get_image_info(img.data) print('----- Analysis Results -----') print(f'width: {width} | height: {height} | orientation: {orientation}') for tag in tags: print(tag) print('----------------------------') print(f'Inference took {a_end - a_start} seconds') print(f'Analysis took {b_end - b_start} seconds') print('') return { 'width': width, 'height': height, 'orientation': orientation, 'tags': tags }
def character_classification(): """run character classifiation prediction --- parameters: - name: body in: body schema: id: text required: - text properties: text: type: string description: the required text for POST method required: true definitions: SentimentResponse: Project: properties: status: type: string ml-result: type: object responses: 40x: description: Client error 200: description: Character Classification Response examples: [ { "status": "success", "sentiment": "1" }, { "status": "error", "message": "Exception caught" }, ] """ json_request = request.get_json() if not json_request: return Response("No json provided.", status=400) text = json_request['text'] if text is None: return Response("No text provided.", status=400) else: label = run_predict(text) return flask.jsonify({"status": "success", "label": label})
def predicting(load_path): model = joblib.load(load_path + 'model.pkl') S_test = joblib.load(load_path + 'S_test.pkl') y_test = joblib.load(load_path + 'y_test.pkl') run_predict((model, S_test, y_test))
if test_bool == True: gridsearch = True print('Running star binary') conf = ConfigVars(test = test_bool, kind = 'star', gridsearch = gridsearch) lib = HelperFunctions(conf) run_binary(conf, lib) print('Running galaxy binary') conf = ConfigVars(test = test_bool, kind = 'galaxy', gridsearch = gridsearch) lib = HelperFunctions(conf) run_binary(conf, lib) print('Running qso binary') conf = ConfigVars(test = test_bool, kind = 'qso', gridsearch = gridsearch) lib = HelperFunctions(conf) run_binary(conf, lib) print('Running consolidation') conf = ConfigVars(test = test_bool) lib = HelperFunctions(conf) run_consolidation(conf, lib) print('Running prediction') after_opt_str = run_predict(conf, lib) if test_bool == True: assert after_opt_str == 'optimal consolidation method: star: 21135, gal: 24111, qso: 1173, outlier: 3581.\n' , 'Test run failed' if after_opt_str == 'optimal consolidation method: star: 21135, gal: 24111, qso: 1173, outlier: 3581.\n': print('Test run passed.')
ohlc['ts'] = ohlc[0] data = pd.merge(ohlc, token_data, on='ts') data.drop(['ts'], axis='columns', inplace=True) data.reset_index(drop=True, inplace=True) if not first_start: data = data[-2:] update_markets_data(data) def exchange_data(first_start): # TODO futures trades = get_trades() bids, asks = get_orderbook() bids['pr'] = bids[0] * bids[1] bids_avg = bids['pr'].sum() / bids[1].sum() asks['pr'] = asks[0] * asks[1] asks_avg = asks['pr'].sum() / asks[1].sum() if __name__ == "__main__": first_start = True while True: try: market_data(first_start) exchange_data(first_start) run_predict() first_start = False time.sleep(360) except: print(datetime.datetime.now(), traceback.format_exc())
def main(): get_number() guess = predict.run_predict() show_predict(guess)