File size: 2,484 Bytes
fea28a2 af8f9ea fea28a2 af8f9ea 2d60e44 3222a7d af8f9ea 6485f40 3222a7d 6485f40 fea28a2 6485f40 fea28a2 6485f40 22da6c9 af8f9ea 6485f40 fea28a2 6485f40 af8f9ea 6485f40 af8f9ea fea28a2 af8f9ea 6485f40 fea28a2 2507c18 fea28a2 af8f9ea 6485f40 3fc3b9c 6485f40 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | #!/usr/bin/env python
# coding: utf-8
import pandas as pd
import random
from IPython.display import display
# import ipywidgets as widgets
import gradio as gr
from pipeline import getEngine
from dotenv import load_dotenv
from config import getParams
load_dotenv()
params = getParams('config.yaml')
art_descr = params['art_descr']
with open('style/app.css', 'r') as css_f:
css = css_f.read()
# load existing data from file (in widget: drag-drop your file?)
df = pd.read_parquet(
params['stock_price_fn']
).interpolate(method="linear", axis=1)
tickers_desc_all = pd.read_parquet(params['tickers_descriptors_fn'])
tickers_desc_prefilter = tickers_desc_all.loc[df.columns]
sectors = list(tickers_desc_prefilter["sector"].unique()[0:10])
engines = ["corrinv", "lof", "geo (BETA)"]
if_inputs = [
gr.Textbox(lines=1, label="Keywords search", placeholder="Keywords Here..."),
gr.Checkbox(label="Exact match", value=False),
gr.Dropdown(sectors, label="Sectors picker"),
gr.Dropdown(engines, label="Detection engine"),
gr.Slider(0, 100, label="Relevance threshold (percentile)", value=15),
gr.Slider(0, 1, step=0.01, label="Correlation threshold (0-1)", value=0.875),
gr.Slider(0, 1, step=0.1, label="Cutoff point (0-1)", value=0.5),
gr.Checkbox(
label="Generate natural language outcome (EXPERIMENTAL)", value=False
),
]
if_outputs = [
gr.DataFrame(
label=(
"Top matching tickers, sorted by descending relevance [FOR DEMO"
" PURPOSES ONLY]"
),
headers=["symbol", "keywords", "relevance", "industry"],
),
gr.Textbox(label="Matching tickers count (search space size)"),
gr.Textbox(label="Anomaly detection outcome"),
gr.Image(label="Anomaly plot"),
gr.Textbox(label="Human-readable description (EXPERIMENTAL)"),
]
demo = gr.Interface(
css = css,
title = "Batonics AB | Anomalous events detection pipeline",
description = art_descr,
fn = getEngine, # pick pipeline, use chosen engine
inputs = if_inputs,
outputs = if_outputs,
examples = params['examples'],
cache_examples = False,
allow_flagging = "auto",
)
if __name__ == "__main__":
# demo.launch(auth_message="Contact matteo@batonics.com to get access.")
demo.launch(
#auth=("batonics", "batonicsdemo22"),
server_name = '0.0.0.0',
show_api = False,
)
|