import gradio as gr # from langchain.vectorstores import Chroma ''' https://huggingface.co/spaces/kevinhug/clientX https://hits.seeyoufarm.com/ ''' ''' PORTFOLIO OPTIMIZATION ''' from aiOpt import Asset import numpy as np def optimize(cost, prob, its): s = Asset(np.asfarray(cost.split()), np.asfarray(prob.split())) return s.random_restart(int(its)) ''' TIME SERIES ANALYTICS ''' import pandas as pd import plotly.express as px def trend(t): ''' import yfinance as yf from sklearn.preprocessing import StandardScaler data = yf.download(t, period="3mo") for c in t.split(' '): q=data.loc[:,('Close',c)] data.loc[:,('Close_MA',c)]=q.rolling(9).mean() -q.rolling(42).mean() q=data.loc[:,('Volume',c)] data.loc[:,('Volume_MA',c)]=q.rolling(9).mean() -q.rolling(42).mean() ma=data.loc[:,["Volume_MA","Close_MA"]].tail(15) std=StandardScaler() result=std.fit_transform(ma) df=pd.DataFrame(result,columns=ma.columns) d=df.tail(1).stack(level=-1).droplevel(0, axis=0) ''' d=pd.read_pickle("data.pkl") ''' https://www.gradio.app/docs/plot fig = px.line(df, x="day", y=countries) fig.update_layout( title="Outbreak in " + month, xaxis_title="Cases", yaxis_title="Days Since Day 0", ) return fig ''' fig=px.scatter(d, x="Close_MA", y="Volume_MA",color='ticker') fig.update_layout( title="Top Right is the Growth Industry", xaxis_title="Trend in Price", yaxis_title="Trend in Volume", ) return fig #return gr.ScatterPlot(d, x="Close_MA", y="Volume_MA",color='ticker') ''' SIMILAR VECTOR DB SEARCH ''' import chromadb client = chromadb.PersistentClient(path="chroma.db") db = client.get_collection(name="banks") def similar(issue): global db docs = db.query(query_texts=issue, n_results=5) return docs ''' FINE TUNE LLM LIKE SCORE ''' from fastai.text.all import * import pathlib p=pathlib.Path('./banks_txt_like.pkl').resolve() ''' NotImplementedError: cannot instantiate ‘WindowsPath’ on your system ''' import platform plt = platform.system() if plt == 'Windows': pathlib.PosixPath = pathlib.WindowsPath else: pathlib.WindowsPath = pathlib.PosixPath learn = load_learner(p) def like(issue): pred,idx,probs = learn.predict(issue) return pred ''' EXPLAINABLE AI ''' ''' https://www.gradio.app/docs/interface ''' with gr.Blocks() as demo: ''' https://hits.seeyoufarm.com/ https://dash.elfsight.com ''' counter="""
 """ # gr.HTML(counter) gr.Markdown("""Enhancing Customer Engagement and Operational Efficiency with NLP ========= 1) Semantic Similarity Document Search (SSDS) 2) Fine Tune LLM 3) Trading Analytic: Using Time Series Data to Identify Growth 4) Portfolio Optimization with cost, probabilities #### Data Scientist: Kevin Wong, objectdeveloper@gmail.com, 416-903-7937 ##### Open source ml bank dataset, __I'm just using a small sample of this data set for demo__ https://www.kaggle.com/datasets/trainingdatapro/20000-customers-reviews-on-banks/?select=Banks.csv [](https://hits.seeyoufarm.com) """) with gr.Tab("Semantic Similarity Document Search (SSDS)"): in_similar = gr.Textbox(placeholder="having credit card problem", label="Issue", info="issue you want to explore about" ) out_similar = gr.JSON(label="Similar Verbatim") btn_similar = gr.Button("Find Similar Verbatim") btn_similar.click(fn=similar, inputs=in_similar, outputs=out_similar) gr.Examples( [ ["having credit card problem"], ["low interest credit card"], ["loan"], ["upset customer"], ["what is the password"], ], [in_similar] ) gr.Markdown(""" Description: ======= In today's dynamic financial landscape, the Semantic Similarity Document Search (SSDS) capability is a practical innovation to improve client experience, marketing leads, and sentiment analysis. As a Data Scientist with a decades in the financial industry, I see the value of SSDS in action. Investment Portfolio Construction/Marketing Leads: ------ To enhance marketing strategies, SSDS identifies market trends and consumer preferences, such as the demand for low-interest credit cards, and GIC. It's a treasure trove for refining our product offerings to the targeted customer according to their credit score, risk appetite, demographic, collateral, capital, and economic conditions, enhancing the lift and efficiency of the recommendation process. Combining **SingleStore MEMSQL/Kafka structured streaming** for a real-time recommendation for closing sales at the right time in the right channel. Optimize your Asset Allocation with your objective function and cost function. ### issue: - low interest credit card - GIC AML/KYC/Compliance/Audit/Cyber Security/Fraud Analytics/Observability: ------ ### vite vue chart.js UI demo https://kevinwkc.github.io/davinci/ ### Proactive Detection: Identify potential fraud threats and vulnerabilities in real-time. Customer-Centric Approach: Gain insights into customer concerns, allowing us to address them promptly. #### issue: - what is the password Client Experience: ------ When a client faces a bad experience, SSDS helps us swiftly locate relevant documents to understand and address their concerns, be it credit card issues, late payment fees, or credit score drops. ### issue: - having bad client experience - having credit card problem - late payment fee - credit score dropping Sentiments: ------ SSDS tracks customer sentiment, empowering us to swiftly respond to upset customers. It ensures we address their issues promptly, enhancing trust and loyalty. With no need for jargon, SSDS delivers tangible value to our fintech operations. It's about staying agile, informed, and customer-centric in a rapidly changing financial world. ### issue: - upset customer """) with gr.Accordion("Future Improvement"): gr.Markdown(""" tuning the distance for use case """) with gr.Tab("Explainable AI"): gr.Markdown("""