rexarski commited on
Commit
494bac0
1 Parent(s): 29cb445

[UPDATE, DOCS] update app.py

Browse files

- add emoji to prediction results
- update space name

Files changed (2) hide show
  1. README.md +1 -1
  2. app.py +51 -11
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: Climate Plus Demo
3
  emoji: 🌦️
4
  colorFrom: yellow
5
  colorTo: blue
 
1
  ---
2
+ title: climate-plus demo
3
  emoji: 🌦️
4
  colorFrom: yellow
5
  colorTo: blue
app.py CHANGED
@@ -71,7 +71,12 @@ def tcfd_classify(text):
71
 
72
 
73
  data1 = {
74
- "example": ["Example 1", "Example 2", "Example 3", "Example 4"],
 
 
 
 
 
75
  "claim": [
76
  "Sea ice has diminished much faster than scientists and climate models anticipated.",
77
  "Climate Models Have Overestimated Global Warming",
@@ -88,7 +93,12 @@ data1 = {
88
  }
89
 
90
  data2 = {
91
- "example": ["Example 1", "Example 2", "Example 3", "Example 4"],
 
 
 
 
 
92
  "text": [
93
  "As a global provider of transport and logistics services, we are often called on for expert input and industry insights by government representatives.",
94
  "There are no sentences in the provided excerpts that disclose Scope 1 and Scope 2, and, if appropriate Scope 3 GHG emissions. The provided excerpts focus on other metrics and targets related to social impact investing, assets under management, and carbon footprint calculations.",
@@ -103,9 +113,27 @@ data2 = {
103
  ],
104
  }
105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  df1 = pd.DataFrame(data1)
107
  df2 = pd.DataFrame(data2)
108
 
 
 
109
 
110
  st.markdown("## Factchecking")
111
 
@@ -114,20 +142,32 @@ ex1_selected = st.selectbox(
114
  )
115
  selected_row1 = df1[df1["example"] == ex1_selected]
116
 
117
- st.markdown(f'**Claim**: {selected_row1["claim"].values[0]}')
118
- st.markdown(f'**Evidence**: {selected_row1["evidence"].values[0]}')
119
- st.markdown(f'**Label**: {selected_row1["label"].values[0]}')
120
- st.markdown("---")
 
 
 
 
 
121
  st.markdown(
122
- f'**Prediction**: {factcheck(selected_row1["claim"].values[0], selected_row1["evidence"].values[0])}'
123
  )
124
 
 
 
125
  st.markdown("## TCFD disclosure classification")
126
 
127
  ex2_selected = st.selectbox("Select a TCFD disclosure example", df2["example"])
128
  selected_row2 = df2[df2["example"] == ex2_selected]
129
 
130
- st.markdown(f'**Text**: {selected_row2["text"].values[0]}')
131
- st.markdown(f'**Label**: {selected_row2["label"].values[0]}')
132
- st.markdown("---")
133
- st.markdown(f'**Prediction**: {tcfd_classify(selected_row2["text"].values[0])}')
 
 
 
 
 
 
71
 
72
 
73
  data1 = {
74
+ "example": [
75
+ "Example 1 (Sea ice has diminished much faster than scientists and climate models anticipated.)",
76
+ "Example 2 (Climate Models Have Overestimated Global Warming)",
77
+ "Example 3 (Climate skeptics argue temperature records have been adjusted in recent years to ...)",
78
+ "Example 4 (Humans are too insignificant to affect global climate.)",
79
+ ],
80
  "claim": [
81
  "Sea ice has diminished much faster than scientists and climate models anticipated.",
82
  "Climate Models Have Overestimated Global Warming",
 
93
  }
94
 
95
  data2 = {
96
+ "example": [
97
+ "Example 1 (As a global provider of transport and logistics services ...)",
98
+ "Example 2 (There are no sentences in the provided excerpts that disclose Scope 1 and Scope 2)",
99
+ "Example 3 (Our strategy needs to be resilient under a range of climate-related scenarios.)",
100
+ "Example 4 (AXA created a Group-level Responsible Investment Committee ...)",
101
+ ],
102
  "text": [
103
  "As a global provider of transport and logistics services, we are often called on for expert input and industry insights by government representatives.",
104
  "There are no sentences in the provided excerpts that disclose Scope 1 and Scope 2, and, if appropriate Scope 3 GHG emissions. The provided excerpts focus on other metrics and targets related to social impact investing, assets under management, and carbon footprint calculations.",
 
113
  ],
114
  }
115
 
116
+
117
+ def get_pred_emoji(str1, str2, mode="factcheck"):
118
+ if mode == "factcheck":
119
+ if str1 == str2:
120
+ return "✅"
121
+ else:
122
+ return "❌"
123
+ elif mode == "tcfd":
124
+ if str1 == str2:
125
+ return "✅"
126
+ elif str1.split()[:-1] == str2.split()[:-1]:
127
+ return "🔧"
128
+ else:
129
+ return "❌"
130
+
131
+
132
  df1 = pd.DataFrame(data1)
133
  df2 = pd.DataFrame(data2)
134
 
135
+ st.markdown("# climate-plus demo")
136
+ st.markdown("This is a minimal example of two models we trained for `climate-plus` project. See the [GitHub repo](https://github.com/rexarski/climate-plus) for more details.")
137
 
138
  st.markdown("## Factchecking")
139
 
 
142
  )
143
  selected_row1 = df1[df1["example"] == ex1_selected]
144
 
145
+ ex_claim = selected_row1["claim"].values[0]
146
+ ex_evidence = selected_row1["evidence"].values[0]
147
+ ex_label = selected_row1["label"].values[0]
148
+ ex_pred = factcheck(
149
+ selected_row1["claim"].values[0], selected_row1["evidence"].values[0]
150
+ )
151
+ st.markdown(f"**Claim**: {ex_claim}")
152
+ st.markdown(f"**Evidence**: {ex_evidence}")
153
+ st.markdown(f"**Label**: {ex_label}")
154
  st.markdown(
155
+ f'**Prediction**: {ex_pred} {get_pred_emoji(ex_label, ex_pred, mode="factcheck")}'
156
  )
157
 
158
+ st.markdown("---")
159
+
160
  st.markdown("## TCFD disclosure classification")
161
 
162
  ex2_selected = st.selectbox("Select a TCFD disclosure example", df2["example"])
163
  selected_row2 = df2[df2["example"] == ex2_selected]
164
 
165
+ ex_text = selected_row2["text"].values[0]
166
+ ex_label2 = selected_row2["label"].values[0]
167
+ ex_pred2 = tcfd_classify(selected_row2["text"].values[0])
168
+
169
+ st.markdown(f"**Text**: {ex_text}")
170
+ st.markdown(f"**Label**: {ex_label2}")
171
+ st.markdown(
172
+ f'**Prediction**: {ex_pred2} {get_pred_emoji(ex_label2, ex_pred2, mode="tcfd")}'
173
+ )