Update app.py
Browse files
app.py
CHANGED
|
@@ -90,6 +90,9 @@ def process_classification(text: str, model1, model2, tokenizer1) -> Tuple[str,
|
|
| 90 |
|
| 91 |
return f"{round(prediction1, 1)}", f"{round(prediction2, 1)}", f"{round(score, 2)}"
|
| 92 |
|
|
|
|
|
|
|
|
|
|
| 93 |
def generate_charts(ner_output_bin: dict, ner_output_ext: dict) -> Tuple[go.Figure, go.Figure]:
|
| 94 |
entities_bin = [entity['entity'] for entity in ner_output_bin['entities']]
|
| 95 |
entities_ext = [entity['entity'] for entity in ner_output_ext['entities']]
|
|
@@ -104,7 +107,6 @@ def generate_charts(ner_output_bin: dict, ner_output_ext: dict) -> Tuple[go.Figu
|
|
| 104 |
ext_labels = list(entity_counts_ext.keys())
|
| 105 |
ext_sizes = list(entity_counts_ext.values())
|
| 106 |
|
| 107 |
-
|
| 108 |
# Define color mapping
|
| 109 |
bin_color_map = {
|
| 110 |
"External": "#6ad5bc",
|
|
@@ -127,7 +129,12 @@ def generate_charts(ner_output_bin: dict, ner_output_ext: dict) -> Tuple[go.Figu
|
|
| 127 |
|
| 128 |
# Create pie chart for extended classification
|
| 129 |
fig1 = go.Figure(data=[go.Pie(labels=ext_labels, values=ext_sizes, textinfo='label+percent', hole=.3, marker=dict(colors=ext_colors))])
|
| 130 |
-
fig1.update_layout(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
|
| 132 |
# Create bar chart for binary classification
|
| 133 |
fig2 = go.Figure(data=[go.Bar(x=bin_labels, y=bin_sizes, marker=dict(color=bin_colors))])
|
|
@@ -135,7 +142,9 @@ def generate_charts(ner_output_bin: dict, ner_output_ext: dict) -> Tuple[go.Figu
|
|
| 135 |
title='Binary Sequence Classification Classes',
|
| 136 |
xaxis_title='Entity Type',
|
| 137 |
yaxis_title='Count',
|
| 138 |
-
template='plotly_dark'
|
|
|
|
|
|
|
| 139 |
)
|
| 140 |
|
| 141 |
return fig1, fig2
|
|
|
|
| 90 |
|
| 91 |
return f"{round(prediction1, 1)}", f"{round(prediction2, 1)}", f"{round(score, 2)}"
|
| 92 |
|
| 93 |
+
import plotly.graph_objects as go
|
| 94 |
+
from typing import Tuple
|
| 95 |
+
|
| 96 |
def generate_charts(ner_output_bin: dict, ner_output_ext: dict) -> Tuple[go.Figure, go.Figure]:
|
| 97 |
entities_bin = [entity['entity'] for entity in ner_output_bin['entities']]
|
| 98 |
entities_ext = [entity['entity'] for entity in ner_output_ext['entities']]
|
|
|
|
| 107 |
ext_labels = list(entity_counts_ext.keys())
|
| 108 |
ext_sizes = list(entity_counts_ext.values())
|
| 109 |
|
|
|
|
| 110 |
# Define color mapping
|
| 111 |
bin_color_map = {
|
| 112 |
"External": "#6ad5bc",
|
|
|
|
| 129 |
|
| 130 |
# Create pie chart for extended classification
|
| 131 |
fig1 = go.Figure(data=[go.Pie(labels=ext_labels, values=ext_sizes, textinfo='label+percent', hole=.3, marker=dict(colors=ext_colors))])
|
| 132 |
+
fig1.update_layout(
|
| 133 |
+
title_text='Extended Sequence Classification Subclasses',
|
| 134 |
+
template='plotly_dark',
|
| 135 |
+
plot_bgcolor='rgba(0,0,0,0)',
|
| 136 |
+
paper_bgcolor='rgba(0,0,0,0)'
|
| 137 |
+
)
|
| 138 |
|
| 139 |
# Create bar chart for binary classification
|
| 140 |
fig2 = go.Figure(data=[go.Bar(x=bin_labels, y=bin_sizes, marker=dict(color=bin_colors))])
|
|
|
|
| 142 |
title='Binary Sequence Classification Classes',
|
| 143 |
xaxis_title='Entity Type',
|
| 144 |
yaxis_title='Count',
|
| 145 |
+
template='plotly_dark',
|
| 146 |
+
plot_bgcolor='rgba(0,0,0,0)',
|
| 147 |
+
paper_bgcolor='rgba(0,0,0,0)'
|
| 148 |
)
|
| 149 |
|
| 150 |
return fig1, fig2
|