Update app_pages/page1_model_comparison.py
Browse files
app_pages/page1_model_comparison.py
CHANGED
|
@@ -2,6 +2,7 @@ import streamlit as st
|
|
| 2 |
from app_models.rubert_MODEL import classify_text
|
| 3 |
from app_models.bag_of_words_MODEL import predict
|
| 4 |
from app_models.lstm_MODEL import predict_review
|
|
|
|
| 5 |
|
| 6 |
class_prefix = 'This review is likely...'
|
| 7 |
|
|
@@ -14,17 +15,24 @@ def run():
|
|
| 14 |
|
| 15 |
|
| 16 |
if st.button('Classify with All Models'):
|
| 17 |
-
# Bag of Words/TF-IDF prediction
|
|
|
|
| 18 |
bow_tfidf_result = predict(user_input)
|
| 19 |
-
|
|
|
|
| 20 |
|
| 21 |
-
# LSTM prediction
|
|
|
|
| 22 |
lstm_result = predict_review(user_input)
|
| 23 |
-
|
|
|
|
| 24 |
|
| 25 |
-
# ruBERT prediction
|
|
|
|
| 26 |
rubert_result = classify_text(user_input)
|
| 27 |
-
|
|
|
|
|
|
|
| 28 |
|
| 29 |
# Placeholder buttons for model selection
|
| 30 |
# if st.button('Classify with BoW/TF-IDF'):
|
|
|
|
| 2 |
from app_models.rubert_MODEL import classify_text
|
| 3 |
from app_models.bag_of_words_MODEL import predict
|
| 4 |
from app_models.lstm_MODEL import predict_review
|
| 5 |
+
import time
|
| 6 |
|
| 7 |
class_prefix = 'This review is likely...'
|
| 8 |
|
|
|
|
| 15 |
|
| 16 |
|
| 17 |
if st.button('Classify with All Models'):
|
| 18 |
+
# Measure and display Bag of Words/TF-IDF prediction time
|
| 19 |
+
start_time = time.time()
|
| 20 |
bow_tfidf_result = predict(user_input)
|
| 21 |
+
end_time = time.time()
|
| 22 |
+
st.write(f'{class_prefix} {bow_tfidf_result} according to Bag of Words/TF-IDF. Time taken: {end_time - start_time:.2f} seconds.')
|
| 23 |
|
| 24 |
+
# Measure and display LSTM prediction time
|
| 25 |
+
start_time = time.time()
|
| 26 |
lstm_result = predict_review(user_input)
|
| 27 |
+
end_time = time.time()
|
| 28 |
+
st.write(f'{class_prefix} {lstm_result} according to LSTM. Time taken: {end_time - start_time:.2f} seconds.')
|
| 29 |
|
| 30 |
+
# Measure and display ruBERT prediction time
|
| 31 |
+
start_time = time.time()
|
| 32 |
rubert_result = classify_text(user_input)
|
| 33 |
+
end_time = time.time()
|
| 34 |
+
st.write(f'{class_prefix} {rubert_result} according to ruBERT. Time taken: {end_time - start_time:.2f} seconds.')
|
| 35 |
+
|
| 36 |
|
| 37 |
# Placeholder buttons for model selection
|
| 38 |
# if st.button('Classify with BoW/TF-IDF'):
|