Christopher Román Jaimes
commited on
Commit
·
1b6b3cf
1
Parent(s):
1ef8976
chore: add raw predictions.
Browse files
app.py
CHANGED
@@ -138,38 +138,6 @@ def clean_prediction(row, feature_name, threshols_dict, clean_functions_dict):
|
|
138 |
return prediction_clean
|
139 |
else:
|
140 |
return None
|
141 |
-
|
142 |
-
def calculate_metrics(X, feature_name, data_type):
|
143 |
-
true_positives = 0
|
144 |
-
true_negatives = 0
|
145 |
-
false_positives = 0
|
146 |
-
false_negatives = 0
|
147 |
-
for pred, true in zip(X[f"clean_pred_{feature_name}"], X[f"clean_{feature_name}"]):
|
148 |
-
if isinstance(pred, data_type):
|
149 |
-
if isinstance(true, data_type):
|
150 |
-
if pred == true:
|
151 |
-
true_positives += 1
|
152 |
-
else:
|
153 |
-
false_positives += 1
|
154 |
-
else:
|
155 |
-
false_positives += 1
|
156 |
-
else:
|
157 |
-
if isinstance(true, data_type):
|
158 |
-
false_negatives += 1
|
159 |
-
else:
|
160 |
-
true_negatives += 1
|
161 |
-
|
162 |
-
# Calculate Metrics
|
163 |
-
precision = true_positives / (true_positives + false_positives) if (true_positives + false_positives) != 0 else np.nan
|
164 |
-
recall = true_positives / (true_positives + false_negatives) if (true_positives + false_negatives) != 0 else np.nan
|
165 |
-
f1_score = 2 * (precision * recall) / (precision + recall) if (precision + recall) != 0 else np.nan
|
166 |
-
metrics = {
|
167 |
-
"precision": precision,
|
168 |
-
"recall": recall,
|
169 |
-
"f1_score": f1_score,
|
170 |
-
}
|
171 |
-
|
172 |
-
return metrics
|
173 |
|
174 |
def extract_remodeling_year_from_string(string):
|
175 |
if isinstance(string, str):
|
@@ -251,7 +219,7 @@ def generate_answer(text):
|
|
251 |
|
252 |
result_json = json.dumps(entities_cleaned, indent = 4, ensure_ascii = False)
|
253 |
|
254 |
-
return result_json
|
255 |
|
256 |
# Cambiar a entrada de texto
|
257 |
#text_input = gr.inputs.Textbox(lines=15, label="Input Text")
|
|
|
138 |
return prediction_clean
|
139 |
else:
|
140 |
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
|
142 |
def extract_remodeling_year_from_string(string):
|
143 |
if isinstance(string, str):
|
|
|
219 |
|
220 |
result_json = json.dumps(entities_cleaned, indent = 4, ensure_ascii = False)
|
221 |
|
222 |
+
return result_json + "\n \n" + entities_formatted
|
223 |
|
224 |
# Cambiar a entrada de texto
|
225 |
#text_input = gr.inputs.Textbox(lines=15, label="Input Text")
|