kkawamu1 commited on
Commit
8ee5083
·
1 Parent(s): 226f67e

Add application file

Browse files
Files changed (3) hide show
  1. app.py +71 -0
  2. flagged/log.csv +9 -0
  3. requirements.tx +0 -0
app.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import gradio as gr
3
+ import gradio as gr; print(gr.__version__)
4
+
5
+ # Replace with path to your ESG data (CSV or other supported format)
6
+ data_path = "ESG_data.csv"
7
+ company_ratings = [
8
+ {"Company Name": "Apple Inc.", "Rating": 4.5},
9
+ {"Company Name": "Amazon.com, Inc.", "Rating": 4.2},
10
+ {"Company Name": "Microsoft Corporation", "Rating": 4.7},
11
+ {"Company Name": "Alphabet Inc. (Google)", "Rating": 4.8},
12
+ {"Company Name": "Tesla, Inc.", "Rating": 3.9},
13
+ {"Company Name": "Meta Platforms Inc. (Facebook)", "Rating": 3.1},
14
+ ]
15
+
16
+ # Load ESG data
17
+ esg_data = pd.DataFrame(company_ratings)
18
+ import gradio as gr
19
+ import pandas as pd
20
+
21
+
22
+ inputs = [gr.Dataframe(row_count = (2, "dynamic"), col_count=(4,"dynamic"), label="Input Data", interactive=1)]
23
+
24
+ outputs = [gr.Dataframe(row_count = (2, "dynamic"), col_count=(1, "fixed"), label="Predictions", headers=["Failures"])]
25
+
26
+
27
+
28
+ def infer(input_dataframe):
29
+ return pd.DataFrame(input_dataframe)
30
+
31
+ gr.Interface(fn = infer, inputs = inputs, outputs = outputs, examples = [[esg_data.head(2)]]).launch()
32
+
33
+ # def get_esg_scores(ticker):
34
+ # """
35
+ # Finds ESG scores for a given ticker symbol in the loaded data.
36
+
37
+ # Args:
38
+ # ticker (str): Ticker symbol of the company.
39
+
40
+ # Returns:
41
+ # pandas.DataFrame: Subset of ESG data for the ticker,
42
+ # containing ESG scores if found, or an empty DataFrame
43
+ # if not found.
44
+ # """
45
+ # filtered_data = esg_data[esg_data["Ticker Symbol"] == ticker.upper()]
46
+ # return filtered_data if not filtered_data.empty else pd.DataFrame()
47
+
48
+ # def display_esg_scores(dataframe):
49
+ # """
50
+ # Displays ESG scores in a table format if a DataFrame is provided,
51
+ # otherwise displays a message indicating no data found.
52
+
53
+ # Args:
54
+ # dataframe (pandas.DataFrame): DataFrame containing ESG scores.
55
+ # """
56
+ # if dataframe.empty:
57
+ # return "No ESG data found for this ticker."
58
+ # else:
59
+ # # Select relevant ESG score columns (adjust based on your data)
60
+ # esg_scores = dataframe[["Ticker Symbol", "Governance Score", "Social Score", "Environmental Score"]]
61
+ # return gr.DataTable(dataframe=esg_scores.to_dict())
62
+
63
+ # iface = gr.Interface(
64
+ # fn=get_esg_scores,
65
+ # inputs=gr.inputs.Textbox(label="Ticker Symbol"),
66
+ # outputs=esg_data,
67
+ # title="ESG Score Lookup",
68
+ # description="Enter a company ticker symbol to view its ESG scores (if available).",
69
+ # )
70
+
71
+ # iface.launch()
flagged/log.csv ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ name,Output,timestamp
2
+ ,Hello !!,2024-05-20 02:22:21.273157
3
+ ,Hello !!,2024-05-20 02:22:22.248193
4
+ ,Hello !!,2024-05-20 02:22:23.235456
5
+ ,Hello !!,2024-05-20 02:22:23.675012
6
+ ,Hello !!,2024-05-20 02:22:27.643848
7
+ ,Hello !!,2024-05-20 02:22:28.585934
8
+ ,Hello !!,2024-05-20 02:22:29.303183
9
+ ,Hello !!,2024-05-20 02:22:30.054843
requirements.tx ADDED
File without changes