krmonline's picture
Update wording
d47887e
import streamlit as st
import pickle
from sentence_transformers import SentenceTransformer
import pandas as pd
import numpy as np
lr_model_loaded = pickle.load(open('./models/lr_model.pkl', 'rb'))
scaler_loaded = pickle.load(open('./models/scaler.pkl', 'rb'))
stmodel = SentenceTransformer("all-MiniLM-L6-v2")
def predict(context):
r = stmodel.encode(context)
y_pred = scaler_loaded.transform([r])
#print(y_pred)
result = lr_model_loaded.predict(y_pred)
return 'บทวิเคราะห์' if result[0] == 1 else 'ไม่ใช่บทวิเคราะห์'
st.write("# News Analyzer\n")
st.write("เป็น Model สำหรับตรวจสอบว่าข่าวนี้เป็นข่าวประเภทบทวิเคราะห์หรือไม่")
context = st.text_area('สามารถวางเนื้อหาข่าวเพื่อตรวจสอบได้ที่นี่',height=300)
if context:
with st.spinner(text="In progress..."):
r = predict(context)
if r == "บทวิเคราะห์":
st.write("## เนื้อหานี้เป็นบทวิเคราะห์")
else:
st.write("## เนื้อหานี้ไม่ใช่บทวิเคราะห์")